import Foundation
import azureSwiftRuntime
public protocol DatabaseAccountsRegenerateKey  {
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var apiVersion : String { get set }
    var keyToRegenerate :  DatabaseAccountRegenerateKeyParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (Error?) -> Void) -> Void;
}

extension Commands.DatabaseAccounts {
// RegenerateKey regenerates an access key for the specified Azure Cosmos DB database account. This method may poll for
// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
    internal class RegenerateKeyCommand : BaseCommand, DatabaseAccountsRegenerateKey {
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var apiVersion = "2015-04-08"
    public var keyToRegenerate :  DatabaseAccountRegenerateKeyParametersProtocol?

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, keyToRegenerate: DatabaseAccountRegenerateKeyParametersProtocol) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.keyToRegenerate = keyToRegenerate
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = true
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = keyToRegenerate

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(keyToRegenerate as? DatabaseAccountRegenerateKeyParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public func execute(client: RuntimeClient,
            completionHandler: @escaping (Error?) -> Void) -> Void {
            client.executeAsyncLRO(command: self) {
                (error) in
                completionHandler(error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol DatabaseListMetricDefinitions  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var databaseRid : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (MetricDefinitionsListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Database {
// ListMetricDefinitions retrieves metric defintions for the given database.
    internal class ListMetricDefinitionsCommand : BaseCommand, DatabaseListMetricDefinitions {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var databaseRid : String
        public var apiVersion = "2015-04-08"

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, databaseRid: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.databaseRid = databaseRid
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{databaseRid}"] = String(describing: self.databaseRid)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(MetricDefinitionsListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (MetricDefinitionsListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: MetricDefinitionsListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol DatabaseListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var databaseRid : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (MetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Database {
// ListMetrics retrieves the metrics determined by the given filter for the given database account and database.
    internal class ListMetricsCommand : BaseCommand, DatabaseListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var databaseRid : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, databaseRid: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.databaseRid = databaseRid
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{databaseRid}"] = String(describing: self.databaseRid)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(MetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (MetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: MetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol DatabaseListUsages  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var databaseRid : String { get set }
    var apiVersion : String { get set }
    var filter : String? { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (UsagesResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Database {
// ListUsages retrieves the usages (most recent data) for the given database.
    internal class ListUsagesCommand : BaseCommand, DatabaseListUsages {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var databaseRid : String
        public var apiVersion = "2015-04-08"
        public var filter : String?

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, databaseRid: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.databaseRid = databaseRid
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{databaseRid}"] = String(describing: self.databaseRid)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            if self.filter != nil { queryParameters["$filter"] = String(describing: self.filter!) }

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(UsagesResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (UsagesResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: UsagesResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
public class DataFactory {
}
public class Commands {
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// Operations is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct Operations {
    public static func List() -> OperationsList {
        return ListCommand()
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol OperationsList  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (OperationListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Operations {
// List lists all of the available Cosmos DB Resource Provider operations.
    internal class ListCommand : BaseCommand, OperationsList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var apiVersion = "2015-04-08"

    public override init() {
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/providers/Microsoft.DocumentDB/operations"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "NextLink"
                }
                let result = try decoder.decode(OperationListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (OperationListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: OperationListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// PartitionKeyRangeId is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct PartitionKeyRangeId {
    public static func ListMetrics(subscriptionId: String, resourceGroupName: String, accountName: String, databaseRid: String, collectionRid: String, partitionKeyRangeId: String, filter: String) -> PartitionKeyRangeIdListMetrics {
        return ListMetricsCommand(subscriptionId: subscriptionId, resourceGroupName: resourceGroupName, accountName: accountName, databaseRid: databaseRid, collectionRid: collectionRid, partitionKeyRangeId: partitionKeyRangeId, filter: filter)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol PartitionKeyRangeIdListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var databaseRid : String { get set }
    var collectionRid : String { get set }
    var partitionKeyRangeId : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (PartitionMetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.PartitionKeyRangeId {
// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id.
    internal class ListMetricsCommand : BaseCommand, PartitionKeyRangeIdListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var databaseRid : String
        public var collectionRid : String
        public var partitionKeyRangeId : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, databaseRid: String, collectionRid: String, partitionKeyRangeId: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.databaseRid = databaseRid
            self.collectionRid = collectionRid
            self.partitionKeyRangeId = partitionKeyRangeId
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{databaseRid}"] = String(describing: self.databaseRid)
            self.pathParameters["{collectionRid}"] = String(describing: self.collectionRid)
            self.pathParameters["{partitionKeyRangeId}"] = String(describing: self.partitionKeyRangeId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(PartitionMetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (PartitionMetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: PartitionMetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// PartitionKeyRangeIdRegion is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct PartitionKeyRangeIdRegion {
    public static func ListMetrics(subscriptionId: String, resourceGroupName: String, accountName: String, region: String, databaseRid: String, collectionRid: String, partitionKeyRangeId: String, filter: String) -> PartitionKeyRangeIdRegionListMetrics {
        return ListMetricsCommand(subscriptionId: subscriptionId, resourceGroupName: resourceGroupName, accountName: accountName, region: region, databaseRid: databaseRid, collectionRid: collectionRid, partitionKeyRangeId: partitionKeyRangeId, filter: filter)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol PartitionKeyRangeIdRegionListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var region : String { get set }
    var databaseRid : String { get set }
    var collectionRid : String { get set }
    var partitionKeyRangeId : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (PartitionMetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.PartitionKeyRangeIdRegion {
// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id and region.
    internal class ListMetricsCommand : BaseCommand, PartitionKeyRangeIdRegionListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var region : String
        public var databaseRid : String
        public var collectionRid : String
        public var partitionKeyRangeId : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, region: String, databaseRid: String, collectionRid: String, partitionKeyRangeId: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.region = region
            self.databaseRid = databaseRid
            self.collectionRid = collectionRid
            self.partitionKeyRangeId = partitionKeyRangeId
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{region}"] = String(describing: self.region)
            self.pathParameters["{databaseRid}"] = String(describing: self.databaseRid)
            self.pathParameters["{collectionRid}"] = String(describing: self.collectionRid)
            self.pathParameters["{partitionKeyRangeId}"] = String(describing: self.partitionKeyRangeId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(PartitionMetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (PartitionMetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: PartitionMetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// Percentile is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct Percentile {
    public static func ListMetrics(subscriptionId: String, resourceGroupName: String, accountName: String, filter: String) -> PercentileListMetrics {
        return ListMetricsCommand(subscriptionId: subscriptionId, resourceGroupName: resourceGroupName, accountName: accountName, filter: filter)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol PercentileListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Percentile {
// ListMetrics retrieves the metrics determined by the given filter for the given database account. This url is only
// for PBS and Replication Latency data
    internal class ListMetricsCommand : BaseCommand, PercentileListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(PercentileMetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: PercentileMetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// PercentileSourceTarget is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct PercentileSourceTarget {
    public static func ListMetrics(subscriptionId: String, resourceGroupName: String, accountName: String, sourceRegion: String, targetRegion: String, filter: String) -> PercentileSourceTargetListMetrics {
        return ListMetricsCommand(subscriptionId: subscriptionId, resourceGroupName: resourceGroupName, accountName: accountName, sourceRegion: sourceRegion, targetRegion: targetRegion, filter: filter)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol PercentileSourceTargetListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var sourceRegion : String { get set }
    var targetRegion : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.PercentileSourceTarget {
// ListMetrics retrieves the metrics determined by the given filter for the given account, source and target region.
// This url is only for PBS and Replication Latency data
    internal class ListMetricsCommand : BaseCommand, PercentileSourceTargetListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var sourceRegion : String
        public var targetRegion : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, sourceRegion: String, targetRegion: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.sourceRegion = sourceRegion
            self.targetRegion = targetRegion
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{sourceRegion}"] = String(describing: self.sourceRegion)
            self.pathParameters["{targetRegion}"] = String(describing: self.targetRegion)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(PercentileMetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: PercentileMetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.

// PercentileTarget is the azure Cosmos DB Database Service Resource Provider REST API
import Foundation
import azureSwiftRuntime
extension Commands {
public struct PercentileTarget {
    public static func ListMetrics(subscriptionId: String, resourceGroupName: String, accountName: String, targetRegion: String, filter: String) -> PercentileTargetListMetrics {
        return ListMetricsCommand(subscriptionId: subscriptionId, resourceGroupName: resourceGroupName, accountName: accountName, targetRegion: targetRegion, filter: filter)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol PercentileTargetListMetrics  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var targetRegion : String { get set }
    var apiVersion : String { get set }
    var filter : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.PercentileTarget {
// ListMetrics retrieves the metrics determined by the given filter for the given account target region. This url is
// only for PBS and Replication Latency data
    internal class ListMetricsCommand : BaseCommand, PercentileTargetListMetrics {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var resourceGroupName : String
        public var accountName : String
        public var targetRegion : String
        public var apiVersion = "2015-04-08"
        public var filter : String

        public init(subscriptionId: String, resourceGroupName: String, accountName: String, targetRegion: String, filter: String) {
            self.subscriptionId = subscriptionId
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.targetRegion = targetRegion
            self.filter = filter
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{targetRegion}"] = String(describing: self.targetRegion)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.queryParameters["$filter"] = String(describing: self.filter)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(PercentileMetricListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (PercentileMetricListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: PercentileMetricListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct CapabilityData : CapabilityProtocol {
    public var name: String?

        enum CodingKeys: String, CodingKey {case name = "name"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.name) {
        self.name = try container.decode(String?.self, forKey: .name)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.name != nil {try container.encode(self.name, forKey: .name)}
  }
}

extension DataFactory {
  public static func createCapabilityProtocol() -> CapabilityProtocol {
    return CapabilityData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct ConsistencyPolicyData : ConsistencyPolicyProtocol {
    public var defaultConsistencyLevel: DefaultConsistencyLevelEnum
    public var maxStalenessPrefix: Int64?
    public var maxIntervalInSeconds: Int32?

        enum CodingKeys: String, CodingKey {case defaultConsistencyLevel = "defaultConsistencyLevel"
        case maxStalenessPrefix = "maxStalenessPrefix"
        case maxIntervalInSeconds = "maxIntervalInSeconds"
        }

  public init(defaultConsistencyLevel: DefaultConsistencyLevelEnum)  {
    self.defaultConsistencyLevel = defaultConsistencyLevel
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      self.defaultConsistencyLevel = try container.decode(DefaultConsistencyLevelEnum.self, forKey: .defaultConsistencyLevel)
    if container.contains(.maxStalenessPrefix) {
        self.maxStalenessPrefix = try container.decode(Int64?.self, forKey: .maxStalenessPrefix)
    }
    if container.contains(.maxIntervalInSeconds) {
        self.maxIntervalInSeconds = try container.decode(Int32?.self, forKey: .maxIntervalInSeconds)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.defaultConsistencyLevel, forKey: .defaultConsistencyLevel)
    if self.maxStalenessPrefix != nil {try container.encode(self.maxStalenessPrefix, forKey: .maxStalenessPrefix)}
    if self.maxIntervalInSeconds != nil {try container.encode(self.maxIntervalInSeconds, forKey: .maxIntervalInSeconds)}
  }
}

extension DataFactory {
  public static func createConsistencyPolicyProtocol(defaultConsistencyLevel: DefaultConsistencyLevelEnum) -> ConsistencyPolicyProtocol {
    return ConsistencyPolicyData(defaultConsistencyLevel: defaultConsistencyLevel)
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountConnectionStringData : DatabaseAccountConnectionStringProtocol {
    public var connectionString: String?
    public var description: String?

        enum CodingKeys: String, CodingKey {case connectionString = "connectionString"
        case description = "description"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.connectionString) {
        self.connectionString = try container.decode(String?.self, forKey: .connectionString)
    }
    if container.contains(.description) {
        self.description = try container.decode(String?.self, forKey: .description)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.connectionString != nil {try container.encode(self.connectionString, forKey: .connectionString)}
    if self.description != nil {try container.encode(self.description, forKey: .description)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountConnectionStringProtocol() -> DatabaseAccountConnectionStringProtocol {
    return DatabaseAccountConnectionStringData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountCreateUpdateParametersData : DatabaseAccountCreateUpdateParametersProtocol, ResourceProtocol {
    public var id: String?
    public var name: String?
    public var type: String?
    public var location: String
    public var tags: [String:String]?
    public var kind: DatabaseAccountKindEnum?
    public var properties: DatabaseAccountCreateUpdatePropertiesProtocol

        enum CodingKeys: String, CodingKey {case id = "id"
        case name = "name"
        case type = "type"
        case location = "location"
        case tags = "tags"
        case kind = "kind"
        case properties = "properties"
        }

  public init(location: String, properties: DatabaseAccountCreateUpdatePropertiesProtocol)  {
    self.location = location
    self.properties = properties
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.id) {
        self.id = try container.decode(String?.self, forKey: .id)
    }
    if container.contains(.name) {
        self.name = try container.decode(String?.self, forKey: .name)
    }
    if container.contains(.type) {
        self.type = try container.decode(String?.self, forKey: .type)
    }
    self.location = try container.decode(String.self, forKey: .location)
    if container.contains(.tags) {
        self.tags = try container.decode([String:String]?.self, forKey: .tags)
    }
    if container.contains(.kind) {
        self.kind = try container.decode(DatabaseAccountKindEnum?.self, forKey: .kind)
    }
    self.properties = try container.decode(DatabaseAccountCreateUpdatePropertiesData.self, forKey: .properties)
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.id != nil {try container.encode(self.id, forKey: .id)}
    if self.name != nil {try container.encode(self.name, forKey: .name)}
    if self.type != nil {try container.encode(self.type, forKey: .type)}
    try container.encode(self.location, forKey: .location)
    if self.tags != nil {try container.encode(self.tags, forKey: .tags)}
    if self.kind != nil {try container.encode(self.kind, forKey: .kind)}
    try container.encode(self.properties as! DatabaseAccountCreateUpdatePropertiesData, forKey: .properties)
  }
}

extension DataFactory {
  public static func createDatabaseAccountCreateUpdateParametersProtocol(location: String, properties: DatabaseAccountCreateUpdatePropertiesProtocol) -> DatabaseAccountCreateUpdateParametersProtocol {
    return DatabaseAccountCreateUpdateParametersData(location: location, properties: properties)
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountCreateUpdatePropertiesData : DatabaseAccountCreateUpdatePropertiesProtocol {
    public var consistencyPolicy: ConsistencyPolicyProtocol?
    public var locations: [LocationProtocol]
    public var databaseAccountOfferType: String
    public var ipRangeFilter: String?
    public var enableAutomaticFailover: Bool?
    public var capabilities: [CapabilityProtocol?]?

        enum CodingKeys: String, CodingKey {case consistencyPolicy = "consistencyPolicy"
        case locations = "locations"
        case databaseAccountOfferType = "databaseAccountOfferType"
        case ipRangeFilter = "ipRangeFilter"
        case enableAutomaticFailover = "enableAutomaticFailover"
        case capabilities = "capabilities"
        }

  public init(locations: [LocationProtocol], databaseAccountOfferType: String)  {
    self.locations = locations
    self.databaseAccountOfferType = databaseAccountOfferType
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.consistencyPolicy) {
        self.consistencyPolicy = try container.decode(ConsistencyPolicyData?.self, forKey: .consistencyPolicy)
    }
    self.locations = try container.decode([LocationData].self, forKey: .locations)
    self.databaseAccountOfferType = try container.decode(String.self, forKey: .databaseAccountOfferType)
    if container.contains(.ipRangeFilter) {
        self.ipRangeFilter = try container.decode(String?.self, forKey: .ipRangeFilter)
    }
    if container.contains(.enableAutomaticFailover) {
        self.enableAutomaticFailover = try container.decode(Bool?.self, forKey: .enableAutomaticFailover)
    }
    if container.contains(.capabilities) {
        self.capabilities = try container.decode([CapabilityData?]?.self, forKey: .capabilities)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.consistencyPolicy != nil {try container.encode(self.consistencyPolicy as! ConsistencyPolicyData?, forKey: .consistencyPolicy)}
    try container.encode(self.locations as! [LocationData], forKey: .locations)
    try container.encode(self.databaseAccountOfferType, forKey: .databaseAccountOfferType)
    if self.ipRangeFilter != nil {try container.encode(self.ipRangeFilter, forKey: .ipRangeFilter)}
    if self.enableAutomaticFailover != nil {try container.encode(self.enableAutomaticFailover, forKey: .enableAutomaticFailover)}
    if self.capabilities != nil {try container.encode(self.capabilities as! [CapabilityData?]?, forKey: .capabilities)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountCreateUpdatePropertiesProtocol(locations: [LocationProtocol], databaseAccountOfferType: String) -> DatabaseAccountCreateUpdatePropertiesProtocol {
    return DatabaseAccountCreateUpdatePropertiesData(locations: locations, databaseAccountOfferType: databaseAccountOfferType)
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountData : DatabaseAccountProtocol, ResourceProtocol {
    public var id: String?
    public var name: String?
    public var type: String?
    public var location: String
    public var tags: [String:String]?
    public var kind: DatabaseAccountKindEnum?
    public var properties: DatabaseAccountPropertiesProtocol?

        enum CodingKeys: String, CodingKey {case id = "id"
        case name = "name"
        case type = "type"
        case location = "location"
        case tags = "tags"
        case kind = "kind"
        case properties = "properties"
        }

  public init(location: String)  {
    self.location = location
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.id) {
        self.id = try container.decode(String?.self, forKey: .id)
    }
    if container.contains(.name) {
        self.name = try container.decode(String?.self, forKey: .name)
    }
    if container.contains(.type) {
        self.type = try container.decode(String?.self, forKey: .type)
    }
    self.location = try container.decode(String.self, forKey: .location)
    if container.contains(.tags) {
        self.tags = try container.decode([String:String]?.self, forKey: .tags)
    }
    if container.contains(.kind) {
        self.kind = try container.decode(DatabaseAccountKindEnum?.self, forKey: .kind)
    }
    if container.contains(.properties) {
        self.properties = try container.decode(DatabaseAccountPropertiesData?.self, forKey: .properties)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.id != nil {try container.encode(self.id, forKey: .id)}
    if self.name != nil {try container.encode(self.name, forKey: .name)}
    if self.type != nil {try container.encode(self.type, forKey: .type)}
    try container.encode(self.location, forKey: .location)
    if self.tags != nil {try container.encode(self.tags, forKey: .tags)}
    if self.kind != nil {try container.encode(self.kind, forKey: .kind)}
    if self.properties != nil {try container.encode(self.properties as! DatabaseAccountPropertiesData?, forKey: .properties)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountProtocol(location: String) -> DatabaseAccountProtocol {
    return DatabaseAccountData(location: location)
  }
}


// DatabaseAccountKind enumerates the values for database account kind.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
public enum DatabaseAccountKindEnum: String, Codable
{
// GlobalDocumentDB specifies the global document db state for database account kind.
    case GlobalDocumentDB = "GlobalDocumentDB"
// MongoDB specifies the mongo db state for database account kind.
    case MongoDB = "MongoDB"
// Parse specifies the parse state for database account kind.
    case Parse = "Parse"
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountListConnectionStringsResultData : DatabaseAccountListConnectionStringsResultProtocol {
    public var connectionStrings: [DatabaseAccountConnectionStringProtocol?]?

        enum CodingKeys: String, CodingKey {case connectionStrings = "connectionStrings"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.connectionStrings) {
        self.connectionStrings = try container.decode([DatabaseAccountConnectionStringData?]?.self, forKey: .connectionStrings)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.connectionStrings != nil {try container.encode(self.connectionStrings as! [DatabaseAccountConnectionStringData?]?, forKey: .connectionStrings)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountListConnectionStringsResultProtocol() -> DatabaseAccountListConnectionStringsResultProtocol {
    return DatabaseAccountListConnectionStringsResultData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountListKeysResultData : DatabaseAccountListKeysResultProtocol {
    public var primaryMasterKey: String?
    public var secondaryMasterKey: String?
    public var properties: DatabaseAccountListReadOnlyKeysResultProtocol?

        enum CodingKeys: String, CodingKey {case primaryMasterKey = "primaryMasterKey"
        case secondaryMasterKey = "secondaryMasterKey"
        case properties = "properties"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.primaryMasterKey) {
        self.primaryMasterKey = try container.decode(String?.self, forKey: .primaryMasterKey)
    }
    if container.contains(.secondaryMasterKey) {
        self.secondaryMasterKey = try container.decode(String?.self, forKey: .secondaryMasterKey)
    }
    if container.contains(.properties) {
        self.properties = try container.decode(DatabaseAccountListReadOnlyKeysResultData?.self, forKey: .properties)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.primaryMasterKey != nil {try container.encode(self.primaryMasterKey, forKey: .primaryMasterKey)}
    if self.secondaryMasterKey != nil {try container.encode(self.secondaryMasterKey, forKey: .secondaryMasterKey)}
    if self.properties != nil {try container.encode(self.properties as! DatabaseAccountListReadOnlyKeysResultData?, forKey: .properties)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountListKeysResultProtocol() -> DatabaseAccountListKeysResultProtocol {
    return DatabaseAccountListKeysResultData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountListReadOnlyKeysResultData : DatabaseAccountListReadOnlyKeysResultProtocol {
    public var primaryReadonlyMasterKey: String?
    public var secondaryReadonlyMasterKey: String?

        enum CodingKeys: String, CodingKey {case primaryReadonlyMasterKey = "primaryReadonlyMasterKey"
        case secondaryReadonlyMasterKey = "secondaryReadonlyMasterKey"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.primaryReadonlyMasterKey) {
        self.primaryReadonlyMasterKey = try container.decode(String?.self, forKey: .primaryReadonlyMasterKey)
    }
    if container.contains(.secondaryReadonlyMasterKey) {
        self.secondaryReadonlyMasterKey = try container.decode(String?.self, forKey: .secondaryReadonlyMasterKey)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.primaryReadonlyMasterKey != nil {try container.encode(self.primaryReadonlyMasterKey, forKey: .primaryReadonlyMasterKey)}
    if self.secondaryReadonlyMasterKey != nil {try container.encode(self.secondaryReadonlyMasterKey, forKey: .secondaryReadonlyMasterKey)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountListReadOnlyKeysResultProtocol() -> DatabaseAccountListReadOnlyKeysResultProtocol {
    return DatabaseAccountListReadOnlyKeysResultData()
  }
}


// DatabaseAccountOfferType enumerates the values for database account offer type.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
public enum DatabaseAccountOfferTypeEnum: String, Codable
{
// Standard specifies the standard state for database account offer type.
    case Standard = "Standard"
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountPatchParametersData : DatabaseAccountPatchParametersProtocol {
    public var tags: [String:String]?
    public var properties: DatabaseAccountPatchPropertiesProtocol?

        enum CodingKeys: String, CodingKey {case tags = "tags"
        case properties = "properties"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.tags) {
        self.tags = try container.decode([String:String]?.self, forKey: .tags)
    }
    if container.contains(.properties) {
        self.properties = try container.decode(DatabaseAccountPatchPropertiesData?.self, forKey: .properties)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.tags != nil {try container.encode(self.tags, forKey: .tags)}
    if self.properties != nil {try container.encode(self.properties as! DatabaseAccountPatchPropertiesData?, forKey: .properties)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountPatchParametersProtocol() -> DatabaseAccountPatchParametersProtocol {
    return DatabaseAccountPatchParametersData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountPatchPropertiesData : DatabaseAccountPatchPropertiesProtocol {
    public var capabilities: [CapabilityProtocol?]?

        enum CodingKeys: String, CodingKey {case capabilities = "capabilities"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.capabilities) {
        self.capabilities = try container.decode([CapabilityData?]?.self, forKey: .capabilities)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.capabilities != nil {try container.encode(self.capabilities as! [CapabilityData?]?, forKey: .capabilities)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountPatchPropertiesProtocol() -> DatabaseAccountPatchPropertiesProtocol {
    return DatabaseAccountPatchPropertiesData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountPropertiesData : DatabaseAccountPropertiesProtocol {
    public var provisioningState: String?
    public var documentEndpoint: String?
    public var databaseAccountOfferType: DatabaseAccountOfferTypeEnum?
    public var ipRangeFilter: String?
    public var enableAutomaticFailover: Bool?
    public var consistencyPolicy: ConsistencyPolicyProtocol?
    public var capabilities: [CapabilityProtocol?]?
    public var writeLocations: [LocationProtocol?]?
    public var readLocations: [LocationProtocol?]?
    public var failoverPolicies: [FailoverPolicyProtocol?]?

        enum CodingKeys: String, CodingKey {case provisioningState = "provisioningState"
        case documentEndpoint = "documentEndpoint"
        case databaseAccountOfferType = "databaseAccountOfferType"
        case ipRangeFilter = "ipRangeFilter"
        case enableAutomaticFailover = "enableAutomaticFailover"
        case consistencyPolicy = "consistencyPolicy"
        case capabilities = "capabilities"
        case writeLocations = "writeLocations"
        case readLocations = "readLocations"
        case failoverPolicies = "failoverPolicies"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.provisioningState) {
        self.provisioningState = try container.decode(String?.self, forKey: .provisioningState)
    }
    if container.contains(.documentEndpoint) {
        self.documentEndpoint = try container.decode(String?.self, forKey: .documentEndpoint)
    }
    if container.contains(.databaseAccountOfferType) {
        self.databaseAccountOfferType = try container.decode(DatabaseAccountOfferTypeEnum?.self, forKey: .databaseAccountOfferType)
    }
    if container.contains(.ipRangeFilter) {
        self.ipRangeFilter = try container.decode(String?.self, forKey: .ipRangeFilter)
    }
    if container.contains(.enableAutomaticFailover) {
        self.enableAutomaticFailover = try container.decode(Bool?.self, forKey: .enableAutomaticFailover)
    }
    if container.contains(.consistencyPolicy) {
        self.consistencyPolicy = try container.decode(ConsistencyPolicyData?.self, forKey: .consistencyPolicy)
    }
    if container.contains(.capabilities) {
        self.capabilities = try container.decode([CapabilityData?]?.self, forKey: .capabilities)
    }
    if container.contains(.writeLocations) {
        self.writeLocations = try container.decode([LocationData?]?.self, forKey: .writeLocations)
    }
    if container.contains(.readLocations) {
        self.readLocations = try container.decode([LocationData?]?.self, forKey: .readLocations)
    }
    if container.contains(.failoverPolicies) {
        self.failoverPolicies = try container.decode([FailoverPolicyData?]?.self, forKey: .failoverPolicies)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.provisioningState != nil {try container.encode(self.provisioningState, forKey: .provisioningState)}
    if self.documentEndpoint != nil {try container.encode(self.documentEndpoint, forKey: .documentEndpoint)}
    if self.databaseAccountOfferType != nil {try container.encode(self.databaseAccountOfferType, forKey: .databaseAccountOfferType)}
    if self.ipRangeFilter != nil {try container.encode(self.ipRangeFilter, forKey: .ipRangeFilter)}
    if self.enableAutomaticFailover != nil {try container.encode(self.enableAutomaticFailover, forKey: .enableAutomaticFailover)}
    if self.consistencyPolicy != nil {try container.encode(self.consistencyPolicy as! ConsistencyPolicyData?, forKey: .consistencyPolicy)}
    if self.capabilities != nil {try container.encode(self.capabilities as! [CapabilityData?]?, forKey: .capabilities)}
    if self.writeLocations != nil {try container.encode(self.writeLocations as! [LocationData?]?, forKey: .writeLocations)}
    if self.readLocations != nil {try container.encode(self.readLocations as! [LocationData?]?, forKey: .readLocations)}
    if self.failoverPolicies != nil {try container.encode(self.failoverPolicies as! [FailoverPolicyData?]?, forKey: .failoverPolicies)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountPropertiesProtocol() -> DatabaseAccountPropertiesProtocol {
    return DatabaseAccountPropertiesData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountRegenerateKeyParametersData : DatabaseAccountRegenerateKeyParametersProtocol {
    public var keyKind: KeyKindEnum

        enum CodingKeys: String, CodingKey {case keyKind = "keyKind"
        }

  public init(keyKind: KeyKindEnum)  {
    self.keyKind = keyKind
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      self.keyKind = try container.decode(KeyKindEnum.self, forKey: .keyKind)
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.keyKind, forKey: .keyKind)
  }
}

extension DataFactory {
  public static func createDatabaseAccountRegenerateKeyParametersProtocol(keyKind: KeyKindEnum) -> DatabaseAccountRegenerateKeyParametersProtocol {
    return DatabaseAccountRegenerateKeyParametersData(keyKind: keyKind)
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct DatabaseAccountsListResultData : DatabaseAccountsListResultProtocol {
    public var value: [DatabaseAccountProtocol?]?

        enum CodingKeys: String, CodingKey {case value = "value"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.value) {
        self.value = try container.decode([DatabaseAccountData?]?.self, forKey: .value)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.value != nil {try container.encode(self.value as! [DatabaseAccountData?]?, forKey: .value)}
  }
}

extension DataFactory {
  public static func createDatabaseAccountsListResultProtocol() -> DatabaseAccountsListResultProtocol {
    return DatabaseAccountsListResultData()
  }
}


// DefaultConsistencyLevel enumerates the values for default consistency level.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
public enum DefaultConsistencyLevelEnum: String, Codable
{
// BoundedStaleness specifies the bounded staleness state for default consistency level.
    case BoundedStaleness = "BoundedStaleness"
// ConsistentPrefix specifies the consistent prefix state for default consistency level.
    case ConsistentPrefix = "ConsistentPrefix"
// Eventual specifies the eventual state for default consistency level.
    case Eventual = "Eventual"
// Session specifies the session state for default consistency level.
    case Session = "Session"
// Strong specifies the strong state for default consistency level.
    case Strong = "Strong"
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct FailoverPoliciesData : FailoverPoliciesProtocol {
    public var failoverPolicies: [FailoverPolicyProtocol]

        enum CodingKeys: String, CodingKey {case failoverPolicies = "failoverPolicies"
        }

  public init(failoverPolicies: [FailoverPolicyProtocol])  {
    self.failoverPolicies = failoverPolicies
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      self.failoverPolicies = try container.decode([FailoverPolicyData].self, forKey: .failoverPolicies)
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.failoverPolicies as! [FailoverPolicyData], forKey: .failoverPolicies)
  }
}

extension DataFactory {
  public static func createFailoverPoliciesProtocol(failoverPolicies: [FailoverPolicyProtocol]) -> FailoverPoliciesProtocol {
    return FailoverPoliciesData(failoverPolicies: failoverPolicies)
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct FailoverPolicyData : FailoverPolicyProtocol {
    public var id: String?
    public var locationName: String?
    public var failoverPriority: Int32?

        enum CodingKeys: String, CodingKey {case id = "id"
        case locationName = "locationName"
        case failoverPriority = "failoverPriority"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.id) {
        self.id = try container.decode(String?.self, forKey: .id)
    }
    if container.contains(.locationName) {
        self.locationName = try container.decode(String?.self, forKey: .locationName)
    }
    if container.contains(.failoverPriority) {
        self.failoverPriority = try container.decode(Int32?.self, forKey: .failoverPriority)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.id != nil {try container.encode(self.id, forKey: .id)}
    if self.locationName != nil {try container.encode(self.locationName, forKey: .locationName)}
    if self.failoverPriority != nil {try container.encode(self.failoverPriority, forKey: .failoverPriority)}
  }
}

extension DataFactory {
  public static func createFailoverPolicyProtocol() -> FailoverPolicyProtocol {
    return FailoverPolicyData()
  }
}


// KeyKind enumerates the values for key kind.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
public enum KeyKindEnum: String, Codable
{
// Primary specifies the primary state for key kind.
    case Primary = "primary"
// PrimaryReadonly specifies the primary readonly state for key kind.
    case PrimaryReadonly = "primaryReadonly"
// Secondary specifies the secondary state for key kind.
    case Secondary = "secondary"
// SecondaryReadonly specifies the secondary readonly state for key kind.
    case SecondaryReadonly = "secondaryReadonly"
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct LocationData : LocationProtocol {
    public var id: String?
    public var locationName: String?
    public var documentEndpoint: String?
    public var provisioningState: String?
    public var failoverPriority: Int32?

        enum CodingKeys: String, CodingKey {case id = "id"
        case locationName = "locationName"
        case documentEndpoint = "documentEndpoint"
        case provisioningState = "provisioningState"
        case failoverPriority = "failoverPriority"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.id) {
        self.id = try container.decode(String?.self, forKey: .id)
    }
    if container.contains(.locationName) {
        self.locationName = try container.decode(String?.self, forKey: .locationName)
    }
    if container.contains(.documentEndpoint) {
        self.documentEndpoint = try container.decode(String?.self, forKey: .documentEndpoint)
    }
    if container.contains(.provisioningState) {
        self.provisioningState = try container.decode(String?.self, forKey: .provisioningState)
    }
    if container.contains(.failoverPriority) {
        self.failoverPriority = try container.decode(Int32?.self, forKey: .failoverPriority)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.id != nil {try container.encode(self.id, forKey: .id)}
    if self.locationName != nil {try container.encode(self.locationName, forKey: .locationName)}
    if self.documentEndpoint != nil {try container.encode(self.documentEndpoint, forKey: .documentEndpoint)}
    if self.provisioningState != nil {try container.encode(self.provisioningState, forKey: .provisioningState)}
    if self.failoverPriority != nil {try container.encode(self.failoverPriority, forKey: .failoverPriority)}
  }
}

extension DataFactory {
  public static func createLocationProtocol() -> LocationProtocol {
    return LocationData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricAvailabilityData : MetricAvailabilityProtocol {
    public var timeGrain: String?
    public var retention: String?

        enum CodingKeys: String, CodingKey {case timeGrain = "timeGrain"
        case retention = "retention"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.timeGrain) {
        self.timeGrain = try container.decode(String?.self, forKey: .timeGrain)
    }
    if container.contains(.retention) {
        self.retention = try container.decode(String?.self, forKey: .retention)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.timeGrain != nil {try container.encode(self.timeGrain, forKey: .timeGrain)}
    if self.retention != nil {try container.encode(self.retention, forKey: .retention)}
  }
}

extension DataFactory {
  public static func createMetricAvailabilityProtocol() -> MetricAvailabilityProtocol {
    return MetricAvailabilityData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricData : MetricProtocol {
    public var startTime: Date?
    public var endTime: Date?
    public var timeGrain: String?
    public var unit: UnitTypeEnum?
    public var name: MetricNameProtocol?
    public var metricValues: [MetricValueProtocol?]?

        enum CodingKeys: String, CodingKey {case startTime = "startTime"
        case endTime = "endTime"
        case timeGrain = "timeGrain"
        case unit = "unit"
        case name = "name"
        case metricValues = "metricValues"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.startTime) {
        self.startTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .startTime)), format: .dateTime)
    }
    if container.contains(.endTime) {
        self.endTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .endTime)), format: .dateTime)
    }
    if container.contains(.timeGrain) {
        self.timeGrain = try container.decode(String?.self, forKey: .timeGrain)
    }
    if container.contains(.unit) {
        self.unit = try container.decode(UnitTypeEnum?.self, forKey: .unit)
    }
    if container.contains(.name) {
        self.name = try container.decode(MetricNameData?.self, forKey: .name)
    }
    if container.contains(.metricValues) {
        self.metricValues = try container.decode([MetricValueData?]?.self, forKey: .metricValues)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.startTime != nil {
        try container.encode(DateConverter.toString(date: self.startTime!, format: .dateTime), forKey: .startTime)
    }
    if self.endTime != nil {
        try container.encode(DateConverter.toString(date: self.endTime!, format: .dateTime), forKey: .endTime)
    }
    if self.timeGrain != nil {try container.encode(self.timeGrain, forKey: .timeGrain)}
    if self.unit != nil {try container.encode(self.unit, forKey: .unit)}
    if self.name != nil {try container.encode(self.name as! MetricNameData?, forKey: .name)}
    if self.metricValues != nil {try container.encode(self.metricValues as! [MetricValueData?]?, forKey: .metricValues)}
  }
}

extension DataFactory {
  public static func createMetricProtocol() -> MetricProtocol {
    return MetricData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricDefinitionData : MetricDefinitionProtocol {
    public var metricAvailabilities: [MetricAvailabilityProtocol?]?
    public var primaryAggregationType: PrimaryAggregationTypeEnum?
    public var unit: UnitTypeEnum?
    public var resourceUri: String?
    public var name: MetricNameProtocol?

        enum CodingKeys: String, CodingKey {case metricAvailabilities = "metricAvailabilities"
        case primaryAggregationType = "primaryAggregationType"
        case unit = "unit"
        case resourceUri = "resourceUri"
        case name = "name"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.metricAvailabilities) {
        self.metricAvailabilities = try container.decode([MetricAvailabilityData?]?.self, forKey: .metricAvailabilities)
    }
    if container.contains(.primaryAggregationType) {
        self.primaryAggregationType = try container.decode(PrimaryAggregationTypeEnum?.self, forKey: .primaryAggregationType)
    }
    if container.contains(.unit) {
        self.unit = try container.decode(UnitTypeEnum?.self, forKey: .unit)
    }
    if container.contains(.resourceUri) {
        self.resourceUri = try container.decode(String?.self, forKey: .resourceUri)
    }
    if container.contains(.name) {
        self.name = try container.decode(MetricNameData?.self, forKey: .name)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.metricAvailabilities != nil {try container.encode(self.metricAvailabilities as! [MetricAvailabilityData?]?, forKey: .metricAvailabilities)}
    if self.primaryAggregationType != nil {try container.encode(self.primaryAggregationType, forKey: .primaryAggregationType)}
    if self.unit != nil {try container.encode(self.unit, forKey: .unit)}
    if self.resourceUri != nil {try container.encode(self.resourceUri, forKey: .resourceUri)}
    if self.name != nil {try container.encode(self.name as! MetricNameData?, forKey: .name)}
  }
}

extension DataFactory {
  public static func createMetricDefinitionProtocol() -> MetricDefinitionProtocol {
    return MetricDefinitionData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricDefinitionsListResultData : MetricDefinitionsListResultProtocol {
    public var value: [MetricDefinitionProtocol?]?

        enum CodingKeys: String, CodingKey {case value = "value"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.value) {
        self.value = try container.decode([MetricDefinitionData?]?.self, forKey: .value)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.value != nil {try container.encode(self.value as! [MetricDefinitionData?]?, forKey: .value)}
  }
}

extension DataFactory {
  public static func createMetricDefinitionsListResultProtocol() -> MetricDefinitionsListResultProtocol {
    return MetricDefinitionsListResultData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricListResultData : MetricListResultProtocol {
    public var value: [MetricProtocol?]?

        enum CodingKeys: String, CodingKey {case value = "value"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.value) {
        self.value = try container.decode([MetricData?]?.self, forKey: .value)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.value != nil {try container.encode(self.value as! [MetricData?]?, forKey: .value)}
  }
}

extension DataFactory {
  public static func createMetricListResultProtocol() -> MetricListResultProtocol {
    return MetricListResultData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricNameData : MetricNameProtocol {
    public var value: String?
    public var localizedValue: String?

        enum CodingKeys: String, CodingKey {case value = "value"
        case localizedValue = "localizedValue"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.value) {
        self.value = try container.decode(String?.self, forKey: .value)
    }
    if container.contains(.localizedValue) {
        self.localizedValue = try container.decode(String?.self, forKey: .localizedValue)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.value != nil {try container.encode(self.value, forKey: .value)}
    if self.localizedValue != nil {try container.encode(self.localizedValue, forKey: .localizedValue)}
  }
}

extension DataFactory {
  public static func createMetricNameProtocol() -> MetricNameProtocol {
    return MetricNameData()
  }
}


// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MetricValueData : MetricValueProtocol {
    public var _count: Double?
    public var average: Double?
    public var maximum: Double?
    public var minimum: Double?
    public var timestamp: Date?
    public var total: Double?

        enum CodingKeys: String, CodingKey {case _count = "_count"
        case average = "average"
        case maximum = "maximum"
        case minimum = "minimum"
        case timestamp = "timestamp"
        case total = "total"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(._count) {
        self._count = try container.decode(Double?.self, forKey: ._count)
    }
    if container.contains(.average) {
        self.average = try container.decode(Double?.self, forKey: .average)
    }
    if container.contains(.maximum) {
        self.maximum = try container.decode(Double?.self, forKey: .maximum)
    }
    if container.contains(.minimum) {
        self.minimum = try container.decode(Double?.self, forKey: .minimum)
    }
    if container.contains(.timestamp) {
        self.timestamp = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .timestamp)), format: .dateTime)
    }
    if container.contains(.total) {
        self.total = try container.decode(Double?.self, forKey: .total)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self._count != nil {try container.encode(self._count, forKey: ._count)}
    if self.average != nil {try container.encode(self.average, forKey: .average)}
    if self.maximum != nil {try container.encode(self.maximum, forKey: .maximum)}
    if self.minimum != nil {try container.encode(self.minimum, forKey: .minimum)}
    if self.timestamp != nil {
        try container.encode(DateConverter.toString(date: self.timestamp!, format: .dateTime), forKey: .timestamp)
    }
    if self.total != nil {try container.encode(self.total, forKey: .total)}
  }
}

extension DataFactory {
  public static func createMetricValueProtocol() -> MetricValueProtocol {
    return MetricValueData()
  }
}