Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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 @@ -172,6 +174,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 @@ -356,6 +360,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.
* @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 @@ -379,6 +385,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]");
String filter = "filter-1274492040";

ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent, filter);
Expand Down Expand Up @@ -415,7 +437,9 @@ public void listRecommendationsExceptionTest() 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 @@ -476,7 +500,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 @@ -492,7 +516,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 @@ -515,7 +540,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 @@ -528,7 +554,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 @@ -578,7 +604,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 @@ -594,7 +620,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 @@ -622,7 +649,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 @@ -637,7 +665,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 @@ -694,7 +722,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 @@ -710,7 +738,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 @@ -738,7 +767,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 @@ -753,7 +783,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 @@ -810,7 +840,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 @@ -826,7 +856,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 @@ -854,7 +885,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 @@ -869,7 +901,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
Loading