Search in sources :

Example 86 with Ds3Request

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

the class RequestConverterUtil_Test method getRequiredArgsFromRequestHeader_Singleton_Test.

@Test
public void getRequiredArgsFromRequestHeader_Singleton_Test() {
    final Ds3Request ds3Request = new Ds3Request("RequestName", null, Classification.amazons3, Requirement.REQUIRED, Requirement.REQUIRED, null, Resource.CAPACITY_SUMMARY, ResourceType.SINGLETON, null, false, null, null, null);
    final ImmutableList<Arguments> result = getRequiredArgsFromRequestHeader(ds3Request);
    assertThat(result.size(), is(2));
    assertThat(result.get(0).getName(), is("BucketName"));
    assertThat(result.get(0).getType(), is("String"));
    assertThat(result.get(1).getName(), is("ObjectName"));
    assertThat(result.get(1).getType(), is("String"));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 87 with Ds3Request

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

the class GoCodeGenerator method generateCommands.

/**
     * Generates Go code for requests and responses
     */
private void generateCommands(final ImmutableList<Ds3Request> ds3Requests) throws IOException, TemplateException {
    if (isEmpty(ds3Requests)) {
        LOG.info("There were no requests to generate.");
        return;
    }
    for (final Ds3Request ds3Request : ds3Requests) {
        generateRequest(ds3Request);
        generateResponse(ds3Request);
    }
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)

Example 88 with Ds3Request

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

the class GoCodeGenerator method generateClient.

/**
     * Generates the client files. Each file contains the client commands separated by {@link HttpVerb}
     */
private void generateClient(final ImmutableList<Ds3Request> ds3Requests) throws IOException, TemplateException {
    for (final HttpVerb httpVerb : HttpVerb.values()) {
        final ImmutableList<Ds3Request> filteredRequests = ds3Requests.stream().filter(ds3Request -> ds3Request.getHttpVerb() == httpVerb).collect(GuavaCollectors.immutableList());
        generateClientFile(filteredRequests, httpVerb);
    }
}
Also used : Client(com.spectralogic.ds3autogen.go.models.client.Client) ConverterUtil.isEnum(com.spectralogic.ds3autogen.utils.ConverterUtil.isEnum) GetObjectResponseGenerator(com.spectralogic.ds3autogen.go.generators.response.GetObjectResponseGenerator) ResponseModelGenerator(com.spectralogic.ds3autogen.go.generators.response.ResponseModelGenerator) Ds3RequestClassificationUtil(com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil) TypeModelGenerator(com.spectralogic.ds3autogen.go.generators.type.TypeModelGenerator) LoggerFactory(org.slf4j.LoggerFactory) NoResponseGenerator(com.spectralogic.ds3autogen.go.generators.response.NoResponseGenerator) BaseTypeGenerator(com.spectralogic.ds3autogen.go.generators.type.BaseTypeGenerator) Type(com.spectralogic.ds3autogen.go.models.type.Type) Response(com.spectralogic.ds3autogen.go.models.response.Response) StringUtils.uncapitalize(org.apache.commons.lang3.StringUtils.uncapitalize) ResponsePayloadUtil.hasResponsePayload(com.spectralogic.ds3autogen.utils.ResponsePayloadUtil.hasResponsePayload) ConverterUtil.removeUnusedTypes(com.spectralogic.ds3autogen.utils.ConverterUtil.removeUnusedTypes) CodeGenerator(com.spectralogic.ds3autogen.api.CodeGenerator) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) BaseClientGenerator(com.spectralogic.ds3autogen.go.generators.client.BaseClientGenerator) ImmutableList(com.google.common.collect.ImmutableList) Request(com.spectralogic.ds3autogen.go.models.request.Request) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) OutputStreamWriter(java.io.OutputStreamWriter) com.spectralogic.ds3autogen.go.generators.request(com.spectralogic.ds3autogen.go.generators.request) Path(java.nio.file.Path) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) OutputStream(java.io.OutputStream) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) BaseResponseGenerator(com.spectralogic.ds3autogen.go.generators.response.BaseResponseGenerator) IOException(java.io.IOException) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) freemarker.template(freemarker.template) ClientModelGenerator(com.spectralogic.ds3autogen.go.generators.client.ClientModelGenerator) ConverterUtil.isEmpty(com.spectralogic.ds3autogen.utils.ConverterUtil.isEmpty) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) Paths(java.nio.file.Paths) Writer(java.io.Writer) Ds3TypeClassificationUtil.isJobsApiBean(com.spectralogic.ds3autogen.utils.Ds3TypeClassificationUtil.isJobsApiBean) HttpVerb(com.spectralogic.ds3autogen.api.models.enums.HttpVerb) JobListGenerator(com.spectralogic.ds3autogen.go.generators.type.JobListGenerator) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) HttpVerb(com.spectralogic.ds3autogen.api.models.enums.HttpVerb)

Example 89 with Ds3Request

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

the class RequestConverterUtil_Test method getRequiredArgsFromRequestHeader_Null_Test.

@Test
public void getRequiredArgsFromRequestHeader_Null_Test() {
    final Ds3Request ds3Request = new Ds3Request("RequestName", null, Classification.amazons3, null, null, null, null, null, null, false, null, null, null);
    final ImmutableList<Arguments> result = getRequiredArgsFromRequestHeader(ds3Request);
    assertThat(result.size(), is(0));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 90 with Ds3Request

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

the class BaseClientGenerator method toVoidCommands.

/**
     * Converts the Ds3Requests with no response type into Void Commands
     */
protected static ImmutableList<VoidCommand> toVoidCommands(final ImmutableList<Ds3Request> ds3Requests, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<VoidCommand> builder = ImmutableList.builder();
    final ImmutableList<Ds3Request> voidRequests = getRequestsBasedOnResponsePayload(ds3Requests, false);
    for (final Ds3Request ds3Request : voidRequests) {
        builder.add(toVoidCommand(ds3Request, docSpec));
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) VoidCommand(com.spectralogic.ds3autogen.net.model.client.VoidCommand) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)

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