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

com.amazonaws.services.cloudwatch.model.transform.GetMetricDataRequestMarshaller Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon CloudWatch module holds the client classes that are used for communicating with Amazon CloudWatch Service

There is a newer version: 1.12.778
Show newest version
/*
 * Copyright 2019-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */
package com.amazonaws.services.cloudwatch.model.transform;

import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.Request;
import com.amazonaws.DefaultRequest;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.services.cloudwatch.model.*;
import com.amazonaws.transform.Marshaller;
import com.amazonaws.util.StringUtils;

/**
 * GetMetricDataRequest Marshaller
 */

@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class GetMetricDataRequestMarshaller implements Marshaller, GetMetricDataRequest> {

    public Request marshall(GetMetricDataRequest getMetricDataRequest) {

        if (getMetricDataRequest == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        Request request = new DefaultRequest(getMetricDataRequest, "AmazonCloudWatch");
        request.addParameter("Action", "GetMetricData");
        request.addParameter("Version", "2010-08-01");
        request.setHttpMethod(HttpMethodName.POST);

        if (!getMetricDataRequest.getMetricDataQueries().isEmpty()
                || !((com.amazonaws.internal.SdkInternalList) getMetricDataRequest.getMetricDataQueries()).isAutoConstruct()) {
            com.amazonaws.internal.SdkInternalList metricDataQueriesList = (com.amazonaws.internal.SdkInternalList) getMetricDataRequest
                    .getMetricDataQueries();
            int metricDataQueriesListIndex = 1;

            for (MetricDataQuery metricDataQueriesListValue : metricDataQueriesList) {
                if (metricDataQueriesListValue != null) {

                    if (metricDataQueriesListValue.getId() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".Id",
                                StringUtils.fromString(metricDataQueriesListValue.getId()));
                    }

                    {
                        MetricStat metricStat = metricDataQueriesListValue.getMetricStat();
                        if (metricStat != null) {

                            {
                                Metric metric = metricStat.getMetric();
                                if (metric != null) {

                                    if (metric.getNamespace() != null) {
                                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".MetricStat.Metric.Namespace",
                                                StringUtils.fromString(metric.getNamespace()));
                                    }

                                    if (metric.getMetricName() != null) {
                                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".MetricStat.Metric.MetricName",
                                                StringUtils.fromString(metric.getMetricName()));
                                    }

                                    if (!metric.getDimensions().isEmpty()
                                            || !((com.amazonaws.internal.SdkInternalList) metric.getDimensions()).isAutoConstruct()) {
                                        com.amazonaws.internal.SdkInternalList dimensionsList = (com.amazonaws.internal.SdkInternalList) metric
                                                .getDimensions();
                                        int dimensionsListIndex = 1;

                                        for (Dimension dimensionsListValue : dimensionsList) {
                                            if (dimensionsListValue != null) {

                                                if (dimensionsListValue.getName() != null) {
                                                    request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex
                                                            + ".MetricStat.Metric.Dimensions.member." + dimensionsListIndex + ".Name",
                                                            StringUtils.fromString(dimensionsListValue.getName()));
                                                }

                                                if (dimensionsListValue.getValue() != null) {
                                                    request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex
                                                            + ".MetricStat.Metric.Dimensions.member." + dimensionsListIndex + ".Value",
                                                            StringUtils.fromString(dimensionsListValue.getValue()));
                                                }
                                            }
                                            dimensionsListIndex++;
                                        }
                                    }
                                }
                            }

                            if (metricStat.getPeriod() != null) {
                                request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".MetricStat.Period",
                                        StringUtils.fromInteger(metricStat.getPeriod()));
                            }

                            if (metricStat.getStat() != null) {
                                request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".MetricStat.Stat",
                                        StringUtils.fromString(metricStat.getStat()));
                            }

                            if (metricStat.getUnit() != null) {
                                request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".MetricStat.Unit",
                                        StringUtils.fromString(metricStat.getUnit()));
                            }
                        }
                    }

                    if (metricDataQueriesListValue.getExpression() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".Expression",
                                StringUtils.fromString(metricDataQueriesListValue.getExpression()));
                    }

                    if (metricDataQueriesListValue.getLabel() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".Label",
                                StringUtils.fromString(metricDataQueriesListValue.getLabel()));
                    }

                    if (metricDataQueriesListValue.getReturnData() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".ReturnData",
                                StringUtils.fromBoolean(metricDataQueriesListValue.getReturnData()));
                    }

                    if (metricDataQueriesListValue.getPeriod() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".Period",
                                StringUtils.fromInteger(metricDataQueriesListValue.getPeriod()));
                    }

                    if (metricDataQueriesListValue.getAccountId() != null) {
                        request.addParameter("MetricDataQueries.member." + metricDataQueriesListIndex + ".AccountId",
                                StringUtils.fromString(metricDataQueriesListValue.getAccountId()));
                    }
                }
                metricDataQueriesListIndex++;
            }
        }

        if (getMetricDataRequest.getStartTime() != null) {
            request.addParameter("StartTime", StringUtils.fromDate(getMetricDataRequest.getStartTime()));
        }

        if (getMetricDataRequest.getEndTime() != null) {
            request.addParameter("EndTime", StringUtils.fromDate(getMetricDataRequest.getEndTime()));
        }

        if (getMetricDataRequest.getNextToken() != null) {
            request.addParameter("NextToken", StringUtils.fromString(getMetricDataRequest.getNextToken()));
        }

        if (getMetricDataRequest.getScanBy() != null) {
            request.addParameter("ScanBy", StringUtils.fromString(getMetricDataRequest.getScanBy()));
        }

        if (getMetricDataRequest.getMaxDatapoints() != null) {
            request.addParameter("MaxDatapoints", StringUtils.fromInteger(getMetricDataRequest.getMaxDatapoints()));
        }

        {
            LabelOptions labelOptions = getMetricDataRequest.getLabelOptions();
            if (labelOptions != null) {

                if (labelOptions.getTimezone() != null) {
                    request.addParameter("LabelOptions.Timezone", StringUtils.fromString(labelOptions.getTimezone()));
                }
            }
        }

        return request;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy