Search in sources :

Example 71 with ApiException

use of com.recurly.v3.ApiException in project googleads-java-lib by googleads.

the class GetAllCreativeTemplates method main.

public static void main(String[] args) {
    AdManagerSession session;
    try {
        // Generate a refreshable OAuth2 credential.
        Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();
        // Construct a AdManagerSession.
        session = new AdManagerSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
    } catch (ConfigurationLoadException cle) {
        System.err.printf("Failed to load configuration from the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, cle);
        return;
    } catch (ValidationException ve) {
        System.err.printf("Invalid configuration in the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, ve);
        return;
    } catch (OAuthException oe) {
        System.err.printf("Failed to create OAuth credentials. Check OAuth settings in the %s file. " + "Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, oe);
        return;
    }
    AdManagerServices adManagerServices = new AdManagerServices();
    try {
        runExample(adManagerServices, session);
    } catch (ApiException apiException) {
        // ApiException is the base class for most exceptions thrown by an API request. Instances
        // of this exception have a message and a collection of ApiErrors that indicate the
        // type and underlying cause of the exception. Every exception object in the admanager.axis
        // packages will return a meaningful value from toString
        // 
        // ApiException extends RemoteException, so this catch block must appear before the
        // catch block for RemoteException.
        System.err.println("Request failed due to ApiException. Underlying ApiErrors:");
        if (apiException.getErrors() != null) {
            int i = 0;
            for (ApiError apiError : apiException.getErrors()) {
                System.err.printf("  Error %d: %s%n", i++, apiError);
            }
        }
    } catch (RemoteException re) {
        System.err.printf("Request failed unexpectedly due to RemoteException: %s%n", re);
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) ApiError(com.google.api.ads.admanager.axis.v202108.ApiError) RemoteException(java.rmi.RemoteException) AdManagerSession(com.google.api.ads.admanager.lib.client.AdManagerSession) AdManagerServices(com.google.api.ads.admanager.axis.factory.AdManagerServices) ApiException(com.google.api.ads.admanager.axis.v202108.ApiException)

Example 72 with ApiException

use of com.recurly.v3.ApiException in project googleads-java-lib by googleads.

the class CreateCreativeWrappers method main.

public static void main(String[] args) {
    AdManagerSession session;
    try {
        // Generate a refreshable OAuth2 credential.
        Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();
        // Construct a AdManagerSession.
        session = new AdManagerSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
    } catch (ConfigurationLoadException cle) {
        System.err.printf("Failed to load configuration from the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, cle);
        return;
    } catch (ValidationException ve) {
        System.err.printf("Invalid configuration in the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, ve);
        return;
    } catch (OAuthException oe) {
        System.err.printf("Failed to create OAuth credentials. Check OAuth settings in the %s file. " + "Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, oe);
        return;
    }
    AdManagerServices adManagerServices = new AdManagerServices();
    CreateCreativeWrappersParams params = new CreateCreativeWrappersParams();
    if (!params.parseArguments(args)) {
        // Either pass the required parameters for this example on the command line, or insert them
        // into the code here. See the parameter class definition above for descriptions.
        params.labelId = Long.parseLong("INSERT_LABEL_ID_HERE");
    }
    try {
        runExample(adManagerServices, session, params.labelId);
    } catch (ApiException apiException) {
        // ApiException is the base class for most exceptions thrown by an API request. Instances
        // of this exception have a message and a collection of ApiErrors that indicate the
        // type and underlying cause of the exception. Every exception object in the admanager.axis
        // packages will return a meaningful value from toString
        // 
        // ApiException extends RemoteException, so this catch block must appear before the
        // catch block for RemoteException.
        System.err.println("Request failed due to ApiException. Underlying ApiErrors:");
        if (apiException.getErrors() != null) {
            int i = 0;
            for (ApiError apiError : apiException.getErrors()) {
                System.err.printf("  Error %d: %s%n", i++, apiError);
            }
        }
    } catch (RemoteException re) {
        System.err.printf("Request failed unexpectedly due to RemoteException: %s%n", re);
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) ApiError(com.google.api.ads.admanager.axis.v202108.ApiError) RemoteException(java.rmi.RemoteException) AdManagerSession(com.google.api.ads.admanager.lib.client.AdManagerSession) AdManagerServices(com.google.api.ads.admanager.axis.factory.AdManagerServices) ApiException(com.google.api.ads.admanager.axis.v202108.ApiException)

Example 73 with ApiException

use of com.recurly.v3.ApiException in project googleads-java-lib by googleads.

the class UpdateCreativeWrappers method main.

public static void main(String[] args) {
    AdManagerSession session;
    try {
        // Generate a refreshable OAuth2 credential.
        Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();
        // Construct a AdManagerSession.
        session = new AdManagerSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
    } catch (ConfigurationLoadException cle) {
        System.err.printf("Failed to load configuration from the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, cle);
        return;
    } catch (ValidationException ve) {
        System.err.printf("Invalid configuration in the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, ve);
        return;
    } catch (OAuthException oe) {
        System.err.printf("Failed to create OAuth credentials. Check OAuth settings in the %s file. " + "Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, oe);
        return;
    }
    AdManagerServices adManagerServices = new AdManagerServices();
    UpdateCreativeWrappersParams params = new UpdateCreativeWrappersParams();
    if (!params.parseArguments(args)) {
        // Either pass the required parameters for this example on the command line, or insert them
        // into the code here. See the parameter class definition above for descriptions.
        params.creativeWrapperId = Long.parseLong("INSERT_CREATIVE_WRAPPER_ID_HERE");
    }
    try {
        runExample(adManagerServices, session, params.creativeWrapperId);
    } catch (ApiException apiException) {
        // ApiException is the base class for most exceptions thrown by an API request. Instances
        // of this exception have a message and a collection of ApiErrors that indicate the
        // type and underlying cause of the exception. Every exception object in the admanager.axis
        // packages will return a meaningful value from toString
        // 
        // ApiException extends RemoteException, so this catch block must appear before the
        // catch block for RemoteException.
        System.err.println("Request failed due to ApiException. Underlying ApiErrors:");
        if (apiException.getErrors() != null) {
            int i = 0;
            for (ApiError apiError : apiException.getErrors()) {
                System.err.printf("  Error %d: %s%n", i++, apiError);
            }
        }
    } catch (RemoteException re) {
        System.err.printf("Request failed unexpectedly due to RemoteException: %s%n", re);
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) ApiError(com.google.api.ads.admanager.axis.v202108.ApiError) RemoteException(java.rmi.RemoteException) AdManagerSession(com.google.api.ads.admanager.lib.client.AdManagerSession) AdManagerServices(com.google.api.ads.admanager.axis.factory.AdManagerServices) ApiException(com.google.api.ads.admanager.axis.v202108.ApiException)

Example 74 with ApiException

use of com.recurly.v3.ApiException in project googleads-java-lib by googleads.

the class GetCustomFieldsForLineItems method main.

public static void main(String[] args) {
    AdManagerSession session;
    try {
        // Generate a refreshable OAuth2 credential.
        Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();
        // Construct a AdManagerSession.
        session = new AdManagerSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
    } catch (ConfigurationLoadException cle) {
        System.err.printf("Failed to load configuration from the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, cle);
        return;
    } catch (ValidationException ve) {
        System.err.printf("Invalid configuration in the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, ve);
        return;
    } catch (OAuthException oe) {
        System.err.printf("Failed to create OAuth credentials. Check OAuth settings in the %s file. " + "Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, oe);
        return;
    }
    AdManagerServices adManagerServices = new AdManagerServices();
    try {
        runExample(adManagerServices, session);
    } catch (ApiException apiException) {
        // ApiException is the base class for most exceptions thrown by an API request. Instances
        // of this exception have a message and a collection of ApiErrors that indicate the
        // type and underlying cause of the exception. Every exception object in the admanager.axis
        // packages will return a meaningful value from toString
        // 
        // ApiException extends RemoteException, so this catch block must appear before the
        // catch block for RemoteException.
        System.err.println("Request failed due to ApiException. Underlying ApiErrors:");
        if (apiException.getErrors() != null) {
            int i = 0;
            for (ApiError apiError : apiException.getErrors()) {
                System.err.printf("  Error %d: %s%n", i++, apiError);
            }
        }
    } catch (RemoteException re) {
        System.err.printf("Request failed unexpectedly due to RemoteException: %s%n", re);
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) ApiError(com.google.api.ads.admanager.axis.v202108.ApiError) RemoteException(java.rmi.RemoteException) AdManagerSession(com.google.api.ads.admanager.lib.client.AdManagerSession) AdManagerServices(com.google.api.ads.admanager.axis.factory.AdManagerServices) ApiException(com.google.api.ads.admanager.axis.v202108.ApiException)

Example 75 with ApiException

use of com.recurly.v3.ApiException in project googleads-java-lib by googleads.

the class UpdateCustomFields method main.

public static void main(String[] args) {
    AdManagerSession session;
    try {
        // Generate a refreshable OAuth2 credential.
        Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();
        // Construct a AdManagerSession.
        session = new AdManagerSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
    } catch (ConfigurationLoadException cle) {
        System.err.printf("Failed to load configuration from the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, cle);
        return;
    } catch (ValidationException ve) {
        System.err.printf("Invalid configuration in the %s file. Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, ve);
        return;
    } catch (OAuthException oe) {
        System.err.printf("Failed to create OAuth credentials. Check OAuth settings in the %s file. " + "Exception: %s%n", DEFAULT_CONFIGURATION_FILENAME, oe);
        return;
    }
    AdManagerServices adManagerServices = new AdManagerServices();
    UpdateCustomFieldsParams params = new UpdateCustomFieldsParams();
    if (!params.parseArguments(args)) {
        // Either pass the required parameters for this example on the command line, or insert them
        // into the code here. See the parameter class definition above for descriptions.
        params.customFieldId = Long.parseLong("INSERT_CUSTOM_FIELD_ID_HERE");
    }
    try {
        runExample(adManagerServices, session, params.customFieldId);
    } catch (ApiException apiException) {
        // ApiException is the base class for most exceptions thrown by an API request. Instances
        // of this exception have a message and a collection of ApiErrors that indicate the
        // type and underlying cause of the exception. Every exception object in the admanager.axis
        // packages will return a meaningful value from toString
        // 
        // ApiException extends RemoteException, so this catch block must appear before the
        // catch block for RemoteException.
        System.err.println("Request failed due to ApiException. Underlying ApiErrors:");
        if (apiException.getErrors() != null) {
            int i = 0;
            for (ApiError apiError : apiException.getErrors()) {
                System.err.printf("  Error %d: %s%n", i++, apiError);
            }
        }
    } catch (RemoteException re) {
        System.err.printf("Request failed unexpectedly due to RemoteException: %s%n", re);
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) ApiError(com.google.api.ads.admanager.axis.v202108.ApiError) RemoteException(java.rmi.RemoteException) AdManagerSession(com.google.api.ads.admanager.lib.client.AdManagerSession) AdManagerServices(com.google.api.ads.admanager.axis.factory.AdManagerServices) ApiException(com.google.api.ads.admanager.axis.v202108.ApiException)

Aggregations

ConfigurationLoadException (com.google.api.ads.common.lib.conf.ConfigurationLoadException)653 OAuthException (com.google.api.ads.common.lib.exception.OAuthException)653 ValidationException (com.google.api.ads.common.lib.exception.ValidationException)653 RemoteException (java.rmi.RemoteException)653 AdManagerServices (com.google.api.ads.admanager.axis.factory.AdManagerServices)649 AdManagerSession (com.google.api.ads.admanager.lib.client.AdManagerSession)649 Credential (com.google.api.client.auth.oauth2.Credential)649 ApiException (com.google.api.ads.admanager.axis.v202202.ApiException)164 ApiException (com.google.api.ads.admanager.axis.v202108.ApiException)163 ApiException (com.google.api.ads.admanager.axis.v202111.ApiException)163 ApiError (com.google.api.ads.admanager.axis.v202202.ApiError)163 ApiException (com.google.api.ads.admanager.axis.v202205.ApiException)163 ApiError (com.google.api.ads.admanager.axis.v202108.ApiError)162 ApiError (com.google.api.ads.admanager.axis.v202111.ApiError)162 ApiError (com.google.api.ads.admanager.axis.v202205.ApiError)162 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)117 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)117 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)117 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)117 IOException (java.io.IOException)80