Skip to content

Commit 75f16be

Browse files
authored
Changes for release v8_1. (#470)
1 parent f10fcac commit 75f16be

5,149 files changed

Lines changed: 88146 additions & 1755580 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
15.0.0 - 2021-08-12
2+
-------------------
3+
- Added and updated examples for Google Ads API v8.1.
4+
- Removed support for Google Ads API v6.0.
5+
- Fixed bugs and added tests for the FieldMasks utility.
6+
- Fixed issues with third_party directory generation.
7+
18
14.0.0 - 2021-07-07
29
-------------------
310
- Added and updated examples for Google Ads API v8.0.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ This project hosts the Java client library for the Google Ads API.
2323
<dependency>
2424
<groupId>com.google.api-ads</groupId>
2525
<artifactId>google-ads</artifactId>
26-
<version>14.0.0</version>
26+
<version>15.0.0</version>
2727
</dependency>
2828

2929
## Gradle dependency
3030

31-
implementation 'com.google.api-ads:google-ads:14.0.0'
32-
31+
implementation 'com.google.api-ads:google-ads:15.0.0'
32+
3333
## Documentation
3434

3535
Our documentation is available [here](https://developers.google.com/google-ads/api/docs/client-libs/java).

buildSrc/src/main/groovy/com.google.api-ads.java-conventions.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ plugins {
2626
id 'maven-publish'
2727
}
2828

29+
// The order of the repositories here is important. If mavenLocal() is first,
30+
// then when we attempt to resolve artifacts like sources for the third_party
31+
// directory, gradle will not even attempt to look for them in mavenCentral.
2932
repositories {
30-
mavenLocal()
31-
mavenCentral()
33+
mavenCentral()
34+
mavenLocal()
3235
}
3336

3437
group = 'com.google.api-ads'

google-ads-examples/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ dependencies {
4646
implementation 'com.beust:jcommander:1.72'
4747
implementation 'joda-time:joda-time:2.8.2'
4848
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.1'
49+
testImplementation 'org.reflections:reflections:0.9.11'
4950
testImplementation 'org.mockito:mockito-core:2.27.0'
51+
testImplementation 'org.hamcrest:hamcrest:2.2'
5052
}
5153

5254
description = 'Google Ads API client library for Java examples'

google-ads-examples/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,17 @@
8282
<version>4.13.1</version>
8383
<scope>test</scope>
8484
</dependency>
85+
<dependency>
86+
<groupId>org.reflections</groupId>
87+
<artifactId>reflections</artifactId>
88+
<version>0.9.11</version>
89+
<scope>test</scope>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.hamcrest</groupId>
93+
<artifactId>hamcrest</artifactId>
94+
<version>2.2</version>
95+
<scope>test</scope>
96+
</dependency>
8597
</dependencies>
8698
</project>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,20 @@ private Optional<Message> getResourceByType(
181181
return Optional.of(resource.getAdGroupCriterion());
182182
case AD_GROUP_BID_MODIFIER:
183183
return Optional.of(resource.getAdGroupBidModifier());
184+
case AD_GROUP_ASSET:
185+
return Optional.of(resource.getAdGroupAsset());
186+
case ASSET:
187+
return Optional.of(resource.getAsset());
184188
case CAMPAIGN:
185189
return Optional.of(resource.getCampaign());
190+
case CAMPAIGN_ASSET:
191+
return Optional.of(resource.getCampaignAsset());
186192
case CAMPAIGN_BUDGET:
187193
return Optional.of(resource.getCampaignBudget());
188194
case CAMPAIGN_CRITERION:
189195
return Optional.of(resource.getCampaignCriterion());
196+
case CUSTOMER_ASSET:
197+
return Optional.of(resource.getCustomerAsset());
190198
case AD_GROUP_FEED:
191199
return Optional.of(resource.getAdGroupFeed());
192200
case CAMPAIGN_FEED:
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.ads.googleads.examples.advancedoperations;
16+
17+
import static com.google.ads.googleads.examples.utils.CodeSampleHelper.getPrintableDateTime;
18+
19+
import com.beust.jcommander.Parameter;
20+
import com.google.ads.googleads.examples.utils.ArgumentNames;
21+
import com.google.ads.googleads.examples.utils.CodeSampleParams;
22+
import com.google.ads.googleads.lib.GoogleAdsClient;
23+
import com.google.ads.googleads.v8.enums.AdvertisingChannelTypeEnum.AdvertisingChannelType;
24+
import com.google.ads.googleads.v8.enums.SeasonalityEventScopeEnum.SeasonalityEventScope;
25+
import com.google.ads.googleads.v8.errors.GoogleAdsError;
26+
import com.google.ads.googleads.v8.errors.GoogleAdsException;
27+
import com.google.ads.googleads.v8.resources.BiddingDataExclusion;
28+
import com.google.ads.googleads.v8.services.BiddingDataExclusionOperation;
29+
import com.google.ads.googleads.v8.services.BiddingDataExclusionServiceClient;
30+
import com.google.ads.googleads.v8.services.MutateBiddingDataExclusionsResponse;
31+
import com.google.common.collect.ImmutableList;
32+
import java.io.FileNotFoundException;
33+
import java.io.IOException;
34+
35+
/**
36+
* Adds a customer-level data exclusion that excludes conversions from being used by Smart Bidding
37+
* for the time interval specified.
38+
*
39+
* <p>For more information on using data exclusions, see
40+
* https://developers.google.com/google-ads/api/docs/campaigns/bidding/data-exclusions.
41+
*/
42+
public class AddBiddingDataExclusion {
43+
44+
private static class AddBiddingDataExclusionParams extends CodeSampleParams {
45+
46+
@Parameter(
47+
names = ArgumentNames.CUSTOMER_ID,
48+
required = true,
49+
description =
50+
"The client customer ID of the Google Ads account that the data exclusion will"
51+
+ " be added to.")
52+
private Long customerId;
53+
54+
@Parameter(
55+
names = ArgumentNames.START_DATE_TIME,
56+
required = true,
57+
description =
58+
"The start date time in yyyy-MM-dd HH:mm:ss format of the data exclusion period.")
59+
private String startDateTime;
60+
61+
@Parameter(
62+
names = ArgumentNames.END_DATE_TIME,
63+
required = true,
64+
description =
65+
"The end date time in yyyy-MM-dd HH:mm:ss format of the data exclusion period.")
66+
private String endDateTime;
67+
}
68+
69+
public static void main(String[] args) throws IOException {
70+
AddBiddingDataExclusionParams params = new AddBiddingDataExclusionParams();
71+
if (!params.parseArguments(args)) {
72+
// Either pass the required parameters for this example on the command line, or insert them
73+
// into the code here. See the parameter class definition above for descriptions.
74+
params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE");
75+
params.startDateTime = "INSERT_START_DATE_TIME_HERE";
76+
params.endDateTime = "INSERT_END_DATE_TIME_HERE";
77+
}
78+
79+
GoogleAdsClient googleAdsClient = null;
80+
try {
81+
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
82+
} catch (FileNotFoundException fnfe) {
83+
System.err.printf(
84+
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
85+
System.exit(1);
86+
} catch (IOException ioe) {
87+
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
88+
System.exit(1);
89+
}
90+
91+
try {
92+
new AddBiddingDataExclusion()
93+
.runExample(googleAdsClient, params.customerId, params.startDateTime, params.endDateTime);
94+
} catch (GoogleAdsException gae) {
95+
// GoogleAdsException is the base class for most exceptions thrown by an API request.
96+
// Instances of this exception have a message and a GoogleAdsFailure that contains a
97+
// collection of GoogleAdsErrors that indicate the underlying causes of the
98+
// GoogleAdsException.
99+
System.err.printf(
100+
"Request ID %s failed due to GoogleAdsException. Underlying errors:%n",
101+
gae.getRequestId());
102+
int i = 0;
103+
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
104+
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
105+
}
106+
System.exit(1);
107+
}
108+
}
109+
110+
/**
111+
* Adds a "CUSTOMER" scoped data exclusion for the client customer ID and dates specified.
112+
*
113+
* @param googleAdsClient the GoogleAdsClient
114+
* @param customerId the client ID of the Google Ads account
115+
* @param startDateTime the start time of the data exclusion (in yyyy-MM-dd HH:mm:ss format) in
116+
* the account's timezone
117+
* @param endDateTime the end time of the data exclusion (in yyyy-MM-dd HH:mm:ss format) in the
118+
* account's timezone
119+
*/
120+
private void runExample(
121+
GoogleAdsClient googleAdsClient, Long customerId, String startDateTime, String endDateTime) {
122+
123+
try (BiddingDataExclusionServiceClient DataExclusionServiceClient =
124+
googleAdsClient.getLatestVersion().createBiddingDataExclusionServiceClient()) {
125+
126+
// [START add_bidding_data_exclusion]
127+
BiddingDataExclusion DataExclusion =
128+
BiddingDataExclusion.newBuilder()
129+
// A unique name is required for every data exclusion.
130+
.setName("Data exclusion #" + getPrintableDateTime())
131+
// The CHANNEL scope applies the data exclusion to all campaigns of specific
132+
// advertising channel types. In this example, the the exclusion will only apply to
133+
// Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific
134+
// campaigns.
135+
.setScope(SeasonalityEventScope.CHANNEL)
136+
.addAdvertisingChannelTypes(AdvertisingChannelType.SEARCH)
137+
// If setting scope CAMPAIGN, add individual campaign resource name(s) according to
138+
// the commented out line below.
139+
// .addCampaigns("INSERT_CAMPAIGN_RESOURCE_NAME_HERE")
140+
.setStartDateTime(startDateTime)
141+
.setEndDateTime(endDateTime)
142+
.build();
143+
144+
BiddingDataExclusionOperation operation =
145+
BiddingDataExclusionOperation.newBuilder().setCreate(DataExclusion).build();
146+
147+
MutateBiddingDataExclusionsResponse response =
148+
DataExclusionServiceClient.mutateBiddingDataExclusions(
149+
customerId.toString(), ImmutableList.of(operation));
150+
System.out.printf(
151+
"Added data exclusion with resource name: %s%n",
152+
response.getResults(0).getResourceName());
153+
// [END add_bidding_data_exclusion]
154+
}
155+
}
156+
}

0 commit comments

Comments
 (0)