Search in sources :

Example 6 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class ObjectsPayloadGenerator 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));
    if (hasRequiredFileObjectListPayload(ds3Request)) {
        builder.add(new Arguments(FILE_OBJECTS_TYPE, OBJECTS_NAME));
    }
    if (isMultiFileDeleteRequest(ds3Request)) {
        builder.add(new Arguments(DELETE_OBJECTS_TYPE, OBJECTS_NAME));
    }
    if (isCompleteMultiPartUploadRequest(ds3Request)) {
        builder.add(new Arguments(PARTS_TYPE, PARTS_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) Ds3RequestClassificationUtil(com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil) PythonHelper.pythonIndent(com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent) GeneratorUtils.hasRequiredFileObjectListPayload(com.spectralogic.ds3autogen.python.utils.GeneratorUtils.hasRequiredFileObjectListPayload) 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 7 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class ObjectsPayloadGenerator method toOptionalConstructorParams.

/**
     * Gets the sorted list of optional constructor parameters including the request payload
     */
@Override
public ImmutableList<ConstructorParam> toOptionalConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(toOptionalArgumentsList(ds3Request.getOptionalQueryParams()));
    if (isEjectStorageDomainBlobsRequest(ds3Request)) {
        builder.add(new Arguments(FILE_OBJECTS_TYPE, OBJECTS_NAME));
    }
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), true)).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) Ds3RequestClassificationUtil(com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil) PythonHelper.pythonIndent(com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent) GeneratorUtils.hasRequiredFileObjectListPayload(com.spectralogic.ds3autogen.python.utils.GeneratorUtils.hasRequiredFileObjectListPayload) 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 8 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class PutObjectRequestGenerator method toOptionalConstructorParams.

/**
     * Gets the sorted list of optional constructor params with headers
     */
@Override
public ImmutableList<ConstructorParam> toOptionalConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(toOptionalArgumentsList(ds3Request.getOptionalQueryParams()));
    builder.add(new Arguments("", "headers"));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), true)).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)

Example 9 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class RetryAfterResponseGenerator method toParamList.

/**
     * Retrieves the arguments: response payload, retry after seconds, and status
     */
@Override
public ImmutableList<Arguments> toParamList(final ImmutableList<Ds3ResponseCode> ds3ResponseCodes) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.add(new Arguments("int", "RetryAfterSeconds"));
    builder.add(new Arguments("Status", "Status"));
    if (hasContent(ds3ResponseCodes)) {
        final ImmutableList<Arguments> responseCodeArgs = ds3ResponseCodes.stream().filter(//Filter error codes
        i -> i.getCode() < ERROR_CODE_THRESHOLD).map(BaseResponseGenerator::toParam).filter(//Filters out empty optional arguments
        Optional::isPresent).map(//Get the Arguments object out of the optional
        Optional::get).collect(GuavaCollectors.immutableList());
        builder.addAll(responseCodeArgs);
    }
    return builder.build().stream().sorted(//Sorts the arguments by name
    new CustomArgumentComparator()).collect(GuavaCollectors.immutableList());
}
Also used : Optional(java.util.Optional) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)9 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)9 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)8 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)7 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 PythonHelper.pythonIndent (com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent)5 GeneratorUtils.hasRequiredFileObjectListPayload (com.spectralogic.ds3autogen.python.utils.GeneratorUtils.hasRequiredFileObjectListPayload)2 Ds3RequestClassificationUtil (com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil)2 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)1 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)1 Operation (com.spectralogic.ds3autogen.api.models.enums.Operation)1 BaseRequest (com.spectralogic.ds3autogen.python.model.request.BaseRequest)1 BaseQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.BaseQueryParam)1 OperationQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.OperationQueryParam)1 QueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.QueryParam)1 VoidQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.VoidQueryParam)1 GeneratorUtils (com.spectralogic.ds3autogen.python.utils.GeneratorUtils)1