use of com.google.api.codegen.viewmodel.ApiCallSettingsView in project toolkit by googleapis.
the class ApiCallableTransformer method generateApiCallableSettings.
public List<ApiCallSettingsView> generateApiCallableSettings(MethodContext context) {
List<ApiCallSettingsView> settings = new ArrayList<>();
MethodConfig methodConfig = context.getMethodConfig();
if (methodConfig.isGrpcStreaming()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.of(methodConfig.getGrpcStreamingType())));
} else if (methodConfig.isPageStreaming()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.PagedApiCallable));
} else if (methodConfig.isBatching()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.BatchingApiCallable));
} else if (methodConfig.isLongRunningOperation()) {
if (context.getFeatureConfig().enableRawOperationCallSettings()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
}
settings.add(generateApiCallableSettings(context, ApiCallableImplType.OperationApiCallable));
} else {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
}
return settings;
}
use of com.google.api.codegen.viewmodel.ApiCallSettingsView in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateStubSettingsClass.
private StaticLangStubSettingsView generateStubSettingsClass(InterfaceContext context, GapicProductConfig productConfig, StaticLangApiMethodView exampleApiMethod) {
addSettingsImports(context);
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
ApiModel model = context.getApiModel();
StaticLangStubSettingsView.Builder xsettingsClass = StaticLangStubSettingsView.newBuilder();
xsettingsClass.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
xsettingsClass.doc(generateSettingsDoc(context, exampleApiMethod, productConfig, context.getNamer().getApiStubSettingsClassName(interfaceConfig), namer.getApiStubInterfaceName(context.getInterfaceConfig())));
String name = namer.getApiStubSettingsClassName(context.getInterfaceConfig());
xsettingsClass.name(name);
xsettingsClass.serviceAddress(model.getServiceAddress());
xsettingsClass.servicePort(model.getServicePort());
xsettingsClass.authScopes(model.getAuthScopes());
if (productConfig.getTransportProtocol().equals(TransportProtocol.HTTP)) {
xsettingsClass.useDefaultServicePortInEndpoint(false);
}
xsettingsClass.transportProtocol(productConfig.getTransportProtocol());
xsettingsClass.rpcTransportName(namer.getTransportClassName(productConfig.getTransportProtocol()));
xsettingsClass.transportNameGetter(namer.getTransporNameGetMethod(productConfig.getTransportProtocol()));
xsettingsClass.defaultTransportProviderBuilder(namer.getDefaultTransportProviderBuilder(productConfig.getTransportProtocol()));
xsettingsClass.transportProvider(namer.getTransportProvider(productConfig.getTransportProtocol()));
xsettingsClass.instantiatingChannelProvider(namer.getInstantiatingChannelProvider(productConfig.getTransportProtocol()));
List<ApiCallSettingsView> apiCallSettings = apiCallableTransformer.generateCallSettings(context);
xsettingsClass.callSettings(apiCallSettings);
xsettingsClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptorClasses(context));
xsettingsClass.pagedListResponseFactories(pageStreamingTransformer.generateFactoryClasses(context));
xsettingsClass.batchingDescriptors(batchingTransformer.generateDescriptorClasses(context));
xsettingsClass.retryCodesDefinitions(retryDefinitionsTransformer.generateRetryCodesDefinitions(context));
xsettingsClass.retryParamsDefinitions(retryDefinitionsTransformer.generateRetryParamsDefinitions(context));
xsettingsClass.transportProtocol(productConfig.getTransportProtocol());
xsettingsClass.hasDefaultServiceAddress(interfaceConfig.hasDefaultServiceAddress());
xsettingsClass.hasDefaultServiceScopes(interfaceConfig.hasDefaultServiceScopes());
xsettingsClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
xsettingsClass.stubInterfaceName(getAndSaveNicknameForStubType(context, namer.getApiStubInterfaceName(interfaceConfig)));
xsettingsClass.rpcStubClassName(getAndSaveNicknameForStubType(context, namer.getApiRpcStubClassName(interfaceConfig.getInterfaceModel(), productConfig.getTransportProtocol())));
return xsettingsClass.build();
}
use of com.google.api.codegen.viewmodel.ApiCallSettingsView in project toolkit by googleapis.
the class ApiCallableTransformer method generateApiCallableSettings.
public ApiCallSettingsView generateApiCallableSettings(MethodContext context, ApiCallableImplType callableImplType) {
SurfaceNamer namer = context.getNamer();
ImportTypeTable typeTable = context.getTypeTable();
MethodModel method = context.getMethodModel();
MethodConfig methodConfig = context.getMethodConfig();
Map<String, RetryCodesDefinitionView> retryCodesByKey = new HashMap<>();
for (RetryCodesDefinitionView retryCodes : retryDefinitionsTransformer.generateRetryCodesDefinitions(context.getSurfaceInterfaceContext())) {
retryCodesByKey.put(retryCodes.key(), retryCodes);
}
Map<String, RetryParamsDefinitionView> retryParamsByKey = new HashMap<>();
for (RetryParamsDefinitionView retryParams : retryDefinitionsTransformer.generateRetryParamsDefinitions(context.getSurfaceInterfaceContext())) {
retryParamsByKey.put(retryParams.key(), retryParams);
}
ApiCallSettingsView.Builder settings = ApiCallSettingsView.newBuilder();
settings.methodName(namer.getApiMethodName(method, VisibilityConfig.PUBLIC));
settings.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
settings.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
settings.responseTypeName(method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
settings.grpcTypeName(typeTable.getAndSaveNicknameFor(context.getGrpcContainerTypeName()));
settings.grpcMethodConstant(namer.getGrpcMethodConstant(method));
settings.retryCodesName(methodConfig.getRetryCodesConfigName());
settings.retryCodesView(retryCodesByKey.get(methodConfig.getRetryCodesConfigName()));
settings.retryParamsName(methodConfig.getRetrySettingsConfigName());
settings.retryParamsView(retryParamsByKey.get(methodConfig.getRetrySettingsConfigName()));
settings.visibility(namer.getVisiblityKeyword(methodConfig.getVisibility()));
String notImplementedPrefix = "ApiCallableTransformer.generateApiCallableSettings - ";
settings.resourceTypeName(namer.getNotImplementedString(notImplementedPrefix + "resourceTypeName"));
settings.pagedListResponseTypeName(namer.getNotImplementedString(notImplementedPrefix + "pagedListResponseTypeName"));
settings.pageStreamingDescriptorName(namer.getNotImplementedString(notImplementedPrefix + "pageStreamingDescriptorName"));
settings.pagedListResponseFactoryName(namer.getNotImplementedString(notImplementedPrefix + "pagedListResponseFactoryName"));
settings.batchingDescriptorName(namer.getNotImplementedString(notImplementedPrefix + "batchingDescriptorName"));
settings.memberName(namer.getSettingsMemberName(method));
settings.settingsGetFunction(namer.getSettingsFunctionName(method));
settings.type(callableImplType);
switch(callableImplType) {
case BidiStreamingApiCallable:
case ClientStreamingApiCallable:
case ServerStreamingApiCallable:
settings.type(ApiCallableImplType.of(methodConfig.getGrpcStreamingType()));
if (methodConfig.getGrpcStreaming().hasResourceField()) {
FieldModel resourceType = methodConfig.getGrpcStreaming().getResourcesField();
settings.resourceTypeName(typeTable.getAndSaveNicknameForElementType(resourceType));
}
settings.grpcStreamingType(methodConfig.getGrpcStreaming().getType());
break;
case PagedApiCallable:
settings.type(ApiCallableImplType.PagedApiCallable);
FieldModel resourceField = methodConfig.getPageStreaming().getResourcesField();
settings.resourceTypeName(typeTable.getAndSaveNicknameForElementType(resourceField));
settings.pagedListResponseTypeName(namer.getAndSavePagedResponseTypeName(context, methodConfig.getPageStreaming().getResourcesFieldConfig()));
settings.pageStreamingDescriptorName(namer.getPageStreamingDescriptorConstName(method));
settings.pagedListResponseFactoryName(namer.getPagedListResponseFactoryConstName(method));
break;
case BatchingApiCallable:
settings.type(ApiCallableImplType.BatchingApiCallable);
settings.batchingDescriptorName(namer.getBatchingDescriptorConstName(method));
settings.batchingConfig(batchingTransformer.generateBatchingConfig(context));
break;
case OperationApiCallable:
settings.type(ApiCallableImplType.OperationApiCallable);
settings.operationMethod(lroTransformer.generateDetailView(context));
settings.memberName(namer.getOperationSettingsMemberName(method));
settings.settingsGetFunction(namer.getOperationSettingsFunctionName(method));
break;
case SimpleApiCallable:
break;
default:
throw new IllegalStateException("Unhandled ApiCallableImplType enum value: " + callableImplType);
}
return settings.build();
}
use of com.google.api.codegen.viewmodel.ApiCallSettingsView in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateCallSettings.
public List<ApiCallSettingsView> generateCallSettings(GapicInterfaceContext context) {
// This method can be removed once mixins are supported in C#
List<ApiCallSettingsView> settingsMembers = new ArrayList<>();
for (MethodModel method : csharpCommonTransformer.getSupportedMethods(context)) {
List<ApiCallSettingsView> calls = apiCallableTransformer.generateApiCallableSettings(context.asRequestMethodContext(method));
settingsMembers.addAll(calls);
}
return settingsMembers;
}
Aggregations