Skip to content

Commit 726704b

Browse files
authored
Merge branch 'main' into ludo-java21
2 parents 007a741 + 8622af1 commit 726704b

File tree

8 files changed

+48
-73
lines changed

8 files changed

+48
-73
lines changed

compute/mailjet/src/main/java/com/example/compute/mailjet/MailjetSender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.example.compute.mailjet;
1818

19-
// [START mailjet_imports]
19+
// [START compute_mailjet_imports]
2020

2121
import com.mailjet.client.ClientOptions;
2222
import com.mailjet.client.MailjetClient;
@@ -27,8 +27,9 @@
2727
import org.json.JSONArray;
2828
import org.json.JSONObject;
2929

30-
// [END mailjet_imports]
30+
// [END compute_mailjet_imports]
3131

32+
// [START compute_mailjet_send_email]
3233
// [START app]
3334
public class MailjetSender {
3435

@@ -82,3 +83,4 @@ public MailjetResponse sendMailjet(String recipient, String sender, MailjetClien
8283
}
8384
}
8485
// [END app]
86+
// [END compute_mailjet_send_email]

compute/sendgrid/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
</properties>
3838

3939
<dependencies>
40-
<!-- [START dependencies] -->
40+
<!-- [START compute_sendgrid_dependencies_java] -->
4141
<dependency>
4242
<groupId>com.sendgrid</groupId>
4343
<artifactId>sendgrid-java</artifactId>
4444
<version>4.10.1</version>
4545
</dependency>
46-
<!-- [END dependencies] -->
46+
<!-- [END compute_sendgrid_dependencies_java] -->
4747
</dependencies>
4848
<build>
4949
<plugins>

compute/sendgrid/src/main/java/com/example/compute/sendgrid/SendEmailServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.sendgrid.helpers.mail.objects.Email;
2626
import java.io.IOException;
2727

28-
// [START example]
28+
// [START compute_sendgrid]
2929
public class SendEmailServlet {
3030
static final String SENDGRID_API_KEY = "YOUR-SENDGRID-API-KEY";
3131
static final String SENDGRID_SENDER = "YOUR-SENDGRID-FROM-EMAIL";
@@ -64,4 +64,4 @@ public static void main(String[] args) throws IOException {
6464
}
6565

6666
}
67-
// [END example]
67+
// [END compute_sendgrid]

endpoints/getting-started/k8s/esp_echo_http.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ spec:
3838
labels:
3939
app: esp-echo
4040
spec:
41-
# [START endpoints_secret_1_java]
42-
# [START secret-1]
41+
# [START endpoints_secret1_yaml_java]
4342
volumes:
4443
- name: service-account-creds
4544
secret:
4645
secretName: service-account-creds
47-
# [END secret-1]
48-
# [END endpoints_secret_1_java]
49-
# [START endpoints_service_java]
50-
# [START service]
46+
# [END endpoints_secret1_yaml_java]
47+
# [START endpoints_service_yaml_java]
5148
containers:
5249
- name: esp
5350
image: gcr.io/endpoints-release/endpoints-runtime:1
@@ -58,19 +55,16 @@ spec:
5855
"--rollout_strategy", "managed",
5956
"--service_account_key", "/etc/nginx/creds/service-account-creds.json",
6057
]
61-
# [END service]
62-
# [END endpoints_service_java]
58+
# [END endpoints_service_yaml_java]
6359
ports:
6460
- containerPort: 8080
65-
# [START endpoints_secret_2_java]
66-
# [START secret-2]
61+
# [START endpoints_secret2_yaml_java]
6762
volumeMounts:
6863
- mountPath: /etc/nginx/creds
6964
name: service-account-creds
7065
readOnly: true
71-
# [END secret-2]
72-
# [END endpoints_secret_2_java]
66+
# [END endpoints_secret2_yaml_java]
7367
- name: echo
7468
image: gcr.io/endpoints-release/echo:latest
7569
ports:
76-
- containerPort: 8081
70+
- containerPort: 8081

jobs/v3/src/main/java/com/google/samples/AutoCompleteSample.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public final class AutoCompleteSample {
3838
private static CloudTalentSolution talentSolutionClient =
3939
JobServiceQuickstart.getTalentSolutionClient();
4040

41-
// [START auto_complete_job_title]
41+
// [START job_auto_complete_job_title]
4242

4343
/** Auto completes job titles within given companyName. */
4444
public static void jobTitleAutoComplete(String companyName, String query) throws IOException {
@@ -59,9 +59,9 @@ public static void jobTitleAutoComplete(String companyName, String query) throws
5959

6060
System.out.println(results);
6161
}
62-
// [END auto_complete_job_title]
62+
// [END job_auto_complete_job_title]
6363

64-
// [START auto_complete_default]
64+
// [START job_auto_complete_default]
6565
/** Auto completes job titles within given companyName. */
6666
public static void defaultAutoComplete(String companyName, String query) throws IOException {
6767
Complete complete =
@@ -79,7 +79,7 @@ public static void defaultAutoComplete(String companyName, String query) throws
7979

8080
System.out.println(results);
8181
}
82-
// [END auto_complete_default]
82+
// [END job_auto_complete_default]
8383

8484
public static void main(String... args) throws Exception {
8585
Company companyToBeCreated = BasicCompanySample.generateCompany().setDisplayName("Google");

jobs/v3/src/main/java/com/google/samples/LocationSearchSample.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public final class LocationSearchSample {
4949
JobServiceQuickstart.getTalentSolutionClient();
5050

5151
// [START job_basic_location_search]
52-
// [START basic_location_search]
5352

5453
/** Basic location Search */
5554
public static void basicLocationSearch(String companyName, String location, double distance)
@@ -80,11 +79,9 @@ public static void basicLocationSearch(String companyName, String location, doub
8079
System.out.printf("Basic location search results: %s", response);
8180

8281
}
83-
// [END basic_location_search]
8482
// [END job_basic_location_search]
8583

8684
// [START job_keyword_location_search]
87-
// [START keyword_location_search]
8885

8986
/** Keyword location Search */
9087
public static void keywordLocationSearch(
@@ -116,11 +113,9 @@ public static void keywordLocationSearch(
116113
Thread.sleep(1000);
117114
System.out.printf("Keyword location search results: %s", response);
118115
}
119-
// [END keyword_location_search]
120116
// [END job_keyword_location_search]
121117

122118
// [START job_city_location_search]
123-
// [START city_location_search]
124119

125120
/** City location Search */
126121
public static void cityLocationSearch(String companyName, String location)
@@ -149,11 +144,9 @@ public static void cityLocationSearch(String companyName, String location)
149144
Thread.sleep(1000);
150145
System.out.printf("City locations search results: %s", response);
151146
}
152-
// [END city_location_search]
153147
// [END job_city_location_search]
154148

155149
// [START job_multi_locations_search]
156-
// [START multi_locations_search]
157150

158151
/** Multiple locations Search */
159152
public static void multiLocationsSearch(
@@ -189,10 +182,8 @@ public static void multiLocationsSearch(
189182

190183
}
191184
// [END job_multi_locations_search]
192-
// [END multi_locations_search]
193185

194186
// [START job_broadening_location_search]
195-
// [START broadening_location_search]
196187

197188
/** Broadening location Search */
198189
public static void broadeningLocationsSearch(String companyName, String location)
@@ -222,7 +213,6 @@ public static void broadeningLocationsSearch(String companyName, String location
222213
Thread.sleep(1000);
223214
System.out.printf("Broadening locations search results: %s", response);
224215
}
225-
// [END broadening_location_search]
226216
// [END job_broadening_location_search]
227217

228218
public static void main(String... args) throws Exception {
@@ -257,4 +247,4 @@ public static void main(String... args) throws Exception {
257247
BasicJobSample.deleteJob(jobName2);
258248
BasicCompanySample.deleteCompany(companyName);
259249
}
260-
}
250+
}

security-command-center/snippets/src/test/java/management/api/EventThreatDetectionCustomModuleTest.java

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
import com.google.cloud.securitycentermanagement.v1.EffectiveEventThreatDetectionCustomModule;
2525
import com.google.cloud.securitycentermanagement.v1.EventThreatDetectionCustomModule;
2626
import com.google.cloud.securitycentermanagement.v1.EventThreatDetectionCustomModule.EnablementState;
27-
import com.google.cloud.securitycentermanagement.v1.ListEventThreatDetectionCustomModulesRequest;
28-
import com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient;
2927
import com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListDescendantEventThreatDetectionCustomModulesPagedResponse;
3028
import com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListEffectiveEventThreatDetectionCustomModulesPagedResponse;
3129
import com.google.cloud.securitycentermanagement.v1.SecurityCenterManagementClient.ListEventThreatDetectionCustomModulesPagedResponse;
3230
import com.google.cloud.securitycentermanagement.v1.ValidateEventThreatDetectionCustomModuleResponse;
3331
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
3432
import com.google.common.base.Strings;
3533
import java.io.IOException;
34+
import java.util.ArrayList;
35+
import java.util.List;
3636
import java.util.UUID;
3737
import java.util.regex.Matcher;
3838
import java.util.regex.Pattern;
@@ -52,6 +52,7 @@ public class EventThreatDetectionCustomModuleTest {
5252
"java_sample_etd_custom_module_test_" + UUID.randomUUID();
5353
private static final int MAX_ATTEMPT_COUNT = 3;
5454
private static final int INITIAL_BACKOFF_MILLIS = 120000; // 2 minutes
55+
private static List<String> createdCustomModuleIds = new ArrayList<>();
5556

5657
@Rule
5758
public final MultipleAttemptsRule multipleAttemptsRule =
@@ -71,36 +72,16 @@ public static void setUp() {
7172
}
7273

7374
@AfterClass
75+
// Perform cleanup of all the custom modules created by the current execution of the test, after
76+
// running tests
7477
public static void cleanUp() throws IOException {
75-
// Perform cleanup after running tests
76-
cleanupExistingCustomModules();
77-
}
78-
79-
// cleanupExistingCustomModules clean up all the existing custom module
80-
private static void cleanupExistingCustomModules() throws IOException {
81-
try (SecurityCenterManagementClient client = SecurityCenterManagementClient.create()) {
82-
ListEventThreatDetectionCustomModulesRequest request =
83-
ListEventThreatDetectionCustomModulesRequest.newBuilder()
84-
.setParent(String.format("projects/%s/locations/global", PROJECT_ID))
85-
.build();
86-
ListEventThreatDetectionCustomModulesPagedResponse response =
87-
client.listEventThreatDetectionCustomModules(request);
88-
// Iterate over the response and delete custom module one by one which start with
89-
// java_sample_custom_module
90-
for (EventThreatDetectionCustomModule module : response.iterateAll()) {
91-
try {
92-
if (module.getDisplayName().startsWith("java_sample_etd_custom_module")) {
93-
String customModuleId = extractCustomModuleId(module.getName());
94-
deleteCustomModule(PROJECT_ID, customModuleId);
95-
}
96-
} catch (Exception e) {
97-
System.err.println("Failed to delete module: " + module.getDisplayName());
98-
e.printStackTrace();
99-
}
78+
for (String customModuleId : createdCustomModuleIds) {
79+
try {
80+
deleteCustomModule(PROJECT_ID, customModuleId);
81+
} catch (Exception e) {
82+
System.err.println("Failed to delete module: " + customModuleId);
83+
e.printStackTrace();
10084
}
101-
} catch (Exception e) {
102-
System.err.println("Failed to process cleanupExistingCustomModules.");
103-
e.printStackTrace();
10485
}
10586
}
10687

@@ -131,6 +112,7 @@ public void testCreateEventThreatDetectionCustomModule() throws IOException {
131112
EventThreatDetectionCustomModule response =
132113
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
133114
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
115+
createdCustomModuleIds.add(extractCustomModuleId(response.getName()));
134116
assertNotNull(response);
135117
assertThat(response.getDisplayName()).isEqualTo(CUSTOM_MODULE_DISPLAY_NAME);
136118
}
@@ -148,8 +130,10 @@ public void testDeleteEventThreatDetectionCustomModule() throws IOException {
148130

149131
@Test
150132
public void testListEventThreatDetectionCustomModules() throws IOException {
151-
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
152-
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
133+
EventThreatDetectionCustomModule createCustomModuleResponse =
134+
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
135+
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
136+
createdCustomModuleIds.add(extractCustomModuleId(createCustomModuleResponse.getName()));
153137
ListEventThreatDetectionCustomModulesPagedResponse response =
154138
ListEventThreatDetectionCustomModules.listEventThreatDetectionCustomModules(PROJECT_ID);
155139
assertTrue(
@@ -163,6 +147,7 @@ public void testGetEventThreatDetectionCustomModule() throws IOException {
163147
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
164148
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
165149
String customModuleId = extractCustomModuleId(response.getName());
150+
createdCustomModuleIds.add(customModuleId);
166151
EventThreatDetectionCustomModule getCustomModuleResponse =
167152
GetEventThreatDetectionCustomModule.getEventThreatDetectionCustomModule(
168153
PROJECT_ID, customModuleId);
@@ -177,6 +162,7 @@ public void testUpdateEventThreatDetectionCustomModule() throws IOException {
177162
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
178163
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
179164
String customModuleId = extractCustomModuleId(createCustomModuleResponse.getName());
165+
createdCustomModuleIds.add(customModuleId);
180166
EventThreatDetectionCustomModule response =
181167
UpdateEventThreatDetectionCustomModule.updateEventThreatDetectionCustomModule(
182168
PROJECT_ID, customModuleId);
@@ -190,6 +176,7 @@ public void testGetEffectiveEventThreatDetectionCustomModule() throws IOExceptio
190176
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
191177
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
192178
String customModuleId = extractCustomModuleId(createCustomModuleResponse.getName());
179+
createdCustomModuleIds.add(customModuleId);
193180
EffectiveEventThreatDetectionCustomModule getEffectiveCustomModuleResponse =
194181
GetEffectiveEventThreatDetectionCustomModule.getEffectiveEventThreatDetectionCustomModule(
195182
PROJECT_ID, customModuleId);
@@ -202,8 +189,10 @@ public void testGetEffectiveEventThreatDetectionCustomModule() throws IOExceptio
202189

203190
@Test
204191
public void testListEffectiveEventThreatDetectionCustomModules() throws IOException {
205-
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
206-
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
192+
EventThreatDetectionCustomModule createCustomModuleResponse =
193+
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
194+
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
195+
createdCustomModuleIds.add(extractCustomModuleId(createCustomModuleResponse.getName()));
207196
ListEffectiveEventThreatDetectionCustomModulesPagedResponse response =
208197
ListEffectiveEventThreatDetectionCustomModules
209198
.listEffectiveEventThreatDetectionCustomModules(PROJECT_ID);
@@ -214,8 +203,10 @@ public void testListEffectiveEventThreatDetectionCustomModules() throws IOExcept
214203

215204
@Test
216205
public void testListDescendantEventThreatDetectionCustomModules() throws IOException {
217-
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
218-
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
206+
EventThreatDetectionCustomModule createCustomModuleResponse =
207+
CreateEventThreatDetectionCustomModule.createEventThreatDetectionCustomModule(
208+
PROJECT_ID, CUSTOM_MODULE_DISPLAY_NAME);
209+
createdCustomModuleIds.add(extractCustomModuleId(createCustomModuleResponse.getName()));
219210
ListDescendantEventThreatDetectionCustomModulesPagedResponse response =
220211
ListDescendantEventThreatDetectionCustomModules
221212
.listDescendantEventThreatDetectionCustomModules(PROJECT_ID);
@@ -233,4 +224,4 @@ public void testValidateEventThreatDetectionCustomModule() throws IOException {
233224
assertNotNull(response);
234225
assertThat(response.getErrorsCount()).isEqualTo(0);
235226
}
236-
}
227+
}

storage-transfer/src/test/java/com/google/cloud/storage/storagetransfer/samples/test/util/TransferJobUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
// [START storagetransfer_transfer_all]
18-
// [START all]
1918

2019
package com.google.cloud.storage.storagetransfer.samples.test.util;
2120

@@ -68,5 +67,4 @@ public static TimeOfDay createTimeOfDay(String timeString)
6867
return time;
6968
}
7069
}
71-
// [END all]
7270
// [END storagetransfer_transfer_all]

0 commit comments

Comments
 (0)