How to get started with Google Cloud Client Libraries

Google Cloud Tech · Beginner ·📄 Research Papers Explained ·6mo ago

Key Takeaways

The video demonstrates how to get started with Google Cloud Client Libraries by installing the Google Cloud CLI, setting up application default credentials, and making a cloud client library call using Python. It covers the basics of cloud client libraries, including authentication and configuration.

Full Transcript

Cloud client libraries. In the last episode, I talked about what they are and why they're so useful. I told you about how they significantly reduce the code that you need to write and handle all those low-level details like authentication. Now, [music] let's get a little bit more hands-on. We're going to set up an environment, get application default credentials configured, [music] and make our very first cloud client library call. This is what's what with cloud client libraries. If you're developing with Google Cloud on your local machine, you'll need to install the Google Cloud CLI or G-Cloud before you can access Google Cloud services. The Google Cloud CLI is part of the Google Cloud SDK. Not only does it let you manage Google Cloud resources from your terminal, it also handles authentication for your locally running application code. The instructions for installing the Google Cloud CLI vary by operating system, so I've linked instructions in the description. For the demonstration I'm about to walk through, I already have the CLI installed, just not configured. So, I've got a cloud storage bucket and I want to return a list of all the files that I have stored in it. Here's how I can do that with Python. Now, before I can run this, I'll install the dependencies with pip install. Rather than a single massive library, Google Cloud client libraries are split by service. Since I'm accessing Google Cloud Storage, I'll install the corresponding client library, Google Cloud Storage. You'll see this pattern for most of the services. Google Cloud compute, Google Cloud Secret Manager, and so on. This approach means you'll only install the code that you need, keeping your application light and clean. Let me do a quick rundown of the code here. First, I import the library for Google Cloud Storage. Next, I instantiate the client. The client is the main entry point for any subsequent calls to the API that I make in my application code. After that, I construct a request which in this case only requires the name of my GCS bucket as a resource path. And now the magic happens. The request is sent to Google Cloud using the list objects method of my client. And since the results are returned as an iterable object, I have a loop to simply print out the name of each object in my bucket. I'm going to run this now just to show you what happens. Like I mentioned before, I installed the Google Cloud CLI, but I haven't configured it. So, as expected, I get an authentication error. Our application doesn't know anything about who I am and what it's allowed to do on Google Cloud. To fix this, I need to get application default credentials or ADC for short. Application default credentials are a standard automatic way for your application to find the right permissions to talk to Google Cloud APIs. There are a few ways to provide your application with these credentials, but for local development, I'll show you the most straightforward approach. Run g-cloud o application-default login. This command opens a browser for you to sign in with your Google account and then creates a local credential file in a well-known location on your file system. You might receive a message like this one warning you about a missing quota project. Well, the quota project is a Google Cloud project that is responsible for billing and usage limits of an API call. I'll talk more about quota projects in a later video. This particular example doesn't need one. So, I'm going to keep going and run the code. Notice again that when we create the client, we don't explicitly provide any credentials. This is the magic of application default credentials. My code will automatically find the credentials I just set up and use them to authenticate to Google Cloud. And there we go. Now that I'm authenticated with my application default credentials, the code runs and I've got a list of my files right here. I didn't have to change a single line of my Python code to indicate credentials or other authentication details. With a single G-Cloud command, I configured my local environment and the client library automatically picked it up. That's the power of this approach. Now this is a very brief overview of how to get started with cloud client libraries with a very simple example as a preferred way of providing authentication to cloud client libraries. Application default credentials are an important [music] concept to understand. There's more to talk about there. So catch the next episode while I'll cover where your application is looking for those credentials, what they look like, and more. And as always, if you have any questions, feel free to drop them in the comments. Thanks for [music] watching. See you next time. Heat. Heat.

Original Description

What are Google Cloud Client Libraries? → https://goo.gle/4jb0mBg Install Google Cloud CLI → https://goo.gle/48MbOjd Guide: Set up Application Default Credentials → https://goo.gle/4qgPioe In a previous episode, Googler Roger Martinez explained what Cloud Client Libraries are and why they’re so useful. Now watch along as Roger demonstrates how to set up your environment, configure Application Default Credentials, and make our first client library call. Welcome back to What’s What: Cloud Client Libraries. Watch more What's What → https://goo.gle/WhatsWhat​ 🔔 Subscribe to Google Cloud Tech → https://goo.gle/GoogleCloudTech #GoogleCloud Speaker: Roger Martinez Products Mentioned: Cloud Client Libraries, Google Cloud Command Line Interface
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Google Cloud Tech · Google Cloud Tech · 0 of 60

← Previous Next →
1 I’m going for it #GoogleCloudCertified
I’m going for it #GoogleCloudCertified
Google Cloud Tech
2 I had to get #GoogleCloudCertified
I had to get #GoogleCloudCertified
Google Cloud Tech
3 Be better overall at what you do #GoogleCloudCertified
Be better overall at what you do #GoogleCloudCertified
Google Cloud Tech
4 Cloud Monitoring on our radar #Analysis #Uptime
Cloud Monitoring on our radar #Analysis #Uptime
Google Cloud Tech
5 Introduction to Generative AI Studio
Introduction to Generative AI Studio
Google Cloud Tech
6 How to use Github Actions with Google's Workload Identity Federation
How to use Github Actions with Google's Workload Identity Federation
Google Cloud Tech
7 Introduction to Responsible AI
Introduction to Responsible AI
Google Cloud Tech
8 Networking updates and CDMC-certified architecture
Networking updates and CDMC-certified architecture
Google Cloud Tech
9 Create and use a Cloud Storage bucket
Create and use a Cloud Storage bucket
Google Cloud Tech
10 How to digitize text from documents
How to digitize text from documents
Google Cloud Tech
11 Faster analytical queries with AlloyDB
Faster analytical queries with AlloyDB
Google Cloud Tech
12 Next ‘23 sessions and FaaS Wave
Next ‘23 sessions and FaaS Wave
Google Cloud Tech
13 Introduction to Assured Open Source Software
Introduction to Assured Open Source Software
Google Cloud Tech
14 BigQuery Cost Optimization: Storage
BigQuery Cost Optimization: Storage
Google Cloud Tech
15 BigQuery Cost Optimization: Compute
BigQuery Cost Optimization: Compute
Google Cloud Tech
16 BigQuery Cost Optimization: Select Queries
BigQuery Cost Optimization: Select Queries
Google Cloud Tech
17 Remote Field Equipment Management with Manufacturing Data Engine
Remote Field Equipment Management with Manufacturing Data Engine
Google Cloud Tech
18 Supercharging your applications with Cloud SQL Enterprise Plus
Supercharging your applications with Cloud SQL Enterprise Plus
Google Cloud Tech
19 Vector Support on our radar #GenAI
Vector Support on our radar #GenAI
Google Cloud Tech
20 Architecting a blockchain startup with Google Cloud
Architecting a blockchain startup with Google Cloud
Google Cloud Tech
21 Kubernetes and multitasking updates!
Kubernetes and multitasking updates!
Google Cloud Tech
22 GKE: Using Kubernetes Events
GKE: Using Kubernetes Events
Google Cloud Tech
23 How to configure firewall rules for Cloud Composer
How to configure firewall rules for Cloud Composer
Google Cloud Tech
24 Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Google Cloud Tech
25 Geospatial analytics on our radar #EarthEngine #BigQuery
Geospatial analytics on our radar #EarthEngine #BigQuery
Google Cloud Tech
26 Ensuring requests are set in Kubernetes
Ensuring requests are set in Kubernetes
Google Cloud Tech
27 Cloud Next 2023, Google research program, and more!
Cloud Next 2023, Google research program, and more!
Google Cloud Tech
28 How to migrate projects between organizations with Resource Manager
How to migrate projects between organizations with Resource Manager
Google Cloud Tech
29 How to run #MySQL in Google Cloud
How to run #MySQL in Google Cloud
Google Cloud Tech
30 #GenerativeAI for enterprises and #Next2023
#GenerativeAI for enterprises and #Next2023
Google Cloud Tech
31 How Google Photos scales to store 4 trillion photos and videos
How Google Photos scales to store 4 trillion photos and videos
Google Cloud Tech
32 Google Cross-Cloud Interconnect (Demo 2)
Google Cross-Cloud Interconnect (Demo 2)
Google Cloud Tech
33 GKE Cost Optimization Golden Signals: Introduction
GKE Cost Optimization Golden Signals: Introduction
Google Cloud Tech
34 GKE Cost Optimization Golden Signals: Workload Rightsizing
GKE Cost Optimization Golden Signals: Workload Rightsizing
Google Cloud Tech
35 GKE Load Balancing: Overview
GKE Load Balancing: Overview
Google Cloud Tech
36 GKE Load Balancing: Best Practices
GKE Load Balancing: Best Practices
Google Cloud Tech
37 Disaster Recovery in GKE
Disaster Recovery in GKE
Google Cloud Tech
38 How to configure IP masquerade agent in GKE Standard clusters
How to configure IP masquerade agent in GKE Standard clusters
Google Cloud Tech
39 Enable and use GKE Control plane logs
Enable and use GKE Control plane logs
Google Cloud Tech
40 Compliance in Australia with Assured Workloads
Compliance in Australia with Assured Workloads
Google Cloud Tech
41 Creating budgets and budget alerts in Google Cloud #FinOps
Creating budgets and budget alerts in Google Cloud #FinOps
Google Cloud Tech
42 Cloud SQL Enterprise Plus on our radar #mySQL
Cloud SQL Enterprise Plus on our radar #mySQL
Google Cloud Tech
43 What's Next for Google Cloud?
What's Next for Google Cloud?
Google Cloud Tech
44 How Loveholidays scaled with Contact Center AI
How Loveholidays scaled with Contact Center AI
Google Cloud Tech
45 What is fleet team management in GKE?
What is fleet team management in GKE?
Google Cloud Tech
46 Troubleshoot VPC Network Peering
Troubleshoot VPC Network Peering
Google Cloud Tech
47 Introduction to DocAI and Contact Center AI
Introduction to DocAI and Contact Center AI
Google Cloud Tech
48 Cloud Run Direct VPC egress explained
Cloud Run Direct VPC egress explained
Google Cloud Tech
49 Database deployment options in GKE
Database deployment options in GKE
Google Cloud Tech
50 Analyze cloud billing data with #BigQuery
Analyze cloud billing data with #BigQuery
Google Cloud Tech
51 Tips to becoming a world-class Prompt Engineer
Tips to becoming a world-class Prompt Engineer
Google Cloud Tech
52 Serverless is simple. Do I need CI/CD?
Serverless is simple. Do I need CI/CD?
Google Cloud Tech
53 Accelerating model deployment with MLOps
Accelerating model deployment with MLOps
Google Cloud Tech
54 How Hawaii's Department of Human Services scaled with CCAI
How Hawaii's Department of Human Services scaled with CCAI
Google Cloud Tech
55 Pricing API on our #Radar
Pricing API on our #Radar
Google Cloud Tech
56 How Recommendations AI for Media can boost customer retention
How Recommendations AI for Media can boost customer retention
Google Cloud Tech
57 Troubleshooting: Node Not Ready Status
Troubleshooting: Node Not Ready Status
Google Cloud Tech
58 One weekend until Cloud Next 2023!
One weekend until Cloud Next 2023!
Google Cloud Tech
59 #GoogleCloudNext starts tomorrow!
#GoogleCloudNext starts tomorrow!
Google Cloud Tech
60 #GoogleCloudNext will be demand!
#GoogleCloudNext will be demand!
Google Cloud Tech

This video teaches viewers how to get started with Google Cloud Client Libraries by installing the Google Cloud CLI, setting up application default credentials, and making a cloud client library call using Python. It covers the basics of cloud client libraries, including authentication and configuration.

Key Takeaways
  1. Install the Google Cloud CLI
  2. Set up Application Default Credentials using g-cloud auth application-default login
  3. Install the Google Cloud Storage client library using pip
  4. Import the library and instantiate the client
  5. Construct a request and send it to Google Cloud using the list objects method
  6. Handle the response and print the results
💡 Application default credentials are a standard automatic way for your application to find the right permissions to talk to Google Cloud APIs, and can be set up using a single G-Cloud command.

Related Reads

Up next
Welcome to the Next Temperamental Era
Charles Schwab
Watch →