All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spotinst.sdkjava.model.SpotinstMrScalerOperatorAwsService Maven / Gradle / Ivy

There is a newer version: 1.0.121
Show newest version
package com.spotinst.sdkjava.model;

import com.spotinst.sdkjava.client.response.BaseSpotinstService;
import com.spotinst.sdkjava.client.rest.*;
import com.spotinst.sdkjava.exception.SpotinstHttpException;
import com.spotinst.sdkjava.model.bl.mrScaler.aws.BlMrScalerOperatorAws;
import com.spotinst.sdkjava.model.bl.mrScaler.aws.BlMrScalerOperatorResponse;

import java.util.HashMap;
import java.util.Map;

public class SpotinstMrScalerOperatorAwsService extends BaseSpotinstService {

    static BlMrScalerOperatorResponse createMrScalerOperator(BlMrScalerOperatorAws blMrScalerOperatorAws,
                                                             String authToken,
                                                             String account) throws SpotinstHttpException {
        BlMrScalerOperatorResponse retVal = null;

        // Get endpoint
        SpotinstHttpConfig config      = SpotinstHttpContext.getInstance().getConfiguration();
        String             apiEndpoint = config.getEndpoint();

        Map queryParams = new HashMap<>();

        // Add account Id Query param
        if (account != null) {
            queryParams.put("accountId", account);
        }

        // Get the headers
        Map headers = buildHeaders(authToken);

        // body
        String body = JsonMapper.toJson(blMrScalerOperatorAws);

        // Build URI
        String uri = String.format("%s/aws/emr/mrScalerOperator", apiEndpoint);

        // Send the request
        RestResponse response = RestClient.sendPost(uri, body, headers, queryParams);

        MrScalerOperatorApiResponse mrScalerOperatorApiReponse =
                getCastedResponse(response, MrScalerOperatorApiResponse.class);

        if (mrScalerOperatorApiReponse.getResponse().getCount() > 0) {
            retVal = mrScalerOperatorApiReponse.getResponse().getItems().get(0);
        }
        return retVal;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy