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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations