use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.
the class GeneratorUtils method getRequiredArgs.
/**
* Retrieves a list of arguments from the Ds3Request, including converting the required
* parameters to arguments, and retrieving the arguments from the request header info
*/
public static ImmutableList<Arguments> getRequiredArgs(final Ds3Request ds3Request) {
final ImmutableList.Builder<Arguments> requiredArgs = ImmutableList.builder();
requiredArgs.addAll(RequestConverterUtil.getRequiredArgsFromRequestHeader(ds3Request));
requiredArgs.addAll(getArgsFromParamList(ds3Request.getRequiredQueryParams()));
if (ds3Request.getIncludeInPath() && isResourceNotification(ds3Request.getResource())) {
requiredArgs.add(new Arguments("Guid", "NotificationId"));
}
return requiredArgs.build();
}
use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.
the class BaseRequestGenerator method toConstructorList.
/**
* Creates the request constructors. There will be multiple constructors if there are
* constructor parameters of type Guid
*/
@Override
public ImmutableList<RequestConstructor> toConstructorList(final Ds3Request ds3Request, final String requestName, final Ds3DocSpec docSpec) {
final ImmutableList<Arguments> constructorArgs = Helper.removeVoidArguments(toConstructorArgsList(ds3Request));
final ImmutableList<Arguments> queryParams = toQueryParamsList(ds3Request);
final RequestConstructor standardConstructor = new RequestConstructor(constructorArgs, queryParams, ds3Request.getOperation(), toConstructorDocs(requestName, constructorArgs.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList()), docSpec, 2));
return splitGuidConstructor(standardConstructor);
}
use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.
the class WithConstructorUtil_Test method putQueryParamLine_IntArguments_Test.
@Test
public void putQueryParamLine_IntArguments_Test() {
final String expected = "this.getQueryParams().put(\"arg_name\", Integer.toString(argName));";
final String result = putQueryParamLine(new Arguments("int", "ArgName"));
assertThat(result, is(expected));
}
use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.
the class WithConstructorUtil_Test method putQueryParamLine_ArgInput_Test.
@Test
public void putQueryParamLine_ArgInput_Test() {
final Arguments delimiter = new Arguments("java.lang.String", "Delimiter");
assertThat(putQueryParamLine(delimiter), is("this.getQueryParams().put(\"delimiter\", delimiter);"));
final Arguments bucketId = new Arguments("java.lang.String", "BucketId");
assertThat(putQueryParamLine(bucketId), is("this.getQueryParams().put(\"bucket_id\", bucketId);"));
final Arguments bucketName = new Arguments("java.lang.String", "BucketName");
assertThat(putQueryParamLine(bucketName), is("this.getQueryParams().put(\"bucket_id\", bucketName);"));
final Arguments stringTest = new Arguments("java.lang.String", "StringTest");
assertThat(putQueryParamLine(stringTest), is("this.getQueryParams().put(\"string_test\", UrlEscapers.urlFragmentEscaper().escape(stringTest).replace(\"+\", \"%2B\"));"));
final Arguments intTest = new Arguments("int", "IntTest");
assertThat(putQueryParamLine(intTest), is("this.getQueryParams().put(\"int_test\", Integer.toString(intTest));"));
}
use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.
the class WithConstructorUtil_Test method withConstructorFirstLine_Test.
@Test
public void withConstructorFirstLine_Test() {
final String expected = " public TestRequest withArgName(final ArgType argName) {\n";
final String result = withConstructorFirstLine(new Arguments("ArgType", "ArgName"), "TestRequest");
assertThat(result, is(expected));
}
Aggregations