Search in sources :

Example 66 with Ds3Request

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.

the class RequestGeneratorUtil_Test method toRequestPath_Exception_Test.

@Test(expected = IllegalArgumentException.class)
public void toRequestPath_Exception_Test() {
    final Ds3Request request = new Ds3Request("Test", HttpVerb.GET, Classification.spectrainternal, Requirement.NOT_ALLOWED, Requirement.NOT_ALLOWED, Action.BULK_DELETE, Resource.ACTIVE_JOB, ResourceType.NON_SINGLETON, Operation.ALLOCATE, false, ImmutableList.of(), ImmutableList.of(), ImmutableList.of());
    toRequestPath(request);
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 67 with Ds3Request

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters for a Ds3Request
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) RequestConverterUtil(com.spectralogic.ds3autogen.utils.RequestConverterUtil) Operation(com.spectralogic.ds3autogen.api.models.enums.Operation) BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) GeneratorUtils(com.spectralogic.ds3autogen.python.utils.GeneratorUtils) BaseQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.BaseQueryParam) ConverterUtil.isEmpty(com.spectralogic.ds3autogen.utils.ConverterUtil.isEmpty) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) PythonDocGeneratorUtil.toConstructorDocs(com.spectralogic.ds3autogen.python.utils.PythonDocGeneratorUtil.toConstructorDocs) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) VoidQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.VoidQueryParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) NormalizingContractNamesUtil(com.spectralogic.ds3autogen.utils.NormalizingContractNamesUtil) OperationQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.OperationQueryParam) QueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.QueryParam) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 68 with Ds3Request

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.

the class StringPayloadGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters including the request payload
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    builder.add(new Arguments("string", PAYLOAD_NAME));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConverterUtil.getNonVoidArgsFromParamList(com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 69 with Ds3Request

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toResponseModel_Test.

@Test
public void toResponseModel_Test() {
    final Ds3Request request = getBucketRequest();
    final BaseResponse result = toResponseModel(request);
    assertThat(result.getName(), is("GetBucketResponseHandler"));
    assertThat(result.getCodes().size(), is(1));
    final String expectedParseResponse = "if self.response.status == 200:\n" + "      self.result = parseModel(xmldom.fromstring(response.read()), ListBucketResult())";
    assertThat(result.getParseResponseCode(), is(expectedParseResponse));
}
Also used : BaseResponse(com.spectralogic.ds3autogen.python.model.response.BaseResponse) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 70 with Ds3Request

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.

the class GetObjectRequestGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters, including the stream
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    builder.add(new Arguments("", "stream"));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConverterUtil.getNonVoidArgsFromParamList(com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) PythonHelper.pythonIndent(com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Aggregations

Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)92 Test (org.junit.Test)76 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)37 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)24 Ds3ModelPartialDataFixture.createEmptyDs3Request (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request)17 ImmutableList (com.google.common.collect.ImmutableList)11 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)11 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)9 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)9 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)8 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)7 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)5 PythonHelper.pythonIndent (com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent)5 Variable (com.spectralogic.ds3autogen.java.models.Variable)3 Ds3RequestClassificationUtil (com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil)3 OutputStream (java.io.OutputStream)3