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

Commit

Permalink
revert: Add support for "billingAccounts" as another parent resource …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
yoshi-automation committed Jan 6, 2021
1 parent e1a5d70 commit c867009
Show file tree
Hide file tree
Showing 19 changed files with 248 additions and 976 deletions.
Expand Up @@ -153,8 +153,6 @@ public RecommenderStub getStub() {
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* INSIGHT_TYPE_ID refers to supported insight types:
* https://cloud.google.com/recommender/docs/insights/insight-types.)
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
Expand All @@ -174,8 +172,6 @@ public final ListInsightsPagedResponse listInsights(InsightTypeName parent) {
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* INSIGHT_TYPE_ID refers to supported insight types:
* https://cloud.google.com/recommender/docs/insights/insight-types.)
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListInsightsPagedResponse listInsights(String parent) {
Expand Down Expand Up @@ -360,8 +356,6 @@ public final UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAccep
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* RECOMMENDER_ID refers to supported recommenders:
* https://cloud.google.com/recommender/docs/recommenders.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListRecommendationsPagedResponse listRecommendations(RecommenderName parent) {
Expand All @@ -381,8 +375,6 @@ public final ListRecommendationsPagedResponse listRecommendations(RecommenderNam
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* RECOMMENDER_ID refers to supported recommenders:
* https://cloud.google.com/recommender/docs/recommenders.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListRecommendationsPagedResponse listRecommendations(String parent) {
Expand All @@ -400,8 +392,6 @@ public final ListRecommendationsPagedResponse listRecommendations(String parent)
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* RECOMMENDER_ID refers to supported recommenders:
* https://cloud.google.com/recommender/docs/recommenders.
* @param filter Filter expression to restrict the recommendations returned. Supported filter
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -425,8 +415,6 @@ public final ListRecommendationsPagedResponse listRecommendations(
* formats:
* <p>1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
* <p>LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/
* RECOMMENDER_ID refers to supported recommenders:
* https://cloud.google.com/recommender/docs/recommenders.
* @param filter Filter expression to restrict the recommendations returned. Supported filter
* fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand Down
Expand Up @@ -95,9 +95,7 @@ public void listInsightsTest() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

InsightTypeName parent =
InsightTypeName.ofProjectLocationInsightTypeName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
InsightTypeName parent = InsightTypeName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");

ListInsightsPagedResponse pagedListResponse = client.listInsights(parent);

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

try {
InsightTypeName parent =
InsightTypeName.ofProjectLocationInsightTypeName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
InsightTypeName parent = InsightTypeName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]");
client.listInsights(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand Down Expand Up @@ -182,9 +178,7 @@ public void getInsightTest() throws Exception {
Insight expectedResponse =
Insight.newBuilder()
.setName(
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
.toString())
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
.setDescription("description-1724546052")
.addAllTargetResources(new ArrayList<String>())
.setInsightSubtype("insightSubtype841535170")
Expand All @@ -197,9 +191,7 @@ public void getInsightTest() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

InsightName name =
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");

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

try {
InsightName name =
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
client.getInsight(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand All @@ -236,9 +226,7 @@ public void getInsightTest2() throws Exception {
Insight expectedResponse =
Insight.newBuilder()
.setName(
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
.toString())
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
.setDescription("description-1724546052")
.addAllTargetResources(new ArrayList<String>())
.setInsightSubtype("insightSubtype841535170")
Expand Down Expand Up @@ -286,9 +274,7 @@ public void markInsightAcceptedTest() throws Exception {
Insight expectedResponse =
Insight.newBuilder()
.setName(
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
.toString())
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
.setDescription("description-1724546052")
.addAllTargetResources(new ArrayList<String>())
.setInsightSubtype("insightSubtype841535170")
Expand All @@ -301,9 +287,7 @@ public void markInsightAcceptedTest() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

InsightName name =
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";

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

try {
InsightName name =
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";
client.markInsightAccepted(name, stateMetadata, etag);
Expand All @@ -346,9 +328,7 @@ public void markInsightAcceptedTest2() throws Exception {
Insight expectedResponse =
Insight.newBuilder()
.setName(
InsightName.ofProjectLocationInsightTypeInsightName(
"[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]")
.toString())
InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]").toString())
.setDescription("description-1724546052")
.addAllTargetResources(new ArrayList<String>())
.setInsightSubtype("insightSubtype841535170")
Expand Down Expand Up @@ -407,9 +387,7 @@ public void listRecommendationsTest() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

RecommenderName parent =
RecommenderName.ofProjectLocationRecommenderName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");

ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);

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

try {
RecommenderName parent =
RecommenderName.ofProjectLocationRecommenderName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
client.listRecommendations(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand Down Expand Up @@ -499,9 +475,7 @@ public void listRecommendationsTest3() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

RecommenderName parent =
RecommenderName.ofProjectLocationRecommenderName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
String filter = "filter-1274492040";

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

try {
RecommenderName parent =
RecommenderName.ofProjectLocationRecommenderName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
RecommenderName parent = RecommenderName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
String filter = "filter-1274492040";
client.listRecommendations(parent, filter);
Assert.fail("No exception raised");
Expand Down Expand Up @@ -592,7 +564,7 @@ public void getRecommendationTest() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand All @@ -608,8 +580,7 @@ public void getRecommendationTest() throws Exception {
mockRecommender.addResponse(expectedResponse);

RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");

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

try {
RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
client.getRecommendation(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand All @@ -646,7 +616,7 @@ public void getRecommendationTest2() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand Down Expand Up @@ -696,7 +666,7 @@ public void markRecommendationClaimedTest() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand All @@ -712,8 +682,7 @@ public void markRecommendationClaimedTest() throws Exception {
mockRecommender.addResponse(expectedResponse);

RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";

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

try {
RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";
client.markRecommendationClaimed(name, stateMetadata, etag);
Expand All @@ -757,7 +725,7 @@ public void markRecommendationClaimedTest2() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand Down Expand Up @@ -814,7 +782,7 @@ public void markRecommendationSucceededTest() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand All @@ -830,8 +798,7 @@ public void markRecommendationSucceededTest() throws Exception {
mockRecommender.addResponse(expectedResponse);

RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";

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

try {
RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";
client.markRecommendationSucceeded(name, stateMetadata, etag);
Expand All @@ -875,7 +841,7 @@ public void markRecommendationSucceededTest2() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand Down Expand Up @@ -932,7 +898,7 @@ public void markRecommendationFailedTest() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand All @@ -948,8 +914,7 @@ public void markRecommendationFailedTest() throws Exception {
mockRecommender.addResponse(expectedResponse);

RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";

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

try {
RecommendationName name =
RecommendationName.ofProjectLocationRecommenderRecommendationName(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
Map<String, String> stateMetadata = new HashMap<>();
String etag = "etag3123477";
client.markRecommendationFailed(name, stateMetadata, etag);
Expand All @@ -993,7 +957,7 @@ public void markRecommendationFailedTest2() throws Exception {
Recommendation expectedResponse =
Recommendation.newBuilder()
.setName(
RecommendationName.ofProjectLocationRecommenderRecommendationName(
RecommendationName.of(
"[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]")
.toString())
.setDescription("description-1724546052")
Expand Down

0 comments on commit c867009

Please sign in to comment.