public boolean isLongRunningOperation() { return getLongRunningConfig() != null; }
@Override public String getAndSaveOperationResponseTypeName( MethodModel method, ImportTypeTable typeTable, MethodConfig methodConfig) { String responseTypeName = typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getReturnType()); String metaTypeName = typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getMetadataType()); return typeTable.getAndSaveNicknameForContainer( "Google.LongRunning.Operation", responseTypeName, metaTypeName); }
@Override public String getAndSaveOperationResponseTypeName( MethodModel method, ImportTypeTable typeTable, MethodConfig methodConfig) { String responseTypeName = typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getReturnType()); String metadataTypeName = typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getMetadataType()); return typeTable.getAndSaveNicknameForContainer( "com.google.api.gax.grpc.OperationFuture", responseTypeName, metadataTypeName); }
private InitCodeContext createResponseInitCodeContext( MethodContext context, SymbolTable symbolTable) { TypeModel outputType = context.getMethodModel().getOutputType(); if (context.getMethodConfig().isLongRunningOperation()) { outputType = context.getMethodConfig().getLongRunningConfig().getReturnType(); } return InitCodeContext.newBuilder() .initObjectType(outputType) .symbolTable(symbolTable) .suggestedName(Name.from("expected_response")) .initFieldConfigStrings(ImmutableList.of()) .initValueConfigMap(ImmutableMap.of()) .initFields(responseInitFields(outputType.getFields())) .fieldConfigMap(context.getProductConfig().getDefaultResourceNameFieldConfigMap()) .valueGenerator(valueGenerator) .additionalInitCodeNodes(createMockResponseAdditionalSubTrees(context)) .build(); }
public StaticLangApiMethodView generateOperationCallableMethod(MethodContext context) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name(namer.getOperationCallableMethodName(method)); methodViewBuilder.exampleName(context.getNamer().getOperationCallableMethodExampleName(method)); setCallableMethodFields( context, namer.getOperationCallableName(method), methodViewBuilder, Arrays.asList(CallingForm.LongRunningCallable)); TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType(); methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType)); methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context)); return methodViewBuilder.type(ClientMethodType.OperationCallableMethod).build(); }
TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType(); methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType)); methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
public StaticLangApiMethodView generateOperationRequestObjectMethod( 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, Arrays.asList(CallingForm.LongRunningRequest)); methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context)); TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType(); methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType)); return methodViewBuilder.type(ClientMethodType.OperationRequestObjectMethod).build(); }
public StaticLangApiMethodView generateOperationFlattenedMethod( 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, Arrays.asList(CallingForm.LongRunningFlattened)); methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context)); TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType(); methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType)); return methodViewBuilder.type(ClientMethodType.OperationFlattenedMethod).build(); }
.makeOptional(); } else if (context.getMethodConfig().isLongRunningOperation()) { type = context.getMethodConfig().getLongRunningConfig().getReturnType(); } else { type = context.getMethodModel().getOutputType();
public StaticLangApiMethodView generateAsyncOperationFlattenedMethod( MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type, boolean requiresOperationMethod) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name( namer.getAsyncApiMethodName( context.getMethodModel(), context.getMethodConfig().getVisibility())); methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method)); methodViewBuilder.callableName(namer.getCallableName(method)); setFlattenedMethodFields( context, additionalParams, Synchronicity.Async, methodViewBuilder, Arrays.asList(CallingForm.LongRunningFlattenedAsync)); if (requiresOperationMethod) { methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context)); } TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType(); methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType)); methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context)); return methodViewBuilder.type(type).build(); }
LongRunningOperationDetailView generateDetailView(MethodContext context) { MethodConfig methodConfig = context.getMethodConfig(); LongRunningConfig lroConfig = methodConfig.getLongRunningConfig(); SurfaceNamer namer = context.getNamer(); String clientReturnTypeName = namer.getAndSaveOperationResponseTypeName( context.getMethodModel(), context.getTypeTable(), methodConfig); String operationPayloadTypeName = namer.getLongRunningOperationTypeName(context.getTypeTable(), lroConfig.getReturnType()); String metadataTypeName = namer.getLongRunningOperationTypeName(context.getTypeTable(), lroConfig.getMetadataType()); return LongRunningOperationDetailView.newBuilder() .methodName(namer.getApiMethodName(context.getMethodModel(), VisibilityConfig.PUBLIC)) .constructorName(namer.getTypeConstructor(clientReturnTypeName)) .clientReturnTypeName(clientReturnTypeName) .operationPayloadTypeName(operationPayloadTypeName) .isEmptyOperation(lroConfig.getReturnType().isEmptyType()) .isEmptyMetadata(lroConfig.getMetadataType().isEmptyType()) .metadataTypeName(metadataTypeName) .implementsDelete(lroConfig.implementsDelete()) .implementsCancel(lroConfig.implementsCancel()) .initialPollDelay(lroConfig.getInitialPollDelay().toMillis()) .pollDelayMultiplier(lroConfig.getPollDelayMultiplier()) .maxPollDelay(lroConfig.getMaxPollDelay().toMillis()) .totalPollTimeout(lroConfig.getTotalPollTimeout().toMillis()) .build(); } }
if (context.getMethodConfig().isLongRunningOperation()) { methodViewBuilder.hasReturnValue( !context.getMethodConfig().getLongRunningConfig().getReturnType().isEmptyType()); } else { methodViewBuilder.hasReturnValue(!method.isOutputTypeEmpty());
methodContext .getTypeTable() .getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getReturnType()); callerResponseTypeName = responseTypeName; fullyQualifiedResponseTypeName = methodContext .getTypeTable() .getFullNameFor(methodConfig.getLongRunningConfig().getReturnType()); } else if (clientMethodType == ClientMethodType.CallableMethod) { clientMethodName = namer.getCallableMethodName(method); boolean hasReturnValue = !method.isOutputTypeEmpty(); if (methodConfig.isLongRunningOperation()) { hasReturnValue = !methodConfig.getLongRunningConfig().getReturnType().isEmptyType();