/** * A utility method which creates the InitValueConfig map that contains the collection config * data. */ public static ImmutableMap<String, InitValueConfig> createCollectionMap(MethodContext context) { ImmutableMap.Builder<String, InitValueConfig> mapBuilder = ImmutableMap.builder(); Map<String, String> fieldNamePatterns = context.getMethodConfig().getFieldNamePatterns(); for (Map.Entry<String, String> fieldNamePattern : fieldNamePatterns.entrySet()) { SingleResourceNameConfig resourceNameConfig = context.getSingleResourceNameConfig(fieldNamePattern.getValue()); String apiWrapperClassName = context.getNamer().getApiWrapperClassName(context.getInterfaceConfig()); InitValueConfig initValueConfig = InitValueConfig.create(apiWrapperClassName, resourceNameConfig); mapBuilder.put(fieldNamePattern.getKey(), initValueConfig); } return mapBuilder.build(); }
@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { // TODO(michaelbausor) make sure this uses the typeTable correctly ImportTypeTable typeTable = methodContext.getTypeTable(); String fullPackageWrapperName = typeTable.getImplicitPackageFullNameFor( getApiWrapperClassName(methodContext.getInterfaceConfig())); String pagedResponseShortName = getPagedResponseTypeInnerName( methodContext.getMethodModel(), typeTable, resourceFieldConfig.getField()); return typeTable.getAndSaveNicknameForInnerType(fullPackageWrapperName, pagedResponseShortName); }
private StaticLangApiMethodSnippetView generateOperationFlattenedAsyncMethod( MethodContext methodContext, String suffix) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateAsyncOperationFlattenedMethod( methodContext, Collections.<ParamWithSimpleDoc>emptyList(), ClientMethodType.AsyncOperationFlattenedMethod, true), methodContext, methodContext.getFlatteningConfig().getFlattenedFieldConfigs().values(), InitCodeOutputType.FieldList, CallingForm.LongRunningFlattenedAsync); String callerResponseTypeName = method.operationMethod().clientReturnTypeName(); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + suffix) .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private StaticLangApiMethodSnippetView generateOperationFlattenedMethod( MethodContext methodContext, String suffix) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateOperationFlattenedMethod( methodContext, Collections.<ParamWithSimpleDoc>emptyList()), methodContext, methodContext.getFlatteningConfig().getFlattenedFieldConfigs().values(), InitCodeOutputType.FieldList, CallingForm.LongRunningFlattened); String callerResponseTypeName = method.operationMethod().clientReturnTypeName(); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + suffix) .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
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, Arrays.asList(CallingForm.Request)); setStaticLangReturnTypeName(context, methodViewBuilder); return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).build(); }
public StaticLangApiMethodView generateGrpcStreamingRequestObjectMethod(MethodContext context) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name( namer.getGrpcStreamingApiMethodName(method, context.getMethodConfig().getVisibility())); methodViewBuilder.exampleName( namer.getGrpcStreamingApiMethodExampleName(context.getInterfaceConfig(), method)); setRequestObjectMethodFields( context, namer.getCallableMethodName(method), Synchronicity.Sync, methodViewBuilder, Arrays.asList(CallingForm.RequestStreamingServer)); setStaticLangGrpcStreamingReturnTypeName(context, methodViewBuilder); return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).build(); }
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, Arrays.asList(CallingForm.FlattenedPaged)); return methodViewBuilder.type(ClientMethodType.PagedFlattenedMethod).build(); }
public StaticLangApiMethodView generatePagedRequestObjectMethod( 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)); setListMethodFields(context, Synchronicity.Sync, methodViewBuilder); setRequestObjectMethodFields( context, namer.getPagedCallableMethodName(method), Synchronicity.Sync, additionalParams, methodViewBuilder, Arrays.asList(CallingForm.RequestPaged)); return methodViewBuilder.type(ClientMethodType.PagedRequestObjectMethod).build(); }
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, Arrays.asList(CallingForm.Flattened)); setStaticLangReturnTypeName(context, methodViewBuilder); return methodViewBuilder.type(ClientMethodType.FlattenedMethod).build(); }
public StaticLangApiMethodView generateGrpcStreamingFlattenedMethod( MethodContext context, List<ParamWithSimpleDoc> additionalParams) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name( namer.getGrpcStreamingApiMethodName(method, context.getMethodConfig().getVisibility())); methodViewBuilder.exampleName( namer.getGrpcStreamingApiMethodExampleName(context.getInterfaceConfig(), method)); methodViewBuilder.callableName(namer.getCallableName(method)); setFlattenedMethodFields( context, additionalParams, Synchronicity.Sync, methodViewBuilder, Arrays.asList(CallingForm.Flattened)); setStaticLangGrpcStreamingReturnTypeName(context, methodViewBuilder); return methodViewBuilder.type(ClientMethodType.FlattenedMethod).build(); }
private StaticLangApiMethodSnippetView generateOperationRequestAsyncMethod( MethodContext methodContext) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateAsyncOperationRequestObjectMethod( methodContext, Collections.<ParamWithSimpleDoc>emptyList(), true), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.LongRunningRequestAsync); String callerResponseTypeName = method.operationMethod().clientReturnTypeName(); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + "_RequestObject") .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private StaticLangApiMethodSnippetView generateFlattenedMethod( MethodContext methodContext, String suffix) { StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateFlattenedMethod(methodContext), methodContext, methodContext.getFlatteningConfig().getFlattenedFieldConfigs().values(), InitCodeOutputType.FieldList, CallingForm.Flattened); SurfaceNamer namer = methodContext.getNamer(); String callerResponseTypeName = methodContext .getTypeTable() .getAndSaveNicknameFor(namer.getStaticLangCallerReturnTypeName(methodContext)); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + suffix) .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private String getMethodDescriptorName(MethodContext context) { if (context.getProductConfig().getTransportProtocol().equals(TransportProtocol.HTTP)) { TypeName rpcStubClassName = new TypeName( context .getNamer() .getFullyQualifiedRpcStubType( context.getInterfaceConfig().getInterfaceModel(), context.getProductConfig().getTransportProtocol())); return context .getTypeTable() .getAndSaveNicknameForInnerType( rpcStubClassName.getFullName(), context.getNamer().getMethodDescriptorName(context.getMethodModel())); } return null; }
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(); }
private StaticLangApiMethodSnippetView generateOperationRequestMethod( MethodContext methodContext) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateOperationRequestObjectMethod(methodContext), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.LongRunningRequest); String callerResponseTypeName = method.operationMethod().clientReturnTypeName(); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + "_RequestObject") .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private StaticLangApiMethodSnippetView generateGrpcStreamingRequestMethod( MethodContext methodContext) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(methodContext), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestStreamingServer); String callerResponseTypeName = method.name() + "Stream"; return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name()) .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .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(); }
private StaticLangApiMethodSnippetView generateRequestMethod(MethodContext methodContext) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateRequestObjectMethod(methodContext), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.Request); String callerResponseTypeName = methodContext .getTypeTable() .getAndSaveNicknameFor(namer.getStaticLangCallerAsyncReturnTypeName(methodContext)); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + "_RequestObject") .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private StaticLangApiMethodSnippetView generateRequestAsyncMethod(MethodContext methodContext) { SurfaceNamer namer = methodContext.getNamer(); StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generateRequestObjectAsyncMethod(methodContext), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestAsync); String callerResponseTypeName = methodContext .getTypeTable() .getAndSaveNicknameFor(namer.getStaticLangCallerAsyncReturnTypeName(methodContext)); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + "_RequestObject") .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }
private StaticLangApiMethodSnippetView generatePagedRequestMethod(MethodContext methodContext) { StaticLangApiMethodView method = generateInitCode( apiMethodTransformer.generatePagedRequestObjectMethod( methodContext, csharpCommonTransformer.pagedMethodAdditionalParams()), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestPaged); SurfaceNamer namer = methodContext.getNamer(); PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming(); FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig(); String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig); return StaticLangApiMethodSnippetView.newBuilder() .method(method) .snippetMethodName(method.name() + "_RequestObject") .callerResponseTypeName(callerResponseTypeName) .apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())) .apiVariableName(method.apiVariableName()) .build(); }