@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourcesFieldConfig) { return methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); }
@Override protected void setServiceResponseTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { String responseTypeName = context .getMethodModel() .getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()); methodViewBuilder.serviceResponseTypeName(responseTypeName); }
private void setStaticLangAsyncReturnTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { SurfaceNamer namer = context.getNamer(); String returnTypeFullName = namer.getStaticLangAsyncReturnTypeName(context); String returnTypeNickname = context.getTypeTable().getAndSaveNicknameFor(returnTypeFullName); methodViewBuilder.responseTypeName(returnTypeNickname); }
private void setStaticLangReturnTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { SurfaceNamer namer = context.getNamer(); String returnTypeFullName = namer.getStaticLangReturnTypeName(context); String returnTypeNickname = context.getTypeTable().getAndSaveNicknameFor(returnTypeFullName); methodViewBuilder.responseTypeName(returnTypeNickname); }
private static String getVariableName(MethodContext context, InitCodeNode item) { if (!context .getFeatureConfig() .useResourceNameFormatOptionInSample(context, item.getFieldConfig()) && item.getInitValueConfig().hasFormattingConfig()) { return context.getNamer().getFormattedVariableName(item.getIdentifier()); } return context.getNamer().localVarName(item.getIdentifier()); } }
public List<SimpleParamDocView> getRequestObjectParamDocs(MethodContext context) { MethodModel method = context.getMethodModel(); SimpleParamDocView doc = SimpleParamDocView.newBuilder() .paramName("request") .typeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer())) .lines( Arrays.<String>asList( "The request object containing all of the parameters for the API call.")) .build(); return ImmutableList.of(doc); } }
private List<BatchingPartitionKeyView> generatePartitionKeys(MethodContext context) { List<BatchingPartitionKeyView> keys = new ArrayList<>(); BatchingConfig batching = context.getMethodConfig().getBatching(); for (GenericFieldSelector fieldSelector : batching.getDiscriminatorFields()) { FieldModel selectedType = fieldSelector.getLastField(); BatchingPartitionKeyView key = BatchingPartitionKeyView.newBuilder() .fieldGetFunction(context.getNamer().getFieldGetFunctionName(selectedType)) .build(); keys.add(key); } return keys; } }
private void setStaticLangGrpcStreamingReturnTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { SurfaceNamer namer = context.getNamer(); // use the api return type name as the surface return type name String returnTypeFullName = namer.getGrpcStreamingApiReturnTypeName(context, context.getTypeTable()); String returnTypeNickname = context.getTypeTable().getAndSaveNicknameFor(returnTypeFullName); methodViewBuilder.responseTypeName(returnTypeNickname); }
@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String inputTypeName = methodContext .getMethodModel() .getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedEnumerable", inputTypeName, outputTypeName, resourceTypeName); }
@Override public String getAndSaveAsyncPagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String inputTypeName = methodContext .getMethodModel() .getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedAsyncEnumerable", inputTypeName, outputTypeName, resourceTypeName); }
@Before public void setUp() { valueSet = SampleValueSet.newBuilder().setId("test-sample-value-set-id").build(); parent = new OutputTransformer.ScopeTable(); child = new OutputTransformer.ScopeTable(parent); MockitoAnnotations.initMocks(this); when(context.getFeatureConfig()).thenReturn(featureConfig); when(context.getMethodConfig()).thenReturn(config); when(context.getMethodModel()).thenReturn(model); when(context.getNamer()).thenReturn(namer); when(context.getTypeTable()).thenReturn(typeTable); when(model.getSimpleName()).thenReturn("methodSimpleName"); when(namer.getSampleResponseVarName(context)).thenReturn("sampleResponseVarName"); }
public StaticLangApiMethodView generateCallableMethod( MethodContext context, List<CallingForm> callingForms) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name(namer.getCallableMethodName(method)); methodViewBuilder.exampleName(context.getNamer().getCallableMethodExampleName(method)); setCallableMethodFields( context, namer.getCallableName(method), methodViewBuilder, callingForms); methodViewBuilder.responseTypeName( context .getMethodModel() .getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer())); return methodViewBuilder.type(ClientMethodType.CallableMethod).build(); }
@Override public String getAndSaveCallerPagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedEnumerable", outputTypeName, resourceTypeName); }
@Override public String getAndSaveCallerAsyncPagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedAsyncEnumerable", outputTypeName, resourceTypeName); }
protected void setServiceResponseTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { SurfaceNamer namer = context.getNamer(); if (context.getMethodConfig().isGrpcStreaming()) { // Only applicable for protobuf APIs. String returnTypeFullName = namer.getGrpcStreamingApiReturnTypeName(context, context.getTypeTable()); String returnTypeNickname = context.getTypeTable().getAndSaveNicknameFor(returnTypeFullName); methodViewBuilder.serviceResponseTypeName(returnTypeNickname); } else { String responseTypeName = context .getMethodModel() .getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()); methodViewBuilder.serviceResponseTypeName(responseTypeName); } }
private ResourceNameInitValueView.Builder createResourceNameInitValueView( MethodContext context, FieldConfig fieldConfig, InitCodeNode item) { String resourceName = context.getNamer().getAndSaveElementResourceTypeName(context.getTypeTable(), fieldConfig); SingleResourceNameConfig singleResourceNameConfig = (SingleResourceNameConfig) fieldConfig.getResourceNameConfig(); List<String> varList = Lists.newArrayList(singleResourceNameConfig.getNameTemplate().vars()); return ResourceNameInitValueView.newBuilder() .resourceTypeName(resourceName) .formatArgs(getFormatFunctionArgs(context, varList, item.getInitValueConfig())); }
public StaticLangApiMethodView generatePagedCallableMethod(MethodContext context) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name(namer.getPagedCallableMethodName(method)); methodViewBuilder.exampleName(namer.getPagedCallableMethodExampleName(method)); setListMethodFields(context, Synchronicity.Sync, methodViewBuilder); setCallableMethodFields( context, namer.getPagedCallableName(method), methodViewBuilder, Arrays.asList(CallingForm.CallablePaged)); return methodViewBuilder.type(ClientMethodType.PagedCallableMethod).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(); }
private InitCodeLineView generateStructureInitCodeLine(MethodContext context, InitCodeNode item) { StructureInitCodeLineView.Builder surfaceLine = StructureInitCodeLineView.newBuilder(); SurfaceNamer namer = context.getNamer(); ImportTypeTable typeTable = context.getTypeTable(); surfaceLine.lineType(InitCodeLineType.StructureInitLine); surfaceLine.identifier(namer.localVarName(item.getIdentifier())); String typeName = typeTable.getAndSaveNicknameFor(item.getType()); surfaceLine.typeName(typeName); surfaceLine.typeConstructor(namer.getTypeConstructor(typeName)); surfaceLine.fieldSettings(getFieldSettings(context, item.getChildren().values())); return surfaceLine.build(); }
private void setCommonApiCallableFields( MethodContext context, ApiCallableView.Builder apiCallableBuilder) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); MethodConfig methodConfig = context.getMethodConfig(); apiCallableBuilder.methodName( namer.getApiMethodName(method, context.getMethodConfig().getVisibility())); apiCallableBuilder.asyncMethodName( namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC)); apiCallableBuilder.memberName(namer.getSettingsMemberName(method)); apiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method)); apiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig)); apiCallableBuilder.transportSettingsVar(namer.getTransportSettingsVar(method)); apiCallableBuilder.httpMethod(generateHttpFields(context)); }