Class GoogleAdsClient.Builder
- Enclosing class:
- GoogleAdsClient
GoogleAdsClient.
Unlike GoogleAdsClient, builders are not thread safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of the environment variables that can be used to configure aGoogleAdsClient.static enumEnum of keys expected in the "ads.properties". -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default file name for the properties configuration file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns a new instance ofGoogleAdsClientbased on the attributes of this builder.fromProperties(Properties properties) Updates this builder with values set from a properties object.Loads the Google Ads Client configuration file from the default location: "ads.properties".fromPropertiesFile(File propertiesFile) Updates this builder with values set from a properties file.abstract com.google.auth.CredentialsReturns the credentials currently configured.abstract StringReturns the developer token currently configured.abstract StringReturns the endpoint currently configured.abstract LongReturns the linked customer ID currently configured.abstract LongReturns the login customer ID currently configured.abstract Integerabstract booleanGets whether to use the Google Cloud Organization of your Google Cloud project instead of developer token to determine your Google Ads API access level.abstract GoogleAdsClient.BuildersetCredentials(com.google.auth.Credentials credentials) Specifies the OAuth credentials.abstract GoogleAdsClient.BuildersetDeveloperToken(String developerToken) Sets the developer token used to obtain access to the Google Ads API.abstract GoogleAdsClient.BuildersetEndpoint(String endpoint) Optional: Overrides the default endpoint.abstract GoogleAdsClient.BuildersetLinkedCustomerId(Long linkedCustomerId) Required by a small subset of services and use-cases.abstract GoogleAdsClient.BuildersetLoginCustomerId(Long customerId) Required for manager accounts only.abstract GoogleAdsClient.BuildersetMaxInboundMessageBytes(Integer maxInboundMessageSize) voidsetMaxInboundMessageBytes(Properties properties) abstract GoogleAdsClient.BuildersetUseCloudOrgForApiAccess(boolean useCloudOrgForApiAccess) Specifies whether to use the Google Cloud Organization of your Google Cloud project instead of developer token to determine your Google Ads API access level.
-
Field Details
-
DEFAULT_PROPERTIES_CONFIG_FILE_NAME
The default file name for the properties configuration file. This does not include a path.- See Also:
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
getCredentials
public abstract com.google.auth.Credentials getCredentials()Returns the credentials currently configured. -
setCredentials
Specifies the OAuth credentials. UseUserCredentials.newBuilder()orServiceAccountCredentials.newBuilder()to build this object, or configure your credentials using a properties file or environment variables.This field is marked nullable to facilitate testing of the client library. In practice, all requests to Google Ads API must be authenticated.
-
enableApplicationDefaultCredentials
-
getDeveloperToken
Returns the developer token currently configured. -
setDeveloperToken
Sets the developer token used to obtain access to the Google Ads API. -
isUseCloudOrgForApiAccess
public abstract boolean isUseCloudOrgForApiAccess()Gets whether to use the Google Cloud Organization of your Google Cloud project instead of developer token to determine your Google Ads API access level. -
setUseCloudOrgForApiAccess
Specifies whether to use the Google Cloud Organization of your Google Cloud project instead of developer token to determine your Google Ads API access level. -
getLoginCustomerId
Returns the login customer ID currently configured. -
getLinkedCustomerId
Returns the linked customer ID currently configured. -
setLinkedCustomerId
Required by a small subset of services and use-cases. Only required if explicitly instructed in the service documentation. -
setLoginCustomerId
Required for manager accounts only. When authenticating as a Google Ads manager account, specifies the customer ID of the authenticating manager account.If your OAuth credentials are for a user with access to multiple manager accounts you must create a separate GoogleAdsClient instance for each manager account. Use
toBuilder().setLoginCustomerId(...).build()to change the loginCustomerId. -
getMaxInboundMessageBytes
-
setMaxInboundMessageBytes
-
setMaxInboundMessageBytes
-
getEndpoint
Returns the endpoint currently configured. -
setEndpoint
Optional: Overrides the default endpoint. For the default value seeGoogleAdsClient.DEFAULT_ENDPOINT. -
fromPropertiesFile
Loads the Google Ads Client configuration file from the default location: "ads.properties".- Throws:
FileNotFoundException- if the file does not exist.IOException- if the file exists, but a failure occurs when trying to load properties from the file.
-
fromPropertiesFile
Updates this builder with values set from a properties file.The format is similar to the format specified in the AdWords API's client library for Java, except the property keys have changed. See
GoogleAdsClient.Builder.ConfigPropertyKeyfor the list of expected keys.- Throws:
FileNotFoundException- if the specified file does not exist.IOException- if the file exists, but a failure occurs when trying to load properties from the file.
-
fromProperties
Updates this builder with values set from a properties object.The format is similar to the format specified in the AdWords API's client library for Java, except the property keys have changed. See
GoogleAdsClient.Builder.ConfigPropertyKeyfor the list of expected keys.- Throws:
IllegalArgumentException- if a failure occurs when trying to load properties from the file.
-
fromEnvironment
-
build
Returns a new instance ofGoogleAdsClientbased on the attributes of this builder.
-