Fetching references to all the various proto classes required to use the API in Python can be verbose and requires you to have an intrinsic understanding of the API or frequently context-switch to reference the protos or documentation.
These two getter methods allow you to retrieve any service or type object in the
API. Services are defined in code under the version path
google/ads/google_ads/v*/services/) and all Types are exported via the
file. In general use
get_service to retrieve a Service object and
for any other object.
You don't have to use this utility, and could instantiate a campaign for example like this:
# note this example uses v1 but this version could change from google.ads.google_ads.v1.proto.resources.campaign_pb2 import Campaign campaign = Campaign()
get_type client method allows you to shortcut this if you prefer:
campaign = client.get_type('Campaign')
When fetching a resource, service, or operation, an instance of that entity will be returned to you. When fetching an enumeration, a reference to the class will be returned without instantiation.
For enumerations use the
get_type method and access the object's enumerable
campaign.status = client.get_type('CampaignStatusEnum').PAUSED
You should always use the
client.get_service method for fetching Services
because there is extra logic built into this method to pass along your developer
token and authentication details when making requests, which you would have to
handle manually if you bypassed it.