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

Commit

Permalink
feat: Implement configurable recommenders and update .bazel files (#778)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 457101611

Source-Link: googleapis/googleapis@c13c88b

Source-Link: https://github.com/googleapis/googleapis-gen/commit/4eb3716b18c24627d23a5998c1d3f95edcc897c3
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGViMzcxNmIxOGMyNDYyN2QyM2E1OTk4YzFkM2Y5NWVkY2M4OTdjMyJ9
  • Loading branch information
gcf-owl-bot[bot] authored Jun 27, 2022
1 parent fb5871b commit c55e269
Show file tree
Hide file tree
Showing 55 changed files with 15,367 additions and 304 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ public UnaryCallSettings<GetRecommendationRequest, Recommendation> getRecommenda
return ((RecommenderStubSettings) getStubSettings()).markRecommendationFailedSettings();
}

/** Returns the object with the settings used for calls to getRecommenderConfig. */
public UnaryCallSettings<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigSettings() {
return ((RecommenderStubSettings) getStubSettings()).getRecommenderConfigSettings();
}

/** Returns the object with the settings used for calls to updateRecommenderConfig. */
public UnaryCallSettings<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigSettings() {
return ((RecommenderStubSettings) getStubSettings()).updateRecommenderConfigSettings();
}

/** Returns the object with the settings used for calls to getInsightTypeConfig. */
public UnaryCallSettings<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigSettings() {
return ((RecommenderStubSettings) getStubSettings()).getInsightTypeConfigSettings();
}

/** Returns the object with the settings used for calls to updateInsightTypeConfig. */
public UnaryCallSettings<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigSettings() {
return ((RecommenderStubSettings) getStubSettings()).updateInsightTypeConfigSettings();
}

public static final RecommenderSettings create(RecommenderStubSettings stub) throws IOException {
return new RecommenderSettings.Builder(stub.toBuilder()).build();
}
Expand Down Expand Up @@ -283,6 +307,30 @@ public UnaryCallSettings.Builder<GetInsightRequest, Insight> getInsightSettings(
return getStubSettingsBuilder().markRecommendationFailedSettings();
}

/** Returns the builder for the settings used for calls to getRecommenderConfig. */
public UnaryCallSettings.Builder<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigSettings() {
return getStubSettingsBuilder().getRecommenderConfigSettings();
}

/** Returns the builder for the settings used for calls to updateRecommenderConfig. */
public UnaryCallSettings.Builder<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigSettings() {
return getStubSettingsBuilder().updateRecommenderConfigSettings();
}

/** Returns the builder for the settings used for calls to getInsightTypeConfig. */
public UnaryCallSettings.Builder<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigSettings() {
return getStubSettingsBuilder().getInsightTypeConfigSettings();
}

/** Returns the builder for the settings used for calls to updateInsightTypeConfig. */
public UnaryCallSettings.Builder<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigSettings() {
return getStubSettingsBuilder().updateInsightTypeConfigSettings();
}

@Override
public RecommenderSettings build() throws IOException {
return new RecommenderSettings(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
"GetInsight": {
"methods": ["getInsight", "getInsight", "getInsight", "getInsightCallable"]
},
"GetInsightTypeConfig": {
"methods": ["getInsightTypeConfig", "getInsightTypeConfig", "getInsightTypeConfig", "getInsightTypeConfigCallable"]
},
"GetRecommendation": {
"methods": ["getRecommendation", "getRecommendation", "getRecommendation", "getRecommendationCallable"]
},
"GetRecommenderConfig": {
"methods": ["getRecommenderConfig", "getRecommenderConfig", "getRecommenderConfig", "getRecommenderConfigCallable"]
},
"ListInsights": {
"methods": ["listInsights", "listInsights", "listInsights", "listInsightsPagedCallable", "listInsightsCallable"]
},
Expand All @@ -33,6 +39,12 @@
},
"MarkRecommendationSucceeded": {
"methods": ["markRecommendationSucceeded", "markRecommendationSucceeded", "markRecommendationSucceeded", "markRecommendationSucceededCallable"]
},
"UpdateInsightTypeConfig": {
"methods": ["updateInsightTypeConfig", "updateInsightTypeConfig", "updateInsightTypeConfigCallable"]
},
"UpdateRecommenderConfig": {
"methods": ["updateRecommenderConfig", "updateRecommenderConfig", "updateRecommenderConfigCallable"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.recommender.v1.GetInsightRequest;
import com.google.cloud.recommender.v1.GetInsightTypeConfigRequest;
import com.google.cloud.recommender.v1.GetRecommendationRequest;
import com.google.cloud.recommender.v1.GetRecommenderConfigRequest;
import com.google.cloud.recommender.v1.Insight;
import com.google.cloud.recommender.v1.InsightTypeConfig;
import com.google.cloud.recommender.v1.ListInsightsRequest;
import com.google.cloud.recommender.v1.ListInsightsResponse;
import com.google.cloud.recommender.v1.ListRecommendationsRequest;
Expand All @@ -37,6 +40,9 @@
import com.google.cloud.recommender.v1.MarkRecommendationFailedRequest;
import com.google.cloud.recommender.v1.MarkRecommendationSucceededRequest;
import com.google.cloud.recommender.v1.Recommendation;
import com.google.cloud.recommender.v1.RecommenderConfig;
import com.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest;
import com.google.cloud.recommender.v1.UpdateRecommenderConfigRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.stub.GrpcOperationsStub;
import io.grpc.MethodDescriptor;
Expand Down Expand Up @@ -134,6 +140,46 @@ public class GrpcRecommenderStub extends RecommenderStub {
.setResponseMarshaller(ProtoUtils.marshaller(Recommendation.getDefaultInstance()))
.build();

private static final MethodDescriptor<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigMethodDescriptor =
MethodDescriptor.<GetRecommenderConfigRequest, RecommenderConfig>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/GetRecommenderConfig")
.setRequestMarshaller(
ProtoUtils.marshaller(GetRecommenderConfigRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(RecommenderConfig.getDefaultInstance()))
.build();

private static final MethodDescriptor<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigMethodDescriptor =
MethodDescriptor.<UpdateRecommenderConfigRequest, RecommenderConfig>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/UpdateRecommenderConfig")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateRecommenderConfigRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(RecommenderConfig.getDefaultInstance()))
.build();

private static final MethodDescriptor<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigMethodDescriptor =
MethodDescriptor.<GetInsightTypeConfigRequest, InsightTypeConfig>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/GetInsightTypeConfig")
.setRequestMarshaller(
ProtoUtils.marshaller(GetInsightTypeConfigRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(InsightTypeConfig.getDefaultInstance()))
.build();

private static final MethodDescriptor<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigMethodDescriptor =
MethodDescriptor.<UpdateInsightTypeConfigRequest, InsightTypeConfig>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.recommender.v1.Recommender/UpdateInsightTypeConfig")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateInsightTypeConfigRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(InsightTypeConfig.getDefaultInstance()))
.build();

private final UnaryCallable<ListInsightsRequest, ListInsightsResponse> listInsightsCallable;
private final UnaryCallable<ListInsightsRequest, ListInsightsPagedResponse>
listInsightsPagedCallable;
Expand All @@ -150,6 +196,14 @@ public class GrpcRecommenderStub extends RecommenderStub {
markRecommendationSucceededCallable;
private final UnaryCallable<MarkRecommendationFailedRequest, Recommendation>
markRecommendationFailedCallable;
private final UnaryCallable<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigCallable;
private final UnaryCallable<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigCallable;
private final UnaryCallable<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigCallable;
private final UnaryCallable<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigCallable;

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
Expand Down Expand Up @@ -277,6 +331,54 @@ protected GrpcRecommenderStub(
return params.build();
})
.build();
GrpcCallSettings<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigTransportSettings =
GrpcCallSettings.<GetRecommenderConfigRequest, RecommenderConfig>newBuilder()
.setMethodDescriptor(getRecommenderConfigMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
})
.build();
GrpcCallSettings<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigTransportSettings =
GrpcCallSettings.<UpdateRecommenderConfigRequest, RecommenderConfig>newBuilder()
.setMethodDescriptor(updateRecommenderConfigMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put(
"recommender_config.name",
String.valueOf(request.getRecommenderConfig().getName()));
return params.build();
})
.build();
GrpcCallSettings<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigTransportSettings =
GrpcCallSettings.<GetInsightTypeConfigRequest, InsightTypeConfig>newBuilder()
.setMethodDescriptor(getInsightTypeConfigMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
})
.build();
GrpcCallSettings<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigTransportSettings =
GrpcCallSettings.<UpdateInsightTypeConfigRequest, InsightTypeConfig>newBuilder()
.setMethodDescriptor(updateInsightTypeConfigMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put(
"insight_type_config.name",
String.valueOf(request.getInsightTypeConfig().getName()));
return params.build();
})
.build();

this.listInsightsCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -322,6 +424,26 @@ protected GrpcRecommenderStub(
markRecommendationFailedTransportSettings,
settings.markRecommendationFailedSettings(),
clientContext);
this.getRecommenderConfigCallable =
callableFactory.createUnaryCallable(
getRecommenderConfigTransportSettings,
settings.getRecommenderConfigSettings(),
clientContext);
this.updateRecommenderConfigCallable =
callableFactory.createUnaryCallable(
updateRecommenderConfigTransportSettings,
settings.updateRecommenderConfigSettings(),
clientContext);
this.getInsightTypeConfigCallable =
callableFactory.createUnaryCallable(
getInsightTypeConfigTransportSettings,
settings.getInsightTypeConfigSettings(),
clientContext);
this.updateInsightTypeConfigCallable =
callableFactory.createUnaryCallable(
updateInsightTypeConfigTransportSettings,
settings.updateInsightTypeConfigSettings(),
clientContext);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
Expand Down Expand Up @@ -386,6 +508,30 @@ public UnaryCallable<GetRecommendationRequest, Recommendation> getRecommendation
return markRecommendationFailedCallable;
}

@Override
public UnaryCallable<GetRecommenderConfigRequest, RecommenderConfig>
getRecommenderConfigCallable() {
return getRecommenderConfigCallable;
}

@Override
public UnaryCallable<UpdateRecommenderConfigRequest, RecommenderConfig>
updateRecommenderConfigCallable() {
return updateRecommenderConfigCallable;
}

@Override
public UnaryCallable<GetInsightTypeConfigRequest, InsightTypeConfig>
getInsightTypeConfigCallable() {
return getInsightTypeConfigCallable;
}

@Override
public UnaryCallable<UpdateInsightTypeConfigRequest, InsightTypeConfig>
updateInsightTypeConfigCallable() {
return updateInsightTypeConfigCallable;
}

@Override
public final void close() {
try {
Expand Down
Loading

0 comments on commit c55e269

Please sign in to comment.