public static class DfaSession.Builder extends Object implements Builder<DfaSession>
Implementation is not thread-safe.
DEFAULT_CONFIGURATION_FILENAME
Constructor and Description |
---|
DfaSession.Builder()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
DfaSession |
build()
Builds the
DfaSession . |
DfaSession.Builder |
from(org.apache.commons.configuration.Configuration config)
Reads properties from the provided
Configuration object.Known properties: api.dfa.username api.dfa.password api.dfa.applicationName api.dfa.token api.dfa.environment, e.g. |
DfaSession.Builder |
fromFile()
Loads credentials from "ads.properties" file in one of the following
locations according to the following order: in the current directory, in
the user home directory, in the classpath
|
DfaSession.Builder |
fromFile(File path)
Populates this builder from a properties file from a specified path.
|
DfaSession.Builder |
fromFile(String path)
Populates this builder from a properties file from a specified path.
|
DfaSession.Builder |
fromFile(URL path)
Populates this builder from a properties file from a specified path.
|
DfaSession.Builder |
withApplicationName(String applicationName)
Includes application name.
|
DfaSession.Builder |
withEndpoint(String endpoint)
Override the endpoint server.
|
DfaSession.Builder |
withEnvironment(DfaSession.Environment environment)
Includes the specified environment, e.g.
|
DfaSession.Builder |
withOAuth2Credential(com.google.api.client.auth.oauth2.Credential credential)
Includes an OAuth2 credential.
|
DfaSession.Builder |
withUsernameAndOAuth2Credential(String username,
com.google.api.client.auth.oauth2.Credential credential)
Includes a username with an OAuth2 credential used for generating DFA
tokens.
|
DfaSession.Builder |
withUsernameAndPassword(String username,
String password)
Deprecated.
It is encouraged that you switch to OAuth2 at your earliest
convenience. Please see the OfflineCredentials utility for
generating offline credentials easily.
|
DfaSession.Builder |
withUsernameAndToken(String username,
String token)
Includes a username with a hard-coded token to be used instead of
fetching a new one.
|
public DfaSession.Builder fromFile() throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<DfaSession>
com.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public DfaSession.Builder fromFile(String path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<DfaSession>
path
- the path to try first as a resource, then as a filecom.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public DfaSession.Builder fromFile(File path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<DfaSession>
path
- the path to load properties fromcom.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public DfaSession.Builder fromFile(URL path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<DfaSession>
path
- the path to try first as a resource, then as a filecom.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public DfaSession.Builder from(org.apache.commons.configuration.Configuration config)
Configuration
object.from
in interface Builder<DfaSession>
config
- public DfaSession.Builder withEnvironment(DfaSession.Environment environment)
DfaSession.Environment.TEST
The environment and endpoint in DFA are currently synonymous. Setting an
environment will clear out any endpoint you have previously set.public DfaSession.Builder withEndpoint(String endpoint)
@Deprecated public DfaSession.Builder withUsernameAndPassword(String username, String password)
public DfaSession.Builder withUsernameAndToken(String username, String token)
public DfaSession.Builder withUsernameAndOAuth2Credential(String username, com.google.api.client.auth.oauth2.Credential credential)
public DfaSession.Builder withOAuth2Credential(com.google.api.client.auth.oauth2.Credential credential)
fromFile()
. Otherwise, you should use
withUsernameAndOAuth2Credential(String, Credential)
public DfaSession.Builder withApplicationName(String applicationName)
public DfaSession build() throws ValidationException
DfaSession
.build
in interface Builder<DfaSession>
DfaSession
ValidationException
- if the DfaSession
did not validateCopyright © 2015. All Rights Reserved.