/*
 * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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.
 * 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 <tencentcloud/scf/v20180416/model/CfsConfig.h>

using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Scf::V20180416::Model;
using namespace std;

CfsConfig::CfsConfig() :
    m_cfsInsListHasBeenSet(false)
{
}

CoreInternalOutcome CfsConfig::Deserialize(const rapidjson::Value &value)
{
    string requestId = "";


    if (value.HasMember("CfsInsList") && !value["CfsInsList"].IsNull())
    {
        if (!value["CfsInsList"].IsArray())
            return CoreInternalOutcome(Error("response `CfsConfig.CfsInsList` is not array type"));

        const rapidjson::Value &tmpValue = value["CfsInsList"];
        for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr)
        {
            CfsInsInfo item;
            CoreInternalOutcome outcome = item.Deserialize(*itr);
            if (!outcome.IsSuccess())
            {
                outcome.GetError().SetRequestId(requestId);
                return outcome;
            }
            m_cfsInsList.push_back(item);
        }
        m_cfsInsListHasBeenSet = true;
    }


    return CoreInternalOutcome(true);
}

void CfsConfig::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const
{

    if (m_cfsInsListHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "CfsInsList";
        iKey.SetString(key.c_str(), allocator);
        value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator);

        int i=0;
        for (auto itr = m_cfsInsList.begin(); itr != m_cfsInsList.end(); ++itr, ++i)
        {
            value[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
            (*itr).ToJsonObject(value[key.c_str()][i], allocator);
        }
    }

}


vector<CfsInsInfo> CfsConfig::GetCfsInsList() const
{
    return m_cfsInsList;
}

void CfsConfig::SetCfsInsList(const vector<CfsInsInfo>& _cfsInsList)
{
    m_cfsInsList = _cfsInsList;
    m_cfsInsListHasBeenSet = true;
}

bool CfsConfig::CfsInsListHasBeenSet() const
{
    return m_cfsInsListHasBeenSet;
}

