Search in sources :

Example 1 with DynamicLangDefaultableParamView

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

the class PhpApiMethodParamTransformer method generateDefaultableParams.

private List<DynamicLangDefaultableParamView> generateDefaultableParams(GapicMethodContext context) {
    if (context.getMethodModel().getRequestStreaming()) {
        return ImmutableList.<DynamicLangDefaultableParamView>of();
    }
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    for (FieldModel field : context.getMethodConfig().getRequiredFields()) {
        DynamicLangDefaultableParamView param = DynamicLangDefaultableParamView.newBuilder().name(context.getNamer().getVariableName(field)).defaultValue("").build();
        methodParams.add(param);
    }
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) ImmutableList(com.google.common.collect.ImmutableList) FieldModel(com.google.api.codegen.config.FieldModel)

Example 2 with DynamicLangDefaultableParamView

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

the class RubyApiMethodParamTransformer method generateMethodParams.

@Override
public List<DynamicLangDefaultableParamView> generateMethodParams(GapicMethodContext context) {
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    if (context.getMethodModel().getRequestStreaming()) {
        DynamicLangDefaultableParamView.Builder param = DynamicLangDefaultableParamView.newBuilder();
        param.name(context.getNamer().getRequestVariableName(context.getMethodModel()));
        param.defaultValue("");
        methodParams.add(param.build());
    } else {
        MethodConfig methodConfig = context.getMethodConfig();
        for (FieldModel field : methodConfig.getRequiredFields()) {
            DynamicLangDefaultableParamView.Builder param = DynamicLangDefaultableParamView.newBuilder();
            param.name(context.getNamer().getVariableName(field));
            param.defaultValue("");
            methodParams.add(param.build());
        }
        for (FieldModel field : methodConfig.getOptionalFields()) {
            if (isRequestTokenParam(methodConfig, field)) {
                continue;
            }
            DynamicLangDefaultableParamView.Builder param = DynamicLangDefaultableParamView.newBuilder();
            param.name(context.getNamer().getVariableName(field));
            param.defaultValue("nil");
            methodParams.add(param.build());
        }
    }
    DynamicLangDefaultableParamView.Builder optionsParam = DynamicLangDefaultableParamView.newBuilder();
    optionsParam.name("options");
    optionsParam.defaultValue("nil");
    methodParams.add(optionsParam.build());
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) MethodConfig(com.google.api.codegen.config.MethodConfig) ImmutableList(com.google.common.collect.ImmutableList) FieldModel(com.google.api.codegen.config.FieldModel)

Example 3 with DynamicLangDefaultableParamView

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

the class NodeJSApiMethodParamTransformer method generateDefaultableParams.

private List<DynamicLangDefaultableParamView> generateDefaultableParams(GapicMethodContext context) {
    if (context.getMethodModel().getRequestStreaming()) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    for (FieldModel field : context.getMethodConfig().getRequiredFields()) {
        DynamicLangDefaultableParamView param = DynamicLangDefaultableParamView.newBuilder().name(context.getNamer().getVariableName(field)).defaultValue("").build();
        methodParams.add(param);
    }
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) ImmutableList(com.google.common.collect.ImmutableList) FieldModel(com.google.api.codegen.config.FieldModel)

Example 4 with DynamicLangDefaultableParamView

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

the class PhpApiMethodParamTransformer method generateMethodParams.

@Override
public List<DynamicLangDefaultableParamView> generateMethodParams(GapicMethodContext context) {
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    methodParams.addAll(generateDefaultableParams(context));
    TypeRef arrayType = TypeRef.fromPrimitiveName("string").makeRepeated();
    DynamicLangDefaultableParamView.Builder optionalArgs = DynamicLangDefaultableParamView.newBuilder();
    optionalArgs.name(context.getNamer().localVarName(Name.from("optional", "args")));
    optionalArgs.defaultValue(context.getTypeTable().getSnippetZeroValueAndSaveNicknameFor(arrayType));
    methodParams.add(optionalArgs.build());
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) ImmutableList(com.google.common.collect.ImmutableList) TypeRef(com.google.api.tools.framework.model.TypeRef)

Example 5 with DynamicLangDefaultableParamView

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

the class PythonApiMethodParamTransformer method generateMethodParams.

@Override
public List<DynamicLangDefaultableParamView> generateMethodParams(GapicMethodContext context) {
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    methodParams.add(DynamicLangDefaultableParamView.newBuilder().name("self").defaultValue("").build());
    if (context.getMethod().getRequestStreaming()) {
        methodParams.add(DynamicLangDefaultableParamView.newBuilder().name(context.getNamer().getRequestVariableName(context.getMethodModel())).defaultValue("").build());
    } else {
        for (FieldModel field : context.getMethodConfig().getRequiredFields()) {
            DynamicLangDefaultableParamView.Builder param = DynamicLangDefaultableParamView.newBuilder();
            param.name(context.getNamer().getVariableName(field));
            param.defaultValue("");
            methodParams.add(param.build());
        }
        for (FieldModel field : context.getMethodConfig().getOptionalFields()) {
            if (isRequestTokenParam(context.getMethodConfig(), field)) {
                continue;
            }
            DynamicLangDefaultableParamView.Builder param = DynamicLangDefaultableParamView.newBuilder();
            param.name(context.getNamer().getVariableName(field));
            param.defaultValue("None");
            methodParams.add(param.build());
        }
    }
    methodParams.add(DynamicLangDefaultableParamView.newBuilder().name("retry").defaultValue("google.api_core.gapic_v1.method.DEFAULT").build());
    methodParams.add(DynamicLangDefaultableParamView.newBuilder().name("timeout").defaultValue("google.api_core.gapic_v1.method.DEFAULT").build());
    methodParams.add(DynamicLangDefaultableParamView.newBuilder().name("metadata").defaultValue("None").build());
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) ImmutableList(com.google.common.collect.ImmutableList) FieldModel(com.google.api.codegen.config.FieldModel)

Aggregations

DynamicLangDefaultableParamView (com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView)5 ImmutableList (com.google.common.collect.ImmutableList)5 FieldModel (com.google.api.codegen.config.FieldModel)4 MethodConfig (com.google.api.codegen.config.MethodConfig)1 TypeRef (com.google.api.tools.framework.model.TypeRef)1