/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/deadline/model/LogConfiguration.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws {
namespace deadline {
namespace Model {

LogConfiguration::LogConfiguration(JsonView jsonValue) { *this = jsonValue; }

LogConfiguration& LogConfiguration::operator=(JsonView jsonValue) {
  if (jsonValue.ValueExists("logDriver")) {
    m_logDriver = jsonValue.GetString("logDriver");
    m_logDriverHasBeenSet = true;
  }
  if (jsonValue.ValueExists("options")) {
    Aws::Map<Aws::String, JsonView> optionsJsonMap = jsonValue.GetObject("options").GetAllObjects();
    for (auto& optionsItem : optionsJsonMap) {
      m_options[optionsItem.first] = optionsItem.second.AsString();
    }
    m_optionsHasBeenSet = true;
  }
  if (jsonValue.ValueExists("parameters")) {
    Aws::Map<Aws::String, JsonView> parametersJsonMap = jsonValue.GetObject("parameters").GetAllObjects();
    for (auto& parametersItem : parametersJsonMap) {
      m_parameters[parametersItem.first] = parametersItem.second.AsString();
    }
    m_parametersHasBeenSet = true;
  }
  if (jsonValue.ValueExists("error")) {
    m_error = jsonValue.GetString("error");
    m_errorHasBeenSet = true;
  }
  return *this;
}

JsonValue LogConfiguration::Jsonize() const {
  JsonValue payload;

  if (m_logDriverHasBeenSet) {
    payload.WithString("logDriver", m_logDriver);
  }

  if (m_optionsHasBeenSet) {
    JsonValue optionsJsonMap;
    for (auto& optionsItem : m_options) {
      optionsJsonMap.WithString(optionsItem.first, optionsItem.second);
    }
    payload.WithObject("options", std::move(optionsJsonMap));
  }

  if (m_parametersHasBeenSet) {
    JsonValue parametersJsonMap;
    for (auto& parametersItem : m_parameters) {
      parametersJsonMap.WithString(parametersItem.first, parametersItem.second);
    }
    payload.WithObject("parameters", std::move(parametersJsonMap));
  }

  if (m_errorHasBeenSet) {
    payload.WithString("error", m_error);
  }

  return payload;
}

}  // namespace Model
}  // namespace deadline
}  // namespace Aws
