use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class NodeJSGapicSurfaceTestTransformer method createTestCaseViews.
private List<TestCaseView> createTestCaseViews(GapicInterfaceContext context) {
ArrayList<TestCaseView> testCaseViews = new ArrayList<>();
SymbolTable testNameTable = new SymbolTable();
for (MethodModel method : context.getSupportedMethods()) {
GapicMethodContext methodContext = context.asRequestMethodContext(method);
if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.ClientStreaming) {
// Issue: https://github.com/googleapis/toolkit/issues/946
continue;
}
Collection<FieldConfig> fieldConfigs = methodContext.getMethodConfig().getRequiredFieldConfigs();
InitCodeContext initCodeContext = InitCodeContext.newBuilder().initObjectType(methodContext.getMethodModel().getInputType()).suggestedName(Name.from("request")).initFieldConfigStrings(methodContext.getMethodConfig().getSampleCodeInitFields()).initValueConfigMap(InitCodeTransformer.createCollectionMap(methodContext)).initFields(FieldConfig.toFieldTypeIterable(fieldConfigs)).outputType(InitCodeOutputType.SingleObject).fieldConfigMap(FieldConfig.toFieldConfigMap(fieldConfigs)).valueGenerator(valueGenerator).build();
testCaseViews.add(testCaseTransformer.createTestCaseView(methodContext, testNameTable, initCodeContext, getMethodType(methodContext)));
}
return testCaseViews;
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createTestCaseViews.
private List<TestCaseView> createTestCaseViews(GapicInterfaceContext context) {
ArrayList<TestCaseView> testCaseViews = new ArrayList<>();
SymbolTable testNameTable = new SymbolTable();
for (MethodModel method : context.getSupportedMethods()) {
GapicMethodContext methodContext = context.asRequestMethodContext(method);
if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.ClientStreaming) {
// Issue: https://github.com/googleapis/toolkit/issues/946
continue;
}
InitCodeOutputType initCodeOutputType = InitCodeOutputType.FieldList;
if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.BidiStreaming) {
initCodeOutputType = InitCodeOutputType.SingleObject;
}
ClientMethodType clientMethodType = ClientMethodType.OptionalArrayMethod;
if (methodContext.isLongRunningMethodContext()) {
clientMethodType = ClientMethodType.LongRunningOptionalArrayMethod;
} else if (methodContext.getMethodConfig().isPageStreaming()) {
clientMethodType = ClientMethodType.PagedOptionalArrayMethod;
}
Collection<FieldConfig> fieldConfigs = methodContext.getMethodConfig().getRequiredFieldConfigs();
InitCodeContext initCodeContext = InitCodeContext.newBuilder().initObjectType(methodContext.getMethodModel().getInputType()).suggestedName(Name.from("request")).initFieldConfigStrings(methodContext.getMethodConfig().getSampleCodeInitFields()).initValueConfigMap(InitCodeTransformer.createCollectionMap(methodContext)).initFields(FieldConfig.toFieldTypeIterable(fieldConfigs)).outputType(initCodeOutputType).fieldConfigMap(FieldConfig.toFieldConfigMap(fieldConfigs)).valueGenerator(valueGenerator).build();
testCaseViews.add(testCaseTransformer.createTestCaseView(methodContext, testNameTable, initCodeContext, clientMethodType));
}
return testCaseViews;
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class NodeJSGapicSurfaceTransformer method createLongRunningDescriptors.
private List<LongRunningOperationDetailView> createLongRunningDescriptors(GapicInterfaceContext context) {
List<LongRunningOperationDetailView> result = new ArrayList<>();
for (MethodModel method : context.getLongRunningMethods()) {
GapicMethodContext methodContext = context.asRequestMethodContext(method);
LongRunningConfig lroConfig = methodContext.getLongRunningConfig();
TypeModel returnType = lroConfig.getReturnType();
TypeModel metadataType = lroConfig.getMetadataType();
result.add(LongRunningOperationDetailView.newBuilder().methodName(context.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).constructorName("").clientReturnTypeName("").operationPayloadTypeName(context.getImportTypeTable().getFullNameFor(returnType)).isEmptyOperation(lroConfig.getReturnType().isEmptyType()).isEmptyMetadata(lroConfig.getMetadataType().isEmptyType()).metadataTypeName(context.getImportTypeTable().getFullNameFor(metadataType)).initialPollDelay(lroConfig.getInitialPollDelay().toMillis()).pollDelayMultiplier(lroConfig.getPollDelayMultiplier()).maxPollDelay(lroConfig.getMaxPollDelay().toMillis()).totalPollTimeout(lroConfig.getTotalPollTimeout().toMillis()).build());
}
return result;
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method createLongRunningDescriptors.
private List<LongRunningOperationDetailView> createLongRunningDescriptors(GapicInterfaceContext context) {
List<LongRunningOperationDetailView> result = new ArrayList<>();
for (MethodModel method : context.getLongRunningMethods()) {
GapicMethodContext methodContext = context.asRequestMethodContext(method);
LongRunningConfig lroConfig = methodContext.getLongRunningConfig();
TypeModel returnType = lroConfig.getReturnType();
TypeModel metadataType = lroConfig.getMetadataType();
result.add(LongRunningOperationDetailView.newBuilder().methodName(context.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).transportMethodName(context.getNamer().getGrpcMethodName(method)).constructorName("").clientReturnTypeName("").operationPayloadTypeName(context.getImportTypeTable().getFullNameFor(returnType)).isEmptyOperation(lroConfig.getReturnType().isEmptyType()).isEmptyMetadata(lroConfig.getMetadataType().isEmptyType()).metadataTypeName(context.getImportTypeTable().getFullNameFor(metadataType)).initialPollDelay(lroConfig.getInitialPollDelay().toMillis()).pollDelayMultiplier(lroConfig.getPollDelayMultiplier()).maxPollDelay(lroConfig.getMaxPollDelay().toMillis()).totalPollTimeout(lroConfig.getTotalPollTimeout().toMillis()).build());
}
return result;
}
Aggregations