com.google.api.ads.dfp.lib.client
Class DfpSession.Builder

java.lang.Object
  extended by com.google.api.ads.dfp.lib.client.DfpSession.Builder
All Implemented Interfaces:
Builder<DfpSession>
Enclosing class:
DfpSession

public static class DfpSession.Builder
extends Object
implements Builder<DfpSession>

Builder for DfpSession.


Field Summary
 
Fields inherited from interface com.google.api.ads.common.lib.utils.Builder
DEFAULT_CONFIGURATION_FILENAME
 
Constructor Summary
DfpSession.Builder()
          Constructor.
 
Method Summary
 DfpSession build()
          Builds the DfpSession.
 DfpSession.Builder from(org.apache.commons.configuration.Configuration config)
          Reads properties from the provided Configuration object.

Known properties: api.dfp.clientLoginToken api.dfp.applicationName api.dfp.networkCode api.dfp.endpoint Deprecated: api.dfp.environment - e.g.
 DfpSession.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
 DfpSession.Builder fromFile(File path)
          Populates this builder from a properties file from a specified path.
 DfpSession.Builder fromFile(String path)
          Populates this builder from a properties file from a specified path.
 DfpSession.Builder fromFile(URL path)
          Populates this builder from a properties file from a specified path.
 DfpSession.Builder withApplicationName(String applicationName)
          Includes application name (any string of your choice).
 DfpSession.Builder withClientLoginToken(String clientLoginToken)
          Includes hard-coded ClientLogin token that will be used instead of fetching a new one.
 DfpSession.Builder withEndpoint(String endpoint)
          Override the endpoint server.
 DfpSession.Builder withEnvironment(DfpSession.Environment environment)
          Deprecated.  
 DfpSession.Builder withNetworkCode(String networkCode)
          Includes network code.
 DfpSession.Builder withOAuth2Credential(com.google.api.client.auth.oauth2.Credential oAuth2Credential)
          Includes OAuth2 credential to be used for OAuth2 authentication.
 DfpSession.Builder withOAuthParameters(com.google.api.client.auth.oauth.OAuthParameters oAuthParameters)
          Includes OAuth parameters to be used for OAuth authentication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DfpSession.Builder

public DfpSession.Builder()
Constructor.

Method Detail

fromFile

public DfpSession.Builder fromFile()
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
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

Specified by:
fromFile in interface Builder<DfpSession>
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfpSession.Builder fromFile(String path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<DfpSession>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfpSession.Builder fromFile(File path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path.

Specified by:
fromFile in interface Builder<DfpSession>
Parameters:
path - the path to load properties from
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfpSession.Builder fromFile(URL path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<DfpSession>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

from

public DfpSession.Builder from(org.apache.commons.configuration.Configuration config)
Reads properties from the provided Configuration object.

Known properties:

Specified by:
from in interface Builder<DfpSession>
Parameters:
config - the configuration
Returns:
Builder populated from the configuration

withClientLoginToken

public DfpSession.Builder withClientLoginToken(String clientLoginToken)
Includes hard-coded ClientLogin token that will be used instead of fetching a new one.


withOAuthParameters

public DfpSession.Builder withOAuthParameters(com.google.api.client.auth.oauth.OAuthParameters oAuthParameters)
Includes OAuth parameters to be used for OAuth authentication.


withOAuth2Credential

public DfpSession.Builder withOAuth2Credential(com.google.api.client.auth.oauth2.Credential oAuth2Credential)
Includes OAuth2 credential to be used for OAuth2 authentication.


withNetworkCode

public DfpSession.Builder withNetworkCode(String networkCode)
Includes network code. Required for most service calls.


withApplicationName

public DfpSession.Builder withApplicationName(String applicationName)
Includes application name (any string of your choice). Required.


withEnvironment

@Deprecated
public DfpSession.Builder withEnvironment(DfpSession.Environment environment)
Deprecated. 

Includes the specified environment, e.g. DfpSession.Environment.PRODUCTION. Optional and defaults to DfpSession.Environment.PRODUCTION. The environment and endpoint in DFP are currently synonymous. Setting an environment will clear out any endpoint you have previously set.


withEndpoint

public DfpSession.Builder withEndpoint(String endpoint)
Override the endpoint server. Optional and defaults to https://www.google.com/. The environment and endpoint in DFP are currently synonymous. Setting an endpoint will clear out any environment you have previously set.


build

public DfpSession build()
                 throws ValidationException
Builds the DfpSession.

Specified by:
build in interface Builder<DfpSession>
Returns:
the built DfpSession
Throws:
ValidationException - if the DfpSession did not validate


Copyright © 2012. All Rights Reserved.