// Copyright 2020 Bloomberg Finance L.P
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

#include <buildboxcommonmetrics_metricsconfigtype.h>

namespace buildboxcommon {
namespace buildboxcommonmetrics {

MetricsConfigType::MetricsConfigType(
    const std::string &file, const std::string &udp_server, const bool enable,
    const size_t publish_interval,
    const std::unordered_map<std::string, std::string> &metric_tags,
    const std::string &prefix, const std::string &statsd_format)
    : d_file(file), d_udpServer(udp_server), d_enable(enable),
      d_metricTags(metric_tags), d_publishInterval(publish_interval),
      d_prefix(prefix), d_statsdFormat(statsd_format)
{
}

MetricsConfigType::MetricsConfigType()
    : d_file(), d_udpServer(), d_enable(false), d_metricTags(),
      d_publishInterval(DEFAULT_PUBLISH_INTERVAL),
      d_statsdFormat(DEFAULT_STATSD_FORMAT)
{
}

void MetricsConfigType::setFile(const std::string &val) { d_file = val; }
const std::string &MetricsConfigType::file() const { return d_file; }

void MetricsConfigType::setMetricTag(const std::string &key,
                                     const std::string &value)
{
    d_metricTags[key] = value;
}

void MetricsConfigType::setMetricTags(
    const std::unordered_map<std::string, std::string> &tags)
{
    d_metricTags = tags;
}

const std::unordered_map<std::string, std::string> &
MetricsConfigType::metric_tags() const
{
    return d_metricTags;
}

void MetricsConfigType::setUdpServer(const std::string &val)
{
    d_udpServer = val;
}
const std::string &MetricsConfigType::udp_server() const
{
    return d_udpServer;
}

void MetricsConfigType::setEnable(const bool val) { d_enable = val; }
bool MetricsConfigType::enable() const { return d_enable; }

void MetricsConfigType::setInterval(const size_t val)
{
    d_publishInterval = val;
}
size_t MetricsConfigType::interval() const { return d_publishInterval; }

void MetricsConfigType::setPrefix(const std::string &prefix)
{
    d_prefix = prefix;
}
const std::string &MetricsConfigType::prefix() const { return d_prefix; }

void MetricsConfigType::setStatsdFormat(const std::string &format)
{
    d_statsdFormat = format;
}
const std::string &MetricsConfigType::statsd_format() const
{
    return d_statsdFormat;
}

} // namespace buildboxcommonmetrics
} // namespace buildboxcommon
