/* Copyright 2018 JDCLOUD.COM

   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.

   Cloud Cabinet Service API
   提供云托管服务的相关接口

   OpenAPI spec version: v1
   Contact: 

   NOTE: This class is auto generated by the jdcloud code generator program.
 */



import Foundation
import JDCloudSDKCore

public class JdccsJDCloudClient:NSObject,JDCloudClient{
    
    private final var jdccsJDCloudClient:JdccsJDCloudClient!


    public convenience init(credential:Credential,sdkEnvironment:SDKEnvironment) {
        self.init()
        self.credential = credential
        self.sdkEnvironment = sdkEnvironment
        jdccsJDCloudClient = self
    }


    public override init() {

        if(GlobalConfig.credential == nil)
        {
            GlobalConfig.credential = Credential(accessKeyId: "",secretAccessKey: "")
        }
        var sdkEnvironment:SDKEnvironment
        if(GlobalConfig.sdkEnvironment != nil)
        {
            sdkEnvironment = GlobalConfig.sdkEnvironment!
        }else{
            sdkEnvironment = SDKEnvironment(endPoint: "jdccs.jdcloud-api.com");
        }
        self.credential = GlobalConfig.credential!
        self.sdkEnvironment = sdkEnvironment
        super.init()
        jdccsJDCloudClient = self
    }
    
    public let userAgent: String = "JdcloudSdkSwift/" + "0.0.1/" + "jdccs/" + "v1"
    
    public let serviceName: String = "jdccs"
    
    public let version: String = "v1"
    
    public let contentType:String = "application/json"
    
    public var credential: Credential
    
    public var sdkEnvironment: SDKEnvironment
    
    public var customHeader: [String : String] = [String:String]()

    public var httpRequestProtocol: String = "https"

    public func addCustomer(key: String, value: String) {
        customHeader[key] = value
    }



    
    public func describeMetricDataAsync(request:DescribeMetricDataRequest,requestComplation:@escaping ExecuteResult<DescribeMetricDataResult>) throws {
        jdccsJDCloudClient = self
        try DescribeMetricDataExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func lastDownsampleAsync(request:LastDownsampleRequest,requestComplation:@escaping ExecuteResult<LastDownsampleResult>) throws {
        jdccsJDCloudClient = self
        try LastDownsampleExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeMetricsAsync(request:DescribeMetricsRequest,requestComplation:@escaping ExecuteResult<DescribeMetricsResult>) throws {
        jdccsJDCloudClient = self
        try DescribeMetricsExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeRoomsAsync(request:DescribeRoomsRequest,requestComplation:@escaping ExecuteResult<DescribeRoomsResult>) throws {
        jdccsJDCloudClient = self
        try DescribeRoomsExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeBandwidthTrafficAsync(request:DescribeBandwidthTrafficRequest,requestComplation:@escaping ExecuteResult<DescribeBandwidthTrafficResult>) throws {
        jdccsJDCloudClient = self
        try DescribeBandwidthTrafficExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeBandwidthTrafficsAsync(request:DescribeBandwidthTrafficsRequest,requestComplation:@escaping ExecuteResult<DescribeBandwidthTrafficsResult>) throws {
        jdccsJDCloudClient = self
        try DescribeBandwidthTrafficsExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeIdcsAsync(request:DescribeIdcsRequest,requestComplation:@escaping ExecuteResult<DescribeIdcsResult>) throws {
        jdccsJDCloudClient = self
        try DescribeIdcsExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func describeCabinetsAsync(request:DescribeCabinetsRequest,requestComplation:@escaping ExecuteResult<DescribeCabinetsResult>) throws {
        jdccsJDCloudClient = self
        try DescribeCabinetsExecutor(jdCloudClient: jdccsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }
    
}


public extension JdccsJDCloudClient{

    convenience init(credential: Credential) {

        var sdkEnvironment:SDKEnvironment
        if(GlobalConfig.sdkEnvironment != nil)
        {
            sdkEnvironment = GlobalConfig.sdkEnvironment!
        }else{
            sdkEnvironment = SDKEnvironment(endPoint: "jdccs.jdcloud-api.com");
        }
        self.init(credential: credential,sdkEnvironment: sdkEnvironment)
    }
}
