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

Commit c867009

Browse files
revert: Add support for "billingAccounts" as another parent resource name for recommendations and insights APIs. (#386)
PiperOrigin-RevId: 347984439 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Dec 17 02:15:37 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: be40b52d80a2131a1b48f4720c4e8024167faad1 Source-Link: googleapis/googleapis@be40b52
1 parent e1a5d70 commit c867009

File tree

19 files changed

+248
-976
lines changed

19 files changed

+248
-976
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ public RecommenderStub getStub() {
153153
* formats:
154154
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
155155
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
156-
* INSIGHT_TYPE_ID refers to supported insight types:
157-
* https://cloud.google.com/recommender/docs/insights/insight-types.)
158156
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
159157
*/
160158
public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
@@ -174,8 +172,6 @@ public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
174172
* formats:
175173
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
176174
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
177-
* INSIGHT_TYPE_ID refers to supported insight types:
178-
* https://cloud.google.com/recommender/docs/insights/insight-types.)
179175
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
180176
*/
181177
public final ListInsightsPagedResponse listInsights(String parent) {
@@ -360,8 +356,6 @@ public final UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAccep
360356
* formats:
361357
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
362358
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
363-
* RECOMMENDER_ID refers to supported recommenders:
364-
* https://cloud.google.com/recommender/docs/recommenders.
365359
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
366360
*/
367361
public final ListRecommendationsPagedResponse listRecommendations(RecommenderName parent) {
@@ -381,8 +375,6 @@ public final ListRecommendationsPagedResponse listRecommendations(RecommenderNam
381375
* formats:
382376
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
383377
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
384-
* RECOMMENDER_ID refers to supported recommenders:
385-
* https://cloud.google.com/recommender/docs/recommenders.
386378
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
387379
*/
388380
public final ListRecommendationsPagedResponse listRecommendations(String parent) {
@@ -400,8 +392,6 @@ public final ListRecommendationsPagedResponse listRecommendations(String parent)
400392
* formats:
401393
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
402394
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
403-
* RECOMMENDER_ID refers to supported recommenders:
404-
* https://cloud.google.com/recommender/docs/recommenders.
405395
* @param filter Filter expression to restrict the recommendations returned. Supported filter
406396
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
407397
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -425,8 +415,6 @@ public final ListRecommendationsPagedResponse listRecommendations(
425415
* formats:
426416
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
427417
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
428-
* RECOMMENDER_ID refers to supported recommenders:
429-
* https://cloud.google.com/recommender/docs/recommenders.
430418
* @param filter Filter expression to restrict the recommendations returned. Supported filter
431419
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
432420
* @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: 30 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ public void listInsightsTest() throws Exception {
9595
.build();
9696
mockRecommender.addResponse(expectedResponse);
9797

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

102100
ListInsightsPagedResponse pagedListResponse = client.listInsights(parent);
103101

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

125123
try {
126-
InsightTypeName parent =
127-
InsightTypeName.ofProjectLocationInsightTypeName(
128-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
124+
InsightTypeName parent = InsightTypeName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
129125
client.listInsights(parent);
130126
Assert.fail("No exception raised");
131127
} catch (InvalidArgumentException e) {
@@ -182,9 +178,7 @@ public void getInsightTest() throws Exception {
182178
Insight expectedResponse =
183179
Insight.newBuilder()
184180
.setName(
185-
InsightName.ofProjectLocationInsightTypeInsightName(
186-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
187-
.toString())
181+
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
188182
.setDescription("description-1724546052")
189183
.addAllTargetResources(new ArrayList<String>())
190184
.setInsightSubtype("insightSubtype841535170")
@@ -197,9 +191,7 @@ public void getInsightTest() throws Exception {
197191
.build();
198192
mockRecommender.addResponse(expectedResponse);
199193

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

204196
Insight actualResponse = client.getInsight(name);
205197
Assert.assertEquals(expectedResponse, actualResponse);
@@ -221,9 +213,7 @@ public void getInsightExceptionTest() throws Exception {
221213
mockRecommender.addException(exception);
222214

223215
try {
224-
InsightName name =
225-
InsightName.ofProjectLocationInsightTypeInsightName(
226-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
216+
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
227217
client.getInsight(name);
228218
Assert.fail("No exception raised");
229219
} catch (InvalidArgumentException e) {
@@ -236,9 +226,7 @@ public void getInsightTest2() throws Exception {
236226
Insight expectedResponse =
237227
Insight.newBuilder()
238228
.setName(
239-
InsightName.ofProjectLocationInsightTypeInsightName(
240-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
241-
.toString())
229+
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
242230
.setDescription("description-1724546052")
243231
.addAllTargetResources(new ArrayList<String>())
244232
.setInsightSubtype("insightSubtype841535170")
@@ -286,9 +274,7 @@ public void markInsightAcceptedTest() throws Exception {
286274
Insight expectedResponse =
287275
Insight.newBuilder()
288276
.setName(
289-
InsightName.ofProjectLocationInsightTypeInsightName(
290-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
291-
.toString())
277+
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
292278
.setDescription("description-1724546052")
293279
.addAllTargetResources(new ArrayList<String>())
294280
.setInsightSubtype("insightSubtype841535170")
@@ -301,9 +287,7 @@ public void markInsightAcceptedTest() throws Exception {
301287
.build();
302288
mockRecommender.addResponse(expectedResponse);
303289

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

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

331315
try {
332-
InsightName name =
333-
InsightName.ofProjectLocationInsightTypeInsightName(
334-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
316+
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
335317
Map<String, String> stateMetadata = new HashMap<>();
336318
String etag = "etag3123477";
337319
client.markInsightAccepted(name, stateMetadata, etag);
@@ -346,9 +328,7 @@ public void markInsightAcceptedTest2() throws Exception {
346328
Insight expectedResponse =
347329
Insight.newBuilder()
348330
.setName(
349-
InsightName.ofProjectLocationInsightTypeInsightName(
350-
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
351-
.toString())
331+
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
352332
.setDescription("description-1724546052")
353333
.addAllTargetResources(new ArrayList<String>())
354334
.setInsightSubtype("insightSubtype841535170")
@@ -407,9 +387,7 @@ public void listRecommendationsTest() throws Exception {
407387
.build();
408388
mockRecommender.addResponse(expectedResponse);
409389

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

414392
ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);
415393

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

437415
try {
438-
RecommenderName parent =
439-
RecommenderName.ofProjectLocationRecommenderName(
440-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
416+
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
441417
client.listRecommendations(parent);
442418
Assert.fail("No exception raised");
443419
} catch (InvalidArgumentException e) {
@@ -499,9 +475,7 @@ public void listRecommendationsTest3() throws Exception {
499475
.build();
500476
mockRecommender.addResponse(expectedResponse);
501477

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

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

531505
try {
532-
RecommenderName parent =
533-
RecommenderName.ofProjectLocationRecommenderName(
534-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
506+
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
535507
String filter = "filter-1274492040";
536508
client.listRecommendations(parent, filter);
537509
Assert.fail("No exception raised");
@@ -592,7 +564,7 @@ public void getRecommendationTest() throws Exception {
592564
Recommendation expectedResponse =
593565
Recommendation.newBuilder()
594566
.setName(
595-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
567+
RecommendationName.of(
596568
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
597569
.toString())
598570
.setDescription("description-1724546052")
@@ -608,8 +580,7 @@ public void getRecommendationTest() throws Exception {
608580
mockRecommender.addResponse(expectedResponse);
609581

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

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

633604
try {
634605
RecommendationName name =
635-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
636-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
606+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
637607
client.getRecommendation(name);
638608
Assert.fail("No exception raised");
639609
} catch (InvalidArgumentException e) {
@@ -646,7 +616,7 @@ public void getRecommendationTest2() throws Exception {
646616
Recommendation expectedResponse =
647617
Recommendation.newBuilder()
648618
.setName(
649-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
619+
RecommendationName.of(
650620
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
651621
.toString())
652622
.setDescription("description-1724546052")
@@ -696,7 +666,7 @@ public void markRecommendationClaimedTest() throws Exception {
696666
Recommendation expectedResponse =
697667
Recommendation.newBuilder()
698668
.setName(
699-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
669+
RecommendationName.of(
700670
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
701671
.toString())
702672
.setDescription("description-1724546052")
@@ -712,8 +682,7 @@ public void markRecommendationClaimedTest() throws Exception {
712682
mockRecommender.addResponse(expectedResponse);
713683

714684
RecommendationName name =
715-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
716-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
685+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
717686
Map<String, String> stateMetadata = new HashMap<>();
718687
String etag = "etag3123477";
719688

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

742711
try {
743712
RecommendationName name =
744-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
745-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
713+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
746714
Map<String, String> stateMetadata = new HashMap<>();
747715
String etag = "etag3123477";
748716
client.markRecommendationClaimed(name, stateMetadata, etag);
@@ -757,7 +725,7 @@ public void markRecommendationClaimedTest2() throws Exception {
757725
Recommendation expectedResponse =
758726
Recommendation.newBuilder()
759727
.setName(
760-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
728+
RecommendationName.of(
761729
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
762730
.toString())
763731
.setDescription("description-1724546052")
@@ -814,7 +782,7 @@ public void markRecommendationSucceededTest() throws Exception {
814782
Recommendation expectedResponse =
815783
Recommendation.newBuilder()
816784
.setName(
817-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
785+
RecommendationName.of(
818786
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
819787
.toString())
820788
.setDescription("description-1724546052")
@@ -830,8 +798,7 @@ public void markRecommendationSucceededTest() throws Exception {
830798
mockRecommender.addResponse(expectedResponse);
831799

832800
RecommendationName name =
833-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
834-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
801+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
835802
Map<String, String> stateMetadata = new HashMap<>();
836803
String etag = "etag3123477";
837804

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

860827
try {
861828
RecommendationName name =
862-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
863-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
829+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
864830
Map<String, String> stateMetadata = new HashMap<>();
865831
String etag = "etag3123477";
866832
client.markRecommendationSucceeded(name, stateMetadata, etag);
@@ -875,7 +841,7 @@ public void markRecommendationSucceededTest2() throws Exception {
875841
Recommendation expectedResponse =
876842
Recommendation.newBuilder()
877843
.setName(
878-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
844+
RecommendationName.of(
879845
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
880846
.toString())
881847
.setDescription("description-1724546052")
@@ -932,7 +898,7 @@ public void markRecommendationFailedTest() throws Exception {
932898
Recommendation expectedResponse =
933899
Recommendation.newBuilder()
934900
.setName(
935-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
901+
RecommendationName.of(
936902
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
937903
.toString())
938904
.setDescription("description-1724546052")
@@ -948,8 +914,7 @@ public void markRecommendationFailedTest() throws Exception {
948914
mockRecommender.addResponse(expectedResponse);
949915

950916
RecommendationName name =
951-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
952-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
917+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
953918
Map<String, String> stateMetadata = new HashMap<>();
954919
String etag = "etag3123477";
955920

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

978943
try {
979944
RecommendationName name =
980-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
981-
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
945+
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
982946
Map<String, String> stateMetadata = new HashMap<>();
983947
String etag = "etag3123477";
984948
client.markRecommendationFailed(name, stateMetadata, etag);
@@ -993,7 +957,7 @@ public void markRecommendationFailedTest2() throws Exception {
993957
Recommendation expectedResponse =
994958
Recommendation.newBuilder()
995959
.setName(
996-
RecommendationName.ofProjectLocationRecommenderRecommendationName(
960+
RecommendationName.of(
997961
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
998962
.toString())
999963
.setDescription("description-1724546052")

0 commit comments

Comments
 (0)