8000 feat(routeoptimization): New code samples (#9367) · suztomo/java-docs-samples@df268fc · GitHub
[go: up one dir, main page]

Skip to content

Commit df268fc

Browse files
bshiiennae
andauthored
feat(routeoptimization): New code samples (GoogleCloudPlatform#9367)
* feat(routeoptimization): New code samples --------- Co-authored-by: Jennifer Davis <iennae@gmail.com> Co-authored-by: Jennifer Davis <sigje@google.com>
1 parent 444c99f commit df268fc

File tree

5 files changed

+168
-7
lines changed

5 files changed

+168
-7
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@
9191
/datacatalog @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/googleapi-dataplex
9292
/functions @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/torus-dpe @GoogleCloudPlatform/functions-framework-google
9393
# ---* Fully Eng Owned
94+
9495
/appengine-* @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/serverless-runtimes
9596
/asset @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-asset-analysis-team @GoogleCloudPlatform/cloud-asset-platform-team
9697
/dlp @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/googleapis-dlp
9798
/flexible @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/serverless-runtimes
9899
/healthcare @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/healthcare-life-sciences
99-
/managedkafka @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/api-pubsub-and-pubsublite
100+
/iot @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/api-iot
100101
/media @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-media-team
101102
/pubsub @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/api-pubsub-and-pubsublite
102103
/pubsublite @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/api-pubsub-and-pubsublite
103104
/retail @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-retail-team
104105
/unittests @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/serverless-runtimes
106+
/bigquery/bigquerydatatransfer @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
107+
/routeoptimization @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/geo-routeoptimization

.github/blunderbuss.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ assign_issues:
1616
- GoogleCloudPlatform/java-samples-reviewers
1717

1818
assign_issues_by:
19+
- labels:
20+
- "api: routeoptimization"
21+
to:
22+
- GoogleCloudPlatform/geo-routeoptimization
1923
- labels:
2024
- "api: cloudasset"
2125
to:
@@ -93,7 +97,6 @@ assign_issues_by:
9397
- "api: cloudfunctions"
9498
to:
9599
- GoogleCloudPlatform/functions-framework-google
96-
- GoogleCloudPlatform/torus-dpe
97100
- labels:
98101
- "api: bigquerydatatransfer"
99102
to:
@@ -180,8 +183,3 @@ assign_prs_by:
180183
- "api: cloudfunctions"
181184
to:
182185
- GoogleCloudPlatform/functions-framework-google
183-
- GoogleCloudPlatform/torus-dpe
184-
- labels:
185-
- "api: bigquerydatatransfer"
186-
to:
187-
- GoogleCloudPlatform/bigquery-data-connectors

routeoptimization/snippets/pom.xml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2022 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<groupId>com.example.routeoptimization</groupId>
22+
<artifactId>routeoptimization-samples</artifactId>
23+
<version>1.0-SNAPSHOT</version>
24+
25+
<!--
26+
The parent pom defines common style checks and testing strategies for our samples.
27+
Removing or replacing it should not affect the execution of the samples in anyway.
28+
-->
29+
<parent>
30+
<artifactId>shared-configuration</artifactId>
31+
<groupId>com.google.cloud.samples</groupId>
32+
<version>1.2.0</version>
33+
</parent>
34+
35+
<properties>
36+
<maven.compiler.source>11</maven.compiler.source>
37+
<maven.compiler.target>11</maven.compiler.target>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>com.google.maps</groupId>
43+
<artifactId>google-maps-routeoptimization</artifactId>
44+
<version>0.5.0</version>
45+
</dependency>
46+
47+
<!-- Test dependencies -->
48+
<dependency>
49+
<artifactId>truth</artifactId>
50+
<groupId>com.google.truth</groupId>
51+
<scope>test</scope>
52+
<version>1.4.0</version>
53+
</dependency>
54+
<dependency>
55+
<artifactId>junit</artifactId>
56+
<groupId>junit</groupId>
57+
<scope>test</scope>
58+
<version>4.13.2</version>
59+
</dependency>
60+
</dependencies>
61+
</project>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Create features in bulk for an existing entity type. See
18+
* https://cloud.google.com/vertex-ai/docs/featurestore/setup
19+
* before running the code snippet
20+
*/
21+
22+
package com.example;
23+
24+
// [START routeoptimization_v1_OptimizeTours_sync]
25+
import com.google.maps.routeoptimization.v1.OptimizeToursRequest;
26+
import com.google.maps.routeoptimization.v1.OptimizeToursResponse;
27+
import com.google.maps.routeoptimization.v1.RouteOptimizationClient;
28+
import com.google.maps.routeoptimization.v1.Shipment;
29+
import com.google.maps.routeoptimization.v1.Shipment.VisitRequest;
30+
import com.google.maps.routeoptimization.v1.ShipmentModel;
31+
import com.google.maps.routeoptimization.v1.Vehicle;
32+
import com.google.type.LatLng;
33+
34+
public class OptimizeTours {
35+
// [END routeoptimization_v1_OptimizeTours_sync]
36+
public static void main(String[] args) throws Exception {
37+
// TODO(developer): Replace these variables before running the sample.
38+
String project = "YOUR_PROJECT_ID";
39+
System.out.println(optimizeTours(project));
40+
}
41+
42+
// [START routeoptimization_v1_OptimizeTours_sync]
43+
public static OptimizeToursResponse optimizeTours(String projectId) throws Exception {
44+
RouteOptimizationClient client = RouteOptimizationClient.create();
45+
OptimizeToursRequest request =
46+
OptimizeToursRequest.newBuilder()
47+
.setParent("projects/" + projectId)
48+
.setModel(
49+
ShipmentModel.newBuilder()
50+
.addShipments(
51+
Shipment.newBuilder()
52+
.addPickups(
53+
VisitRequest.newBuilder()
54+
.setArrivalLocation(
55+
LatLng.newBuilder().setLatitude(48.8).setLongitude(2.4))))
56+
.addVehicles(
57+
Vehicle.newBuilder()
58+
.setStartLocation(
59+
LatLng.newBuilder().setLatitude(48.9).setLongitude(2.5))))
60+
.build();
61+
return client.optimizeTours(request);
62+
}
63+
}
64+
// [END routeoptimization_v1_OptimizeTours_sync]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Create features in bulk for an existing entity type. See
18+
* https://cloud.google.com/vertex-ai/docs/featurestore/setup
19+
* before running the code snippet
20+
*/
21+
22+
package com.example;
23+
24+
import static com.google.common.truth.Truth.assertThat;
25+
26+
import org.junit.Test;
27+
28+
public final class OptimizeToursTest {
29+
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
30+
31+
@Test
32+
public void optimizeTours_success() throws Exception {
33+
assertThat(OptimizeTours.optimizeTours(PROJECT_ID).hasMetrics()).isTrue();
34+
}
35+
}

0 commit comments

Comments
 (0)
0