Skip to content

Commit 8c1aa47

Browse files
authored
Changes for release v5.0. (#330)
1 parent 8423dfc commit 8c1aa47

8,217 files changed

Lines changed: 3410935 additions & 4093 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
9.0.0 - 2020-09-01
2+
------------------
3+
- Added support and examples for Google Ads API v5_0.
4+
- Switched internal catalog implementation default to use annotation processor.
5+
16
8.0.0 - 2020-07-31
27
------------------
38
- Removed v1 from the library.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This project hosts the Java client library for the Google Ads API.
1818
<dependency>
1919
<groupId>com.google.api-ads</groupId>
2020
<artifactId>google-ads</artifactId>
21-
<version>8.0.0</version>
21+
<version>9.0.0</version>
2222
</dependency>
2323

2424
## Documentation

google-ads-examples/src/main/java/com/google/ads/googleads/examples/accountmanagement/ApproveMerchantCenterLink.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
import com.google.ads.googleads.examples.utils.CodeSampleParams;
2020
import com.google.ads.googleads.lib.GoogleAdsClient;
2121
import com.google.ads.googleads.lib.utils.FieldMasks;
22-
import com.google.ads.googleads.v4.enums.MerchantCenterLinkStatusEnum.MerchantCenterLinkStatus;
23-
import com.google.ads.googleads.v4.errors.GoogleAdsError;
24-
import com.google.ads.googleads.v4.errors.GoogleAdsException;
25-
import com.google.ads.googleads.v4.resources.MerchantCenterLink;
26-
import com.google.ads.googleads.v4.services.ListMerchantCenterLinksRequest;
27-
import com.google.ads.googleads.v4.services.ListMerchantCenterLinksResponse;
28-
import com.google.ads.googleads.v4.services.MerchantCenterLinkOperation;
29-
import com.google.ads.googleads.v4.services.MerchantCenterLinkServiceClient;
30-
import com.google.ads.googleads.v4.services.MutateMerchantCenterLinkResponse;
31-
import com.google.ads.googleads.v4.services.MutateMerchantCenterLinkResult;
22+
import com.google.ads.googleads.v5.enums.MerchantCenterLinkStatusEnum.MerchantCenterLinkStatus;
23+
import com.google.ads.googleads.v5.errors.GoogleAdsError;
24+
import com.google.ads.googleads.v5.errors.GoogleAdsException;
25+
import com.google.ads.googleads.v5.resources.MerchantCenterLink;
26+
import com.google.ads.googleads.v5.services.ListMerchantCenterLinksRequest;
27+
import com.google.ads.googleads.v5.services.ListMerchantCenterLinksResponse;
28+
import com.google.ads.googleads.v5.services.MerchantCenterLinkOperation;
29+
import com.google.ads.googleads.v5.services.MerchantCenterLinkServiceClient;
30+
import com.google.ads.googleads.v5.services.MutateMerchantCenterLinkResponse;
31+
import com.google.ads.googleads.v5.services.MutateMerchantCenterLinkResult;
3232
import java.io.FileNotFoundException;
3333
import java.io.IOException;
3434

@@ -61,16 +61,16 @@ public static void main(String[] args) {
6161
params.merchantCenterAccountId = Long.parseLong("INSERT_MERCHANT_CENTER_ACCOUNT_ID_HERE");
6262
}
6363

64-
GoogleAdsClient googleAdsClient;
64+
GoogleAdsClient googleAdsClient = null;
6565
try {
6666
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
6767
} catch (FileNotFoundException fnfe) {
6868
System.err.printf(
6969
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
70-
return;
70+
System.exit(1);
7171
} catch (IOException ioe) {
7272
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
73-
return;
73+
System.exit(1);
7474
}
7575

7676
try {
@@ -88,6 +88,7 @@ public static void main(String[] args) {
8888
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
8989
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
9090
}
91+
System.exit(1);
9192
}
9293
}
9394

@@ -124,7 +125,7 @@ private void runExample(
124125

125126
// Checks if there is a link for the Merchant Center account we are looking for, then only
126127
// approves the link if it is in a 'PENDING' state.
127-
if (merchantCenterAccountId == merchantCenterLink.getId().getValue()
128+
if (merchantCenterAccountId == merchantCenterLink.getId()
128129
&& merchantCenterLink.getStatus() == MerchantCenterLinkStatus.PENDING) {
129130
// Updates the status of Merchant Center link to 'ENABLED' to approve the link.
130131
updateMerchantCenterLinkStatus(

google-ads-examples/src/main/java/com/google/ads/googleads/examples/accountmanagement/CreateCustomer.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
import com.google.ads.googleads.examples.utils.ArgumentNames;
1919
import com.google.ads.googleads.examples.utils.CodeSampleParams;
2020
import com.google.ads.googleads.lib.GoogleAdsClient;
21-
import com.google.ads.googleads.v4.errors.GoogleAdsError;
22-
import com.google.ads.googleads.v4.errors.GoogleAdsException;
23-
import com.google.ads.googleads.v4.resources.Customer;
24-
import com.google.ads.googleads.v4.services.CreateCustomerClientResponse;
25-
import com.google.ads.googleads.v4.services.CustomerServiceClient;
26-
import com.google.protobuf.BoolValue;
27-
import com.google.protobuf.StringValue;
21+
import com.google.ads.googleads.v5.errors.GoogleAdsError;
22+
import com.google.ads.googleads.v5.errors.GoogleAdsException;
23+
import com.google.ads.googleads.v5.resources.Customer;
24+
import com.google.ads.googleads.v5.services.CreateCustomerClientResponse;
25+
import com.google.ads.googleads.v5.services.CustomerServiceClient;
2826
import java.io.FileNotFoundException;
2927
import java.io.IOException;
3028
import java.time.ZonedDateTime;
@@ -54,16 +52,16 @@ public static void main(String[] args) {
5452
params.managerAccountId = Long.valueOf("INSERT_MANAGER_ID_HERE");
5553
}
5654

57-
GoogleAdsClient googleAdsClient;
55+
GoogleAdsClient googleAdsClient = null;
5856
try {
5957
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
6058
} catch (FileNotFoundException fnfe) {
6159
System.err.printf(
6260
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
63-
return;
61+
System.exit(1);
6462
} catch (IOException ioe) {
6563
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
66-
return;
64+
System.exit(1);
6765
}
6866

6967
try {
@@ -80,6 +78,7 @@ public static void main(String[] args) {
8078
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
8179
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
8280
}
81+
System.exit(1);
8382
}
8483
}
8584

@@ -90,15 +89,13 @@ private void runExample(GoogleAdsClient googleAdsClient, Long managerId) {
9089
// Initializes a Customer object to be created.
9190
Customer customer =
9291
Customer.newBuilder()
93-
.setDescriptiveName(
94-
StringValue.of("Account created with CustomerService on '" + dateTime + "'"))
95-
.setCurrencyCode(StringValue.of("USD"))
96-
.setTimeZone(StringValue.of("America/New_York"))
92+
.setDescriptiveName("Account created with CustomerService on '" + dateTime + "'")
93+
.setCurrencyCode("USD")
94+
.setTimeZone("America/New_York")
9795
// Optional: Sets additional attributes of the customer.
98-
.setTrackingUrlTemplate(StringValue.of("{lpurl}?device={device}"))
99-
.setFinalUrlSuffix(
100-
StringValue.of("keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}"))
101-
.setHasPartnersBadge(BoolValue.of(false))
96+
.setTrackingUrlTemplate("{lpurl}?device={device}")
97+
.setFinalUrlSuffix("keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}")
98+
.setHasPartnersBadge(false)
10299
.build();
103100

104101
// Sends the request to create the customer.

google-ads-examples/src/main/java/com/google/ads/googleads/examples/accountmanagement/GetAccountChanges.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
import com.google.ads.googleads.examples.utils.ArgumentNames;
1919
import com.google.ads.googleads.examples.utils.CodeSampleParams;
2020
import com.google.ads.googleads.lib.GoogleAdsClient;
21-
import com.google.ads.googleads.v4.errors.GoogleAdsError;
22-
import com.google.ads.googleads.v4.errors.GoogleAdsException;
23-
import com.google.ads.googleads.v4.resources.ChangeStatus;
24-
import com.google.ads.googleads.v4.services.GoogleAdsRow;
25-
import com.google.ads.googleads.v4.services.GoogleAdsServiceClient;
26-
import com.google.ads.googleads.v4.services.GoogleAdsServiceClient.SearchPagedResponse;
21+
import com.google.ads.googleads.v5.errors.GoogleAdsError;
22+
import com.google.ads.googleads.v5.errors.GoogleAdsException;
23+
import com.google.ads.googleads.v5.resources.ChangeStatus;
24+
import com.google.ads.googleads.v5.services.GoogleAdsRow;
25+
import com.google.ads.googleads.v5.services.GoogleAdsServiceClient;
26+
import com.google.ads.googleads.v5.services.GoogleAdsServiceClient.SearchPagedResponse;
2727
import java.io.FileNotFoundException;
2828
import java.io.IOException;
2929
import java.util.Optional;
@@ -46,16 +46,16 @@ public static void main(String[] args) {
4646
params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE");
4747
}
4848

49-
GoogleAdsClient googleAdsClient;
49+
GoogleAdsClient googleAdsClient = null;
5050
try {
5151
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
5252
} catch (FileNotFoundException fnfe) {
5353
System.err.printf(
5454
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
55-
return;
55+
System.exit(1);
5656
} catch (IOException ioe) {
5757
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
58-
return;
58+
System.exit(1);
5959
}
6060

6161
try {
@@ -72,6 +72,7 @@ public static void main(String[] args) {
7272
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
7373
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
7474
}
75+
System.exit(1);
7576
}
7677
}
7778

@@ -135,7 +136,7 @@ private static Optional<String> getResourceNameForResourceType(ChangeStatus chan
135136
// See https://developers.google.com/google-ads/api/docs/change-status for a description.
136137
switch (changeStatus.getResourceType()) {
137138
case AD_GROUP:
138-
resourceName = changeStatus.getAdGroup().getValue();
139+
resourceName = changeStatus.getAdGroup();
139140
break;
140141
case AD_GROUP_AD:
141142
resourceName = changeStatus.getAdGroupAd().getValue();
@@ -144,13 +145,13 @@ private static Optional<String> getResourceNameForResourceType(ChangeStatus chan
144145
resourceName = changeStatus.getAdGroupBidModifier().getValue();
145146
break;
146147
case AD_GROUP_CRITERION:
147-
resourceName = changeStatus.getAdGroup().getValue();
148+
resourceName = changeStatus.getAdGroup();
148149
break;
149150
case AD_GROUP_FEED:
150151
resourceName = changeStatus.getAdGroupFeed().getValue();
151152
break;
152153
case CAMPAIGN:
153-
resourceName = changeStatus.getCampaign().getValue();
154+
resourceName = changeStatus.getCampaign();
154155
break;
155156
case CAMPAIGN_CRITERION:
156157
resourceName = changeStatus.getCampaignCriterion().getValue();

google-ads-examples/src/main/java/com/google/ads/googleads/examples/accountmanagement/GetAccountHierarchy.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
import com.google.ads.googleads.examples.utils.ArgumentNames;
1919
import com.google.ads.googleads.examples.utils.CodeSampleParams;
2020
import com.google.ads.googleads.lib.GoogleAdsClient;
21-
import com.google.ads.googleads.v4.errors.GoogleAdsError;
22-
import com.google.ads.googleads.v4.errors.GoogleAdsException;
23-
import com.google.ads.googleads.v4.resources.CustomerClient;
24-
import com.google.ads.googleads.v4.services.CustomerName;
25-
import com.google.ads.googleads.v4.services.CustomerServiceClient;
26-
import com.google.ads.googleads.v4.services.GoogleAdsRow;
27-
import com.google.ads.googleads.v4.services.GoogleAdsServiceClient;
28-
import com.google.ads.googleads.v4.services.GoogleAdsServiceClient.SearchPagedResponse;
29-
import com.google.ads.googleads.v4.services.ListAccessibleCustomersRequest;
30-
import com.google.ads.googleads.v4.services.ListAccessibleCustomersResponse;
31-
import com.google.ads.googleads.v4.services.SearchGoogleAdsRequest;
21+
import com.google.ads.googleads.v5.errors.GoogleAdsError;
22+
import com.google.ads.googleads.v5.errors.GoogleAdsException;
23+
import com.google.ads.googleads.v5.resources.CustomerClient;
24+
import com.google.ads.googleads.v5.services.CustomerName;
25+
import com.google.ads.googleads.v5.services.CustomerServiceClient;
26+
import com.google.ads.googleads.v5.services.GoogleAdsRow;
27+
import com.google.ads.googleads.v5.services.GoogleAdsServiceClient;
28+
import com.google.ads.googleads.v5.services.GoogleAdsServiceClient.SearchPagedResponse;
29+
import com.google.ads.googleads.v5.services.ListAccessibleCustomersRequest;
30+
import com.google.ads.googleads.v5.services.ListAccessibleCustomersResponse;
31+
import com.google.ads.googleads.v5.services.SearchGoogleAdsRequest;
3232
import com.google.common.base.Strings;
3333
import com.google.common.collect.ArrayListMultimap;
3434
import com.google.common.collect.Multimap;
@@ -53,7 +53,7 @@ public class GetAccountHierarchy {
5353

5454
private static class GetAccountHierarchyParams extends CodeSampleParams {
5555

56-
@Parameter(names = ArgumentNames.MANAGER_ID)
56+
@Parameter(names = ArgumentNames.MANAGER_CUSTOMER_ID)
5757
private Long managerId;
5858

5959
@Parameter(names = ArgumentNames.LOGIN_CUSTOMER_ID)
@@ -84,16 +84,16 @@ public static void main(String[] args) {
8484
return;
8585
}
8686

87-
GoogleAdsClient googleAdsClient;
87+
GoogleAdsClient googleAdsClient = null;
8888
try {
8989
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
9090
} catch (FileNotFoundException fnfe) {
9191
System.err.printf(
9292
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
93-
return;
93+
System.exit(1);
9494
} catch (IOException ioe) {
9595
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
96-
return;
96+
System.exit(1);
9797
}
9898

9999
try {
@@ -111,8 +111,10 @@ public static void main(String[] args) {
111111
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
112112
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
113113
}
114+
System.exit(1);
114115
} catch (IOException ioe) {
115116
System.err.printf("Request failed. Exception: %s%n", ioe);
117+
System.exit(1);
116118
}
117119
}
118120

@@ -259,6 +261,7 @@ private Map<CustomerClient, Multimap<Long, CustomerClient>> createCustomerClient
259261
System.out.printf(
260262
"Unable to retrieve hierarchy for customer ID %d: %s%n",
261263
customerIdToSearchFrom, gae.getGoogleAdsFailure().getErrors(0).getMessage());
264+
return null;
262265
}
263266
}
264267

google-ads-examples/src/main/java/com/google/ads/googleads/examples/accountmanagement/GetAccountInformation.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import com.google.ads.googleads.examples.utils.ArgumentNames;
1919
import com.google.ads.googleads.examples.utils.CodeSampleParams;
2020
import com.google.ads.googleads.lib.GoogleAdsClient;
21-
import com.google.ads.googleads.v4.errors.GoogleAdsError;
22-
import com.google.ads.googleads.v4.errors.GoogleAdsException;
23-
import com.google.ads.googleads.v4.resources.Customer;
24-
import com.google.ads.googleads.v4.services.CustomerServiceClient;
25-
import com.google.ads.googleads.v4.utils.ResourceNames;
21+
import com.google.ads.googleads.v5.errors.GoogleAdsError;
22+
import com.google.ads.googleads.v5.errors.GoogleAdsException;
23+
import com.google.ads.googleads.v5.resources.Customer;
24+
import com.google.ads.googleads.v5.services.CustomerServiceClient;
25+
import com.google.ads.googleads.v5.utils.ResourceNames;
2626
import java.io.FileNotFoundException;
2727
import java.io.IOException;
2828

@@ -47,16 +47,16 @@ public static void main(String[] args) {
4747
params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE");
4848
}
4949

50-
GoogleAdsClient googleAdsClient;
50+
GoogleAdsClient googleAdsClient = null;
5151
try {
5252
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
5353
} catch (FileNotFoundException fnfe) {
5454
System.err.printf(
5555
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
56-
return;
56+
System.exit(1);
5757
} catch (IOException ioe) {
5858
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
59-
return;
59+
System.exit(1);
6060
}
6161

6262
try {
@@ -73,6 +73,7 @@ public static void main(String[] args) {
7373
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
7474
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
7575
}
76+
System.exit(1);
7677
}
7778
}
7879

@@ -92,12 +93,12 @@ private void runExample(GoogleAdsClient googleAdsClient, long customerId) {
9293
System.out.printf(
9394
"Customer with ID %d, descriptive name '%s', currency code '%s', timezone '%s', "
9495
+ "tracking URL template '%s' and auto tagging enabled '%s' was retrieved.%n",
95-
customer.getId().getValue(),
96-
customer.getDescriptiveName().getValue(),
97-
customer.getCurrencyCode().getValue(),
98-
customer.getTimeZone().getValue(),
99-
customer.getTrackingUrlTemplate().getValue(),
100-
customer.getAutoTaggingEnabled().getValue());
96+
customer.getId(),
97+
customer.getDescriptiveName(),
98+
customer.getCurrencyCode(),
99+
customer.getTimeZone(),
100+
customer.getTrackingUrlTemplate(),
101+
customer.getAutoTaggingEnabled());
101102
}
102103
}
103104
}

0 commit comments

Comments
 (0)