Working with companies – Cloud Talent Solution
Articles,  Blog

Working with companies – Cloud Talent Solution


MARK MIRCHANDANI: You can’t
have jobs without companies. In our last video,
we set everything to start using the Google Cloud
Talent Solution Job Search API and started by
creating a company. Now, let’s dive deeper
into creating and updating companies, as well as
checking out their properties. [UPBEAT MUSIC] Here’s the Python code we
used to create the company. As you can see,
it’s pretty short. But let’s quickly go
through what we’re doing, since a lot of it will
apply to the API as a whole. We’ll be using version 3 of
the API for all of our code. Don’t forget to check out
the documentation for any of the latest updates. Everything above this line is
setting up the client library. But we’re also setting
a global variable with the format
of projects slash and then the ID of your project. This is important, because all
the companies you deal with, and then later, jobs,
will have this project as the parent they belong to. It’s also easy to
see this when you look at the name of a
created company, which we’ll look at when we run the code. Inside our function, we’ll set
up the company to be created, which gets passed in, and
make the actual request. The client library
makes it clear that we’re creating a company
with projects.companies.create. And then we pass
that project ID along with our company properties. This code also prints out the
resulting company details. After some error
checking in our function, we’ll go back and set
the required fields and call create_company. Right now, we’re only using
two fields, display name and external ID. These are the only required
fields for creating a company. The display name is exactly
what it sounds like. It’s the name that
displays for the company. External ID is your
identifier to help you track the company with
whatever your job system has. You can put whatever reasonable
string makes sense here or just put the same thing
as a display name, if you don’t have a
current system identifier, or if you’re a staffing
agency and don’t want to reveal the hiring
company’s information. With just these, we’ll
create a company. So let’s run the code. Here’s a printout of the
details of the company. We can see the
fields we passed in as well as the name
of the company, which is generated on a
create and serves as a unique identifier for this
company in the job search API. We’ll use this anytime
we need to reference the company in the API,
such as updating it or when we create jobs. You can see that it follows
the same format from before– projects, slash, your project
ID, slash, companies, slash, and then the unique
company name. Great, we can now
create companies and use their unique
names as identifiers. Now, let’s go back
and take a quick look at that list_companies code
from the previous video. Thanks to the client
libraries, this code looks almost identical
to the create code. Inside of our function,
we’ll do companies.list instead of
companies.create, but still pass in the same project ID. Once we make the call,
we’ll just quickly check if there are
any companies returned and list their display names
along with their unique names. With this short
snippet, we can quickly see what companies we’ve
set up with the API. Let’s run the code
and see some output. Here’s two companies
I made earlier. Pretty straightforward,
but what happens when you need to update a company? We’ll do that by patching it. Here’s our update code. Hopefully the structure
looks pretty familiar. We’ll be calling patch
to update the company. And we’ll pass along the
unique name, as well as a full company object with all
the fields we want to update. The project ID isn’t needed
here, because that’s already included in the company name. Here’s where we set
the name and the fields in the updated company object– in this case, a
new display name. It’s important to note
that you can’t change the external ID or
the automatically generated name for any company. When updating a company, you
should include every property in the passed in
object, even those that aren’t going to be updated. Otherwise, any
missing properties would get removed
from the company. To avoid any confusion
there, we actually recommend providing
an update mask where you specify only the
fields you want to update. This is a string
that you can pass in with a comma separated list of
fields that you want to update. Here’s some modified code
that shows setting an update mask to update the
display name along with the size of the company. Size is an enum that we’ll
talk about in just a second. When we make this API
request, only the fields explicitly listed in the update
mask will actually be updated. And other fields will
just be unchanged. Now, let’s look at size and
other properties of a company. The more information
a company has, the better the experience
will be for job seekers. As we just saw, size
is an enum that you can set to represent
the amount of people that work at the company. There’s a few options here. And if you’re using the
Python Client libraries, you can just pass
in the string value. Here’s some other
properties you’ll probably want to include. HeadquartersAddress, which
is the string address of the company’s headquarters. The API will
geolocate the address and try to fill in more specific
details in a read-only property named derivedinfo. Jobs will have
their own addresses. HiringAgency is a
Boolean if this company post jobs for other employers. Eeotext is a string that lets
you include an equal employment opportunity legal disclaimer
for all of the jobs associated with this company. WebsiteUri is a string
for the company’s website. And careerSiteUri is a string
specifically for the company’s career site. ImageUri is a string
for the company’s logo. You can also delete companies
if you don’t need them anymore. The delete operation
is pretty simple, and you just pass along the
company’s name to delete it, exactly as you might expect. It’s important to note
that a delete will fail if the company has any
open jobs associated with it. Now that you can work
with companies, let’s start talking about jobs. Then again, we’ve
covered a lot today. So let’s talk about
jobs in the next video. Check out the documentation if
you’re eager to get started. And let us know if you
have any questions. Thanks for watching. And remember, when
looking for talent, it’s OK to keep your
head in the Cloud. [SMOOTH MUSIC]

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *