public Map constructOperations()

in codegen/src/main/java/software/amazon/awssdk/codegen/AddOperations.java [154:236]


    public Map<String, OperationModel> constructOperations() {

        Map<String, OperationModel> javaOperationModels = new TreeMap<>();
        Map<String, Shape> c2jShapes = serviceModel.getShapes();

        for (Map.Entry<String, Operation> entry : serviceModel.getOperations().entrySet()) {

            String operationName = entry.getKey();
            Operation op = entry.getValue();

            OperationModel operationModel = new OperationModel();

            operationModel.setOperationName(operationName);
            operationModel.setServiceProtocol(serviceModel.getMetadata().getProtocol());
            operationModel.setDeprecated(op.isDeprecated());
            operationModel.setDeprecatedMessage(op.getDeprecatedMessage());
            operationModel.setDocumentation(op.getDocumentation());
            operationModel.setIsAuthenticated(isAuthenticated(op));
            operationModel.setAuthType(op.getAuthtype());
            operationModel.setPaginated(isPaginated(op));
            operationModel.setEndpointOperation(op.isEndpointoperation());
            operationModel.setEndpointDiscovery(op.getEndpointdiscovery());
            operationModel.setEndpointTrait(op.getEndpoint());
            operationModel.setHttpChecksumRequired(op.isHttpChecksumRequired());
            operationModel.setHttpChecksum(op.getHttpChecksum());
            operationModel.setRequestcompression(op.getRequestcompression());
            operationModel.setStaticContextParams(op.getStaticContextParams());
            operationModel.setOperationContextParams(op.getOperationContextParams());
            operationModel.setAuth(getAuthFromOperation(op));
            operationModel.setUnsignedPayload(op.isUnsignedPayload());

            Input input = op.getInput();
            if (input != null) {
                String originalShapeName = input.getShape();
                String inputShape = namingStrategy.getRequestClassName(operationName);
                String documentation = input.getDocumentation() != null ? input.getDocumentation() :
                                       c2jShapes.get(originalShapeName).getDocumentation();

                operationModel.setInput(new VariableModel(unCapitalize(inputShape), inputShape)
                                            .withDocumentation(documentation));

            }

            Output output = op.getOutput();
            if (output != null) {
                String outputShapeName = getResultShapeName(op, c2jShapes);
                Shape outputShape = c2jShapes.get(outputShapeName);
                String responseClassName = namingStrategy.getResponseClassName(operationName);
                String documentation = getOperationDocumentation(output, outputShape);

                operationModel.setReturnType(
                    new ReturnTypeModel(responseClassName).withDocumentation(documentation));
                if (isBlobShape(getPayloadShape(c2jShapes, outputShape))) {
                    operationModel.setHasBlobMemberAsPayload(true);
                }
                if (isStringShape(getPayloadShape(c2jShapes, outputShape))) {
                    operationModel.setHasStringMemberAsPayload(true);
                }
            }

            if (op.getErrors() != null) {
                for (ErrorMap error : op.getErrors()) {

                    String documentation =
                        error.getDocumentation() != null ? error.getDocumentation() :
                        c2jShapes.get(error.getShape()).getDocumentation();

                    Integer httpStatusCode = getHttpStatusCode(error, c2jShapes.get(error.getShape()));

                    if (!deprecatedShapes.contains(error.getShape())) {
                        operationModel.addException(
                            new ExceptionModel(namingStrategy.getExceptionName(error.getShape()))
                                .withDocumentation(documentation)
                                .withHttpStatusCode(httpStatusCode));
                    }
                }
            }

            javaOperationModels.put(operationName, operationModel);
        }

        return javaOperationModels;
    }