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

Commit

Permalink
Merge 4e788cf into d44f21c
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Feb 5, 2021
2 parents d44f21c + 4e788cf commit e49ac6a
Show file tree
Hide file tree
Showing 29 changed files with 3,052 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ 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 @@ -171,6 +173,8 @@ 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 @@ -355,6 +359,8 @@ 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 @@ -374,6 +380,8 @@ 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 @@ -391,6 +399,8 @@ 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 @@ -414,6 +424,8 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public void listInsightsTest() throws Exception {
.build();
mockRecommender.addResponse(expectedResponse);

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

ListInsightsPagedResponse pagedListResponse = client.listInsights(parent);

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

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

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

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

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

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

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

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

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

ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit e49ac6a

Please sign in to comment.