Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit e49ac6a

Browse files
Merge 4e788cf into d44f21c
2 parents d44f21c + 4e788cf commit e49ac6a

File tree

29 files changed

+3052
-384
lines changed

29 files changed

+3052
-384
lines changed

google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public RecommenderStub getStub() {
152152
* formats:
153153
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
154154
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
155+
* INSIGHT_TYPE_ID refers to supported insight types:
156+
* https://cloud.google.com/recommender/docs/insights/insight-types.)
155157
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
156158
*/
157159
public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
@@ -171,6 +173,8 @@ public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
171173
* formats:
172174
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
173175
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
176+
* INSIGHT_TYPE_ID refers to supported insight types:
177+
* https://cloud.google.com/recommender/docs/insights/insight-types.)
174178
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
175179
*/
176180
public final ListInsightsPagedResponse listInsights(String parent) {
@@ -355,6 +359,8 @@ public final UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAccep
355359
* formats:
356360
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
357361
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
362+
* RECOMMENDER_ID refers to supported recommenders:
363+
* https://cloud.google.com/recommender/docs/recommenders.
358364
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
359365
*/
360366
public final ListRecommendationsPagedResponse listRecommendations(RecommenderName parent) {
@@ -374,6 +380,8 @@ public final ListRecommendationsPagedResponse listRecommendations(RecommenderNam
374380
* formats:
375381
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
376382
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
383+
* RECOMMENDER_ID refers to supported recommenders:
384+
* https://cloud.google.com/recommender/docs/recommenders.
377385
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
378386
*/
379387
public final ListRecommendationsPagedResponse listRecommendations(String parent) {
@@ -391,6 +399,8 @@ public final ListRecommendationsPagedResponse listRecommendations(String parent)
391399
* formats:
392400
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
393401
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
402+
* RECOMMENDER_ID refers to supported recommenders:
403+
* https://cloud.google.com/recommender/docs/recommenders.
394404
* @param filter Filter expression to restrict the recommendations returned. Supported filter
395405
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
396406
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -414,6 +424,8 @@ public final ListRecommendationsPagedResponse listRecommendations(
414424
* formats:
415425
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
416426
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
427+
* RECOMMENDER_ID refers to supported recommenders:
428+
* https://cloud.google.com/recommender/docs/recommenders.
417429
* @param filter Filter expression to restrict the recommendations returned. Supported filter
418430
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
419431
* @throws com.google.api.gax.rpc.ApiException if the remote call fails

google-cloud-recommender/src/test/java/com/google/cloud/recommender/v1/RecommenderClientTest.java

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public void listInsightsTest() throws Exception {
9595
.build();
9696
mockRecommender.addResponse(expectedResponse);
9797

98-
InsightTypeName parent = InsightTypeName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
98+
InsightTypeName parent =
99+
InsightTypeName.ofProjectLocationInsightTypeName(
100+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
99101

100102
ListInsightsPagedResponse pagedListResponse = client.listInsights(parent);
101103

@@ -121,7 +123,9 @@ public void listInsightsExceptionTest() throws Exception {
121123
mockRecommender.addException(exception);
122124

123125
try {
124-
InsightTypeName parent = InsightTypeName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
126+
InsightTypeName parent =
127+
InsightTypeName.ofProjectLocationInsightTypeName(
128+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
125129
client.listInsights(parent);
126130
Assert.fail("No exception raised");
127131
} catch (InvalidArgumentException e) {
@@ -178,7 +182,9 @@ public void getInsightTest() throws Exception {
178182
Insight expectedResponse =
179183
Insight.newBuilder()
180184
.setName(
181-
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
185+
InsightName.ofProjectLocationInsightTypeInsightName(
186+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
187+
.toString())
182188
.setDescription("description-1724546052")
183189
.addAllTargetResources(new ArrayList<String>())
184190
.setInsightSubtype("insightSubtype841535170")
@@ -191,7 +197,9 @@ public void getInsightTest() throws Exception {
191197
.build();
192198
mockRecommender.addResponse(expectedResponse);
193199

194-
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
200+
InsightName name =
201+
InsightName.ofProjectLocationInsightTypeInsightName(
202+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
195203

196204
Insight actualResponse = client.getInsight(name);
197205
Assert.assertEquals(expectedResponse, actualResponse);
@@ -213,7 +221,9 @@ public void getInsightExceptionTest() throws Exception {
213221
mockRecommender.addException(exception);
214222

215223
try {
216-
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
224+
InsightName name =
225+
InsightName.ofProjectLocationInsightTypeInsightName(
226+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
217227
client.getInsight(name);
218228
Assert.fail("No exception raised");
219229
} catch (InvalidArgumentException e) {
@@ -226,7 +236,9 @@ public void getInsightTest2() throws Exception {
226236
Insight expectedResponse =
227237
Insight.newBuilder()
228238
.setName(
229-
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
239+
InsightName.ofProjectLocationInsightTypeInsightName(
240+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
241+
.toString())
230242
.setDescription("description-1724546052")
231243
.addAllTargetResources(new ArrayList<String>())
232244
.setInsightSubtype("insightSubtype841535170")
@@ -274,7 +286,9 @@ public void markInsightAcceptedTest() throws Exception {
274286
Insight expectedResponse =
275287
Insight.newBuilder()
276288
.setName(
277-
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
289+
InsightName.ofProjectLocationInsightTypeInsightName(
290+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
291+
.toString())
278292
.setDescription("description-1724546052")
279293
.addAllTargetResources(new ArrayList<String>())
280294
.setInsightSubtype("insightSubtype841535170")
@@ -287,7 +301,9 @@ public void markInsightAcceptedTest() throws Exception {
287301
.build();
288302
mockRecommender.addResponse(expectedResponse);
289303

290-
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
304+
InsightName name =
305+
InsightName.ofProjectLocationInsightTypeInsightName(
306+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
291307
Map<String, String> stateMetadata = new HashMap<>();
292308
String etag = "etag3123477";
293309

@@ -313,7 +329,9 @@ public void markInsightAcceptedExceptionTest() throws Exception {
313329
mockRecommender.addException(exception);
314330

315331
try {
316-
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
332+
InsightName name =
333+
InsightName.ofProjectLocationInsightTypeInsightName(
334+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
317335
Map<String, String> stateMetadata = new HashMap<>();
318336
String etag = "etag3123477";
319337
client.markInsightAccepted(name, stateMetadata, etag);
@@ -328,7 +346,9 @@ public void markInsightAcceptedTest2() throws Exception {
328346
Insight expectedResponse =
329347
Insight.newBuilder()
330348
.setName(
331-
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
349+
InsightName.ofProjectLocationInsightTypeInsightName(
350+
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
351+
.toString())
332352
.setDescription("description-1724546052")
333353
.addAllTargetResources(new ArrayList<String>())
334354
.setInsightSubtype("insightSubtype841535170")
@@ -387,7 +407,9 @@ public void listRecommendationsTest() throws Exception {
387407
.build();
388408
mockRecommender.addResponse(expectedResponse);
389409

390-
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
410+
RecommenderName parent =
411+
RecommenderName.ofProjectLocationRecommenderName(
412+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
391413

392414
ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);
393415

@@ -413,7 +435,9 @@ public void listRecommendationsExceptionTest() throws Exception {
413435
mockRecommender.addException(exception);
414436

415437
try {
416-
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
438+
RecommenderName parent =
439+
RecommenderName.ofProjectLocationRecommenderName(
440+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
417441
client.listRecommendations(parent);
418442
Assert.fail("No exception raised");
419443
} catch (InvalidArgumentException e) {
@@ -475,7 +499,9 @@ public void listRecommendationsTest3() throws Exception {
475499
.build();
476500
mockRecommender.addResponse(expectedResponse);
477501

478-
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
502+
RecommenderName parent =
503+
RecommenderName.ofProjectLocationRecommenderName(
504+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
479505
String filter = "filter-1274492040";
480506

481507
ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter);
@@ -503,7 +529,9 @@ public void listRecommendationsExceptionTest3() throws Exception {
503529
mockRecommender.addException(exception);
504530

505531
try {
506-
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
532+
RecommenderName parent =
533+
RecommenderName.ofProjectLocationRecommenderName(
534+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
507535
String filter = "filter-1274492040";
508536
client.listRecommendations(parent, filter);
509537
Assert.fail("No exception raised");
@@ -564,7 +592,7 @@ public void getRecommendationTest() throws Exception {
564592
Recommendation expectedResponse =
565593
Recommendation.newBuilder()
566594
.setName(
567-
RecommendationName.of(
595+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
568596
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
569597
.toString())
570598
.setDescription("description-1724546052")
@@ -580,7 +608,8 @@ public void getRecommendationTest() throws Exception {
580608
mockRecommender.addResponse(expectedResponse);
581609

582610
RecommendationName name =
583-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
611+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
612+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
584613

585614
Recommendation actualResponse = client.getRecommendation(name);
586615
Assert.assertEquals(expectedResponse, actualResponse);
@@ -603,7 +632,8 @@ public void getRecommendationExceptionTest() throws Exception {
603632

604633
try {
605634
RecommendationName name =
606-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
635+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
636+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
607637
client.getRecommendation(name);
608638
Assert.fail("No exception raised");
609639
} catch (InvalidArgumentException e) {
@@ -616,7 +646,7 @@ public void getRecommendationTest2() throws Exception {
616646
Recommendation expectedResponse =
617647
Recommendation.newBuilder()
618648
.setName(
619-
RecommendationName.of(
649+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
620650
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
621651
.toString())
622652
.setDescription("description-1724546052")
@@ -666,7 +696,7 @@ public void markRecommendationClaimedTest() throws Exception {
666696
Recommendation expectedResponse =
667697
Recommendation.newBuilder()
668698
.setName(
669-
RecommendationName.of(
699+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
670700
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
671701
.toString())
672702
.setDescription("description-1724546052")
@@ -682,7 +712,8 @@ public void markRecommendationClaimedTest() throws Exception {
682712
mockRecommender.addResponse(expectedResponse);
683713

684714
RecommendationName name =
685-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
715+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
716+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
686717
Map<String, String> stateMetadata = new HashMap<>();
687718
String etag = "etag3123477";
688719

@@ -710,7 +741,8 @@ public void markRecommendationClaimedExceptionTest() throws Exception {
710741

711742
try {
712743
RecommendationName name =
713-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
744+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
745+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
714746
Map<String, String> stateMetadata = new HashMap<>();
715747
String etag = "etag3123477";
716748
client.markRecommendationClaimed(name, stateMetadata, etag);
@@ -725,7 +757,7 @@ public void markRecommendationClaimedTest2() throws Exception {
725757
Recommendation expectedResponse =
726758
Recommendation.newBuilder()
727759
.setName(
728-
RecommendationName.of(
760+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
729761
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
730762
.toString())
731763
.setDescription("description-1724546052")
@@ -782,7 +814,7 @@ public void markRecommendationSucceededTest() throws Exception {
782814
Recommendation expectedResponse =
783815
Recommendation.newBuilder()
784816
.setName(
785-
RecommendationName.of(
817+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
786818
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
787819
.toString())
788820
.setDescription("description-1724546052")
@@ -798,7 +830,8 @@ public void markRecommendationSucceededTest() throws Exception {
798830
mockRecommender.addResponse(expectedResponse);
799831

800832
RecommendationName name =
801-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
833+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
834+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
802835
Map<String, String> stateMetadata = new HashMap<>();
803836
String etag = "etag3123477";
804837

@@ -826,7 +859,8 @@ public void markRecommendationSucceededExceptionTest() throws Exception {
826859

827860
try {
828861
RecommendationName name =
829-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
862+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
863+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
830864
Map<String, String> stateMetadata = new HashMap<>();
831865
String etag = "etag3123477";
832866
client.markRecommendationSucceeded(name, stateMetadata, etag);
@@ -841,7 +875,7 @@ public void markRecommendationSucceededTest2() throws Exception {
841875
Recommendation expectedResponse =
842876
Recommendation.newBuilder()
843877
.setName(
844-
RecommendationName.of(
878+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
845879
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
846880
.toString())
847881
.setDescription("description-1724546052")
@@ -898,7 +932,7 @@ public void markRecommendationFailedTest() throws Exception {
898932
Recommendation expectedResponse =
899933
Recommendation.newBuilder()
900934
.setName(
901-
RecommendationName.of(
935+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
902936
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
903937
.toString())
904938
.setDescription("description-1724546052")
@@ -914,7 +948,8 @@ public void markRecommendationFailedTest() throws Exception {
914948
mockRecommender.addResponse(expectedResponse);
915949

916950
RecommendationName name =
917-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
951+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
952+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
918953
Map<String, String> stateMetadata = new HashMap<>();
919954
String etag = "etag3123477";
920955

@@ -942,7 +977,8 @@ public void markRecommendationFailedExceptionTest() throws Exception {
942977

943978
try {
944979
RecommendationName name =
945-
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
980+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
981+
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
946982
Map<String, String> stateMetadata = new HashMap<>();
947983
String etag = "etag3123477";
948984
client.markRecommendationFailed(name, stateMetadata, etag);
@@ -957,7 +993,7 @@ public void markRecommendationFailedTest2() throws Exception {
957993
Recommendation expectedResponse =
958994
Recommendation.newBuilder()
959995
.setName(
960-
RecommendationName.of(
996+
RecommendationName.ofProjectLocationRecommenderRecommendationName(
961997
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
962998
.toString())
963999
.setDescription("description-1724546052")

0 commit comments

Comments
 (0)