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

Commit

Permalink
feat: adds methods for interacting with insights (#229)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/8f9b2ee6-9eab-4b87-867c-98d5f8fc5313/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 319247865
Source-Link: googleapis/googleapis@5202cfe
  • Loading branch information
yoshi-automation committed Jul 8, 2020
1 parent 2a75f21 commit bec782f
Show file tree
Hide file tree
Showing 34 changed files with 14,329 additions and 250 deletions.

Large diffs are not rendered by default.

Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.recommender.v1;

import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse;
import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse;

import com.google.api.core.ApiFunction;
Expand Down Expand Up @@ -48,16 +49,16 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of getRecommendation to 30 seconds:
* <p>For example, to set the total timeout of getInsight to 30 seconds:
*
* <pre>
* <code>
* RecommenderSettings.Builder recommenderSettingsBuilder =
* RecommenderSettings.newBuilder();
* recommenderSettingsBuilder
* .getRecommendationSettings()
* .getInsightSettings()
* .setRetrySettings(
* recommenderSettingsBuilder.getRecommendationSettings().getRetrySettings().toBuilder()
* recommenderSettingsBuilder.getInsightSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* RecommenderSettings recommenderSettings = recommenderSettingsBuilder.build();
Expand All @@ -67,6 +68,22 @@
@Generated("by gapic-generator")
@BetaApi
public class RecommenderSettings extends ClientSettings<RecommenderSettings> {
/** Returns the object with the settings used for calls to listInsights. */
public PagedCallSettings<ListInsightsRequest, ListInsightsResponse, ListInsightsPagedResponse>
listInsightsSettings() {
return ((RecommenderStubSettings) getStubSettings()).listInsightsSettings();
}

/** Returns the object with the settings used for calls to getInsight. */
public UnaryCallSettings<GetInsightRequest, Insight> getInsightSettings() {
return ((RecommenderStubSettings) getStubSettings()).getInsightSettings();
}

/** Returns the object with the settings used for calls to markInsightAccepted. */
public UnaryCallSettings<MarkInsightAcceptedRequest, Insight> markInsightAcceptedSettings() {
return ((RecommenderStubSettings) getStubSettings()).markInsightAcceptedSettings();
}

/** Returns the object with the settings used for calls to listRecommendations. */
public PagedCallSettings<
ListRecommendationsRequest, ListRecommendationsResponse, ListRecommendationsPagedResponse>
Expand Down Expand Up @@ -193,6 +210,24 @@ public Builder applyToAllUnaryMethods(
return this;
}

/** Returns the builder for the settings used for calls to listInsights. */
public PagedCallSettings.Builder<
ListInsightsRequest, ListInsightsResponse, ListInsightsPagedResponse>
listInsightsSettings() {
return getStubSettingsBuilder().listInsightsSettings();
}

/** Returns the builder for the settings used for calls to getInsight. */
public UnaryCallSettings.Builder<GetInsightRequest, Insight> getInsightSettings() {
return getStubSettingsBuilder().getInsightSettings();
}

/** Returns the builder for the settings used for calls to markInsightAccepted. */
public UnaryCallSettings.Builder<MarkInsightAcceptedRequest, Insight>
markInsightAcceptedSettings() {
return getStubSettingsBuilder().markInsightAcceptedSettings();
}

/** Returns the builder for the settings used for calls to listRecommendations. */
public PagedCallSettings.Builder<
ListRecommendationsRequest,
Expand Down
Expand Up @@ -21,18 +21,18 @@
*
* <p>================= RecommenderClient =================
*
* <p>Service Description: Provides recommendations for cloud customers for various categories like
* performance optimization, cost savings, reliability, feature discovery, etc. These
* recommendations are generated automatically based on analysis of user resources, configuration
* and monitoring metrics.
* <p>Service Description: Provides insights and recommendations for cloud customers for various
* categories like performance optimization, cost savings, reliability, feature discovery, etc.
* Insights and recommendations are generated automatically based on analysis of user resources,
* configuration and monitoring metrics.
*
* <p>Sample for RecommenderClient:
*
* <pre>
* <code>
* try (RecommenderClient recommenderClient = RecommenderClient.create()) {
* RecommendationName name = RecommendationName.of("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]");
* Recommendation response = recommenderClient.getRecommendation(name);
* InsightName name = InsightName.of("[PROJECT]", "[LOCATION]", "[INSIGHT_TYPE]", "[INSIGHT]");
* Insight response = recommenderClient.getInsight(name);
* }
* </code>
* </pre>
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.recommender.v1.stub;

import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse;
import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse;

import com.google.api.core.BetaApi;
Expand All @@ -25,9 +26,14 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.recommender.v1.GetInsightRequest;
import com.google.cloud.recommender.v1.GetRecommendationRequest;
import com.google.cloud.recommender.v1.Insight;
import com.google.cloud.recommender.v1.ListInsightsRequest;
import com.google.cloud.recommender.v1.ListInsightsResponse;
import com.google.cloud.recommender.v1.ListRecommendationsRequest;
import com.google.cloud.recommender.v1.ListRecommendationsResponse;
import com.google.cloud.recommender.v1.MarkInsightAcceptedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationClaimedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest;
Expand All @@ -50,6 +56,31 @@
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public class GrpcRecommenderStub extends RecommenderStub {

private static final MethodDescriptor<ListInsightsRequest, ListInsightsResponse>
listInsightsMethodDescriptor =
MethodDescriptor.<ListInsightsRequest, ListInsightsResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/ListInsights")
.setRequestMarshaller(ProtoUtils.marshaller(ListInsightsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListInsightsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<GetInsightRequest, Insight> getInsightMethodDescriptor =
MethodDescriptor.<GetInsightRequest, Insight>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/GetInsight")
.setRequestMarshaller(ProtoUtils.marshaller(GetInsightRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Insight.getDefaultInstance()))
.build();
private static final MethodDescriptor<MarkInsightAcceptedRequest, Insight>
markInsightAcceptedMethodDescriptor =
MethodDescriptor.<MarkInsightAcceptedRequest, Insight>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/MarkInsightAccepted")
.setRequestMarshaller(
ProtoUtils.marshaller(MarkInsightAcceptedRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Insight.getDefaultInstance()))
.build();
private static final MethodDescriptor<ListRecommendationsRequest, ListRecommendationsResponse>
listRecommendationsMethodDescriptor =
MethodDescriptor.<ListRecommendationsRequest, ListRecommendationsResponse>newBuilder()
Expand Down Expand Up @@ -101,6 +132,11 @@ public class GrpcRecommenderStub extends RecommenderStub {

private final BackgroundResource backgroundResources;

private final UnaryCallable<ListInsightsRequest, ListInsightsResponse> listInsightsCallable;
private final UnaryCallable<ListInsightsRequest, ListInsightsPagedResponse>
listInsightsPagedCallable;
private final UnaryCallable<GetInsightRequest, Insight> getInsightCallable;
private final UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAcceptedCallable;
private final UnaryCallable<ListRecommendationsRequest, ListRecommendationsResponse>
listRecommendationsCallable;
private final UnaryCallable<ListRecommendationsRequest, ListRecommendationsPagedResponse>
Expand Down Expand Up @@ -152,6 +188,45 @@ protected GrpcRecommenderStub(
throws IOException {
this.callableFactory = callableFactory;

GrpcCallSettings<ListInsightsRequest, ListInsightsResponse> listInsightsTransportSettings =
GrpcCallSettings.<ListInsightsRequest, ListInsightsResponse>newBuilder()
.setMethodDescriptor(listInsightsMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<ListInsightsRequest>() {
@Override
public Map<String, String> extract(ListInsightsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("parent", String.valueOf(request.getParent()));
return params.build();
}
})
.build();
GrpcCallSettings<GetInsightRequest, Insight> getInsightTransportSettings =
GrpcCallSettings.<GetInsightRequest, Insight>newBuilder()
.setMethodDescriptor(getInsightMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetInsightRequest>() {
@Override
public Map<String, String> extract(GetInsightRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<MarkInsightAcceptedRequest, Insight> markInsightAcceptedTransportSettings =
GrpcCallSettings.<MarkInsightAcceptedRequest, Insight>newBuilder()
.setMethodDescriptor(markInsightAcceptedMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<MarkInsightAcceptedRequest>() {
@Override
public Map<String, String> extract(MarkInsightAcceptedRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<ListRecommendationsRequest, ListRecommendationsResponse>
listRecommendationsTransportSettings =
GrpcCallSettings.<ListRecommendationsRequest, ListRecommendationsResponse>newBuilder()
Expand Down Expand Up @@ -223,6 +298,20 @@ public Map<String, String> extract(MarkRecommendationFailedRequest request) {
})
.build();

this.listInsightsCallable =
callableFactory.createUnaryCallable(
listInsightsTransportSettings, settings.listInsightsSettings(), clientContext);
this.listInsightsPagedCallable =
callableFactory.createPagedCallable(
listInsightsTransportSettings, settings.listInsightsSettings(), clientContext);
this.getInsightCallable =
callableFactory.createUnaryCallable(
getInsightTransportSettings, settings.getInsightSettings(), clientContext);
this.markInsightAcceptedCallable =
callableFactory.createUnaryCallable(
markInsightAcceptedTransportSettings,
settings.markInsightAcceptedSettings(),
clientContext);
this.listRecommendationsCallable =
callableFactory.createUnaryCallable(
listRecommendationsTransportSettings,
Expand Down Expand Up @@ -257,6 +346,22 @@ public Map<String, String> extract(MarkRecommendationFailedRequest request) {
backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}

public UnaryCallable<ListInsightsRequest, ListInsightsPagedResponse> listInsightsPagedCallable() {
return listInsightsPagedCallable;
}

public UnaryCallable<ListInsightsRequest, ListInsightsResponse> listInsightsCallable() {
return listInsightsCallable;
}

public UnaryCallable<GetInsightRequest, Insight> getInsightCallable() {
return getInsightCallable;
}

public UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAcceptedCallable() {
return markInsightAcceptedCallable;
}

public UnaryCallable<ListRecommendationsRequest, ListRecommendationsPagedResponse>
listRecommendationsPagedCallable() {
return listRecommendationsPagedCallable;
Expand Down
Expand Up @@ -15,14 +15,20 @@
*/
package com.google.cloud.recommender.v1.stub;

import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse;
import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse;

import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.recommender.v1.GetInsightRequest;
import com.google.cloud.recommender.v1.GetRecommendationRequest;
import com.google.cloud.recommender.v1.Insight;
import com.google.cloud.recommender.v1.ListInsightsRequest;
import com.google.cloud.recommender.v1.ListInsightsResponse;
import com.google.cloud.recommender.v1.ListRecommendationsRequest;
import com.google.cloud.recommender.v1.ListRecommendationsResponse;
import com.google.cloud.recommender.v1.MarkInsightAcceptedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationClaimedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest;
Expand All @@ -39,6 +45,22 @@
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public abstract class RecommenderStub implements BackgroundResource {

public UnaryCallable<ListInsightsRequest, ListInsightsPagedResponse> listInsightsPagedCallable() {
throw new UnsupportedOperationException("Not implemented: listInsightsPagedCallable()");
}

public UnaryCallable<ListInsightsRequest, ListInsightsResponse> listInsightsCallable() {
throw new UnsupportedOperationException("Not implemented: listInsightsCallable()");
}

public UnaryCallable<GetInsightRequest, Insight> getInsightCallable() {
throw new UnsupportedOperationException("Not implemented: getInsightCallable()");
}

public UnaryCallable<MarkInsightAcceptedRequest, Insight> markInsightAcceptedCallable() {
throw new UnsupportedOperationException("Not implemented: markInsightAcceptedCallable()");
}

public UnaryCallable<ListRecommendationsRequest, ListRecommendationsPagedResponse>
listRecommendationsPagedCallable() {
throw new UnsupportedOperationException("Not implemented: listRecommendationsPagedCallable()");
Expand Down

0 comments on commit bec782f

Please sign in to comment.