use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateFlattenedMethod.
public StaticLangApiMethodView generateFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), method));
methodViewBuilder.callableName(namer.getCallableName(method));
setFlattenedMethodFields(context, additionalParams, Synchronicity.Sync, methodViewBuilder);
setStaticLangReturnTypeName(context, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.FlattenedMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generatePagedFlattenedMethod.
public StaticLangApiMethodView generatePagedFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), context.getMethodModel()));
setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
setFlattenedMethodFields(context, additionalParams, Synchronicity.Sync, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.PagedFlattenedMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateRequestObjectMethod.
public StaticLangApiMethodView generateRequestObjectMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), method));
setRequestObjectMethodFields(context, namer.getCallableMethodName(method), Synchronicity.Sync, additionalParams, methodViewBuilder);
setStaticLangReturnTypeName(context, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateApiMethods.
private List<StaticLangApiMethodView> generateApiMethods(GapicInterfaceContext context) {
List<ParamWithSimpleDoc> pagedMethodAdditionalParams = new ImmutableList.Builder<ParamWithSimpleDoc>().addAll(csharpCommonTransformer.pagedMethodAdditionalParams()).addAll(csharpCommonTransformer.callSettingsParam()).build();
List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
for (MethodModel method : csharpCommonTransformer.getSupportedMethods(context)) {
MethodConfig methodConfig = context.getMethodConfig(method);
MethodContext requestMethodContext = context.asRequestMethodContext(method);
if (methodConfig.isGrpcStreaming()) {
// Only for protobuf-based APIs.
apiMethods.add(apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(requestMethodContext));
} else if (methodConfig.isLongRunningOperation()) {
// Only for protobuf-based APIs.
GapicMethodContext gapicMethodContext = (GapicMethodContext) requestMethodContext;
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
GapicMethodContext methodContext = context.asFlattenedMethodContext(requestMethodContext.getMethodModel(), flatteningGroup);
apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.AsyncOperationFlattenedCallSettingsMethod, true));
apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(methodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.AsyncOperationFlattenedCancellationMethod, true));
apiMethods.add(apiMethodTransformer.generateOperationFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam()));
}
}
apiMethods.add(apiMethodTransformer.generateAsyncOperationRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam(), true));
apiMethods.add(apiMethodTransformer.generateOperationRequestObjectMethod(gapicMethodContext, csharpCommonTransformer.callSettingsParam()));
} else if (methodConfig.isPageStreaming()) {
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
apiMethods.add(apiMethodTransformer.generatePagedFlattenedAsyncMethod(methodContext, pagedMethodAdditionalParams));
apiMethods.add(apiMethodTransformer.generatePagedFlattenedMethod(methodContext, pagedMethodAdditionalParams));
}
}
apiMethods.add(apiMethodTransformer.generatePagedRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
apiMethods.add(apiMethodTransformer.generatePagedRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
} else {
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
apiMethods.add(apiMethodTransformer.generateFlattenedAsyncMethod(methodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.FlattenedAsyncCallSettingsMethod));
apiMethods.add(apiMethodTransformer.generateFlattenedAsyncMethod(methodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.FlattenedAsyncCancellationTokenMethod));
apiMethods.add(apiMethodTransformer.generateFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam()));
}
}
apiMethods.add(apiMethodTransformer.generateRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.AsyncRequestObjectCallSettingsMethod));
apiMethods.add(apiMethodTransformer.generateRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.AsyncRequestObjectCancellationMethod));
apiMethods.add(apiMethodTransformer.generateRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
}
}
return apiMethods;
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateApiMethods.
private List<StaticLangApiMethodView> generateApiMethods(InterfaceContext context) {
List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
for (MethodModel method : context.getSupportedMethods()) {
MethodConfig methodConfig = context.getMethodConfig(method);
MethodContext requestMethodContext = context.asRequestMethodContext(method);
if (methodConfig.isPageStreaming()) {
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
MethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
apiMethods.add(apiMethodTransformer.generatePagedFlattenedMethod(flattenedMethodContext));
if (hasAnyResourceNameParameter(flatteningGroup)) {
apiMethods.add(apiMethodTransformer.generatePagedFlattenedMethod(flattenedMethodContext.withResourceNamesInSamplesOnly()));
}
}
}
apiMethods.add(apiMethodTransformer.generatePagedRequestObjectMethod(requestMethodContext));
apiMethods.add(apiMethodTransformer.generatePagedCallableMethod(requestMethodContext));
apiMethods.add(apiMethodTransformer.generateUnpagedListCallableMethod(requestMethodContext));
} else if (methodConfig.isGrpcStreaming()) {
ImportTypeTable typeTable = context.getImportTypeTable();
switch(methodConfig.getGrpcStreamingType()) {
case BidiStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
break;
case ClientStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
break;
case ServerStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
break;
default:
throw new IllegalArgumentException("Invalid streaming type: " + methodConfig.getGrpcStreamingType());
}
apiMethods.add(apiMethodTransformer.generateCallableMethod(requestMethodContext));
} else if (methodConfig.isLongRunningOperation()) {
context.getImportTypeTable().saveNicknameFor("com.google.api.gax.rpc.OperationCallable");
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
MethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(flattenedMethodContext));
if (hasAnyResourceNameParameter(flatteningGroup)) {
apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(flattenedMethodContext.withResourceNamesInSamplesOnly()));
}
}
}
apiMethods.add(apiMethodTransformer.generateAsyncOperationRequestObjectMethod(requestMethodContext));
apiMethods.add(apiMethodTransformer.generateOperationCallableMethod(requestMethodContext));
apiMethods.add(apiMethodTransformer.generateCallableMethod(requestMethodContext));
} else {
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
MethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
apiMethods.add(apiMethodTransformer.generateFlattenedMethod(flattenedMethodContext));
if (hasAnyResourceNameParameter(flatteningGroup)) {
apiMethods.add(apiMethodTransformer.generateFlattenedMethod(flattenedMethodContext.withResourceNamesInSamplesOnly()));
}
}
}
apiMethods.add(apiMethodTransformer.generateRequestObjectMethod(requestMethodContext));
apiMethods.add(apiMethodTransformer.generateCallableMethod(requestMethodContext));
}
}
return apiMethods;
}
Aggregations