From the course: Google Cloud Professional Cloud Architect Cert Prep (2025)

Getting started with the Google Cloud CLI SDK

- [Instructor] All right, let's get into another application of the Google Cloud, which is using the SDK. Let's go ahead and activate the clouds shell here and also open up the editor. Now the editor has some additional resources for using the SDK that are worth pointing out. So if we go into here, you can see I have an app engine app sitting here, but I also could go over to this section, which is called Cloud Code and toggle down to where it says Cloud APIs. If we go to Cloud APIs, it has the ability here to give me a search window and I can search for certain things. In this case, if I want to look at the cloud natural language, API and I can verify that I sign in. It also tells me how to configure the authentication for a runtime environment. And then also it tells us in different languages how to install a library. So in this case, if I wanted to install the client library in go, I could do go get. Now, in terms of the code sample as well, it gives us several samples here. And if we look at this, you can see they've got Java, Node, Python, Go. So for example, if I wanted to analyze the entities in a string, here's the go command that I could just paste into, let's say a microservice on app engine or cloud functions. And I'd be good to go. Now what I'm going to do though is use an even more straightforward interface to explore the API, which is the terminal. So if we go over to the terminal here, one of the ways that we could interact with that natural language API is to use something called GCloud ML language. So let's type in GCloud ML language, and if we do the help command, it will show us that this is a very sophisticated tool that allows us to interact with the natural language API, but from ACLI. And you can see some of the commands you could do, you could analyze entities, you can analyze the entity sentiment, you can analyze the sentiment, you can look at the syntax and you could even classify input text into different documents. And you can see there's also variance as well, like an alpha and a beta. So let's go ahead and try out first here, analyze entities. So I'm going to go ahead and type in ML language, and I'm going to go ahead and type in analyze entities. And again, let's go ahead and use the help menu to make sure that I put in the right text. It says aha content. So let's go ahead and do that next. And we'll do that and let's put a word in or a phrase that seems like it would be good to extract entities. So if I said the Lakers some years are a good team, there we go. If we go through and we analyze this, it was able to extract out that the user is probably talking about the Los Angeles Lakers, and they were able to identify that it was a type of organization. It was able to grab the metadata that shows the Wikipedia page, and also it was able to tell us that it was a team as well. So we get a bunch of interesting metadata automatically just by calling that API, I don't have to do model training, I don't have to do anything. I can actually just pull that JSON payload into Go and parse it and do whatever it is that I need to do with it. Now we can also do other things as well, so we could also analyze sentiment. So let's go ahead and do that next. If we go over here and we scroll up and we say instead analyze sentiment, we'll do the same thing. We'll just go through help here and let's take a look at what we've got. So we've got the, the name here, which is use Google Cloud natural language API to identify sentiment in text. That looks good. And again, what's nice about this is that it gives us some instructions on how to work. Now, we could even give it a file that might be kind of fun. Let's go ahead and try that out. So I'm going to do a nice trick that I've seen many people do that I'm going to borrow, which is, I'm going to go ahead and put a hash right here, and this will save that command so I can come back to it. Now I want to create a document. Now, fortunately, because I'm inside of this directory, Go NLP, I can just create something here and then edit it with the editor. So it's going to, and say, touch my data dot txt. You can see here it is right here. So let's do something that is maybe like a review of a French wine. So, you know, this particular wine is very dry and from a small village in France, and I enjoyed it. Okay, so we've got a review maybe for some wine. And then all I need to do here is go again up to this command and just tweak this. So if I do control A, it gets me to the beginning, and if I do control E, it gets me to the end and I just need to make it match what this says, which is my data. There we go. And now, if I run this, it reads in the file and it says that the sentiment here is a 0.7. So it's giving us basically a positive sentiment about, you know, this particular review. If we want to call it a review, and again, I could integrate that into my application. So in many cases, using a command line interface to first explore the documentation is I think a good practice for API developers. And again, if you go to the documentation here, let's go ahead and take a look at that. You can see here that they give you a walkthrough of exactly what it is you need to do. And you can use this as a shortcut to really enhance your productivity when you're building with the SDK.

Contents