Search in sources :

Example 1 with PageStreamingRequestView

use of com.google.api.codegen.configgen.viewmodel.PageStreamingRequestView in project toolkit by googleapis.

the class MethodTransformer method generatePageStreaming.

private void generatePageStreaming(MethodModel method, MethodView.Builder methodView) {
    PageStreamingRequestView request = generatePageStreamingRequest(method);
    if (request == null) {
        return;
    }
    PageStreamingResponseView response = helperTransformer.generatePageStreamingResponse(method);
    if (response == null) {
        return;
    }
    methodView.pageStreaming(PageStreamingView.newBuilder().request(request).response(response).build());
}
Also used : PageStreamingResponseView(com.google.api.codegen.configgen.viewmodel.PageStreamingResponseView) PageStreamingRequestView(com.google.api.codegen.configgen.viewmodel.PageStreamingRequestView)

Example 2 with PageStreamingRequestView

use of com.google.api.codegen.configgen.viewmodel.PageStreamingRequestView in project toolkit by googleapis.

the class MethodTransformer method generatePageStreamingRequest.

private PageStreamingRequestView generatePageStreamingRequest(MethodModel method) {
    PageStreamingRequestView.Builder requestBuilder = PageStreamingRequestView.newBuilder();
    for (FieldModel field : method.getInputFields()) {
        String fieldName = field.getSimpleName();
        if (fieldName.equals(helperTransformer.getPagingParameters().getNameForPageToken())) {
            requestBuilder.tokenField(fieldName);
        } else if (fieldName.equals(helperTransformer.getPagingParameters().getNameForPageSize())) {
            requestBuilder.pageSizeField(fieldName);
        }
    }
    PageStreamingRequestView request = requestBuilder.build();
    return request.tokenField() == null && request.pageSizeField() == null ? null : request;
}
Also used : PageStreamingRequestView(com.google.api.codegen.configgen.viewmodel.PageStreamingRequestView) FieldModel(com.google.api.codegen.config.FieldModel)

Aggregations

PageStreamingRequestView (com.google.api.codegen.configgen.viewmodel.PageStreamingRequestView)2 FieldModel (com.google.api.codegen.config.FieldModel)1 PageStreamingResponseView (com.google.api.codegen.configgen.viewmodel.PageStreamingResponseView)1