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

extension Commands.Service {
// Validate validate if a resource can be created.
    internal class ValidateCommand : BaseCommand, ServiceValidate {
        public var resourceGroupName : String
        public var subscriptionId : String
        public var apiVersion = "2016-03-01"
    public var validateRequest :  ValidateRequestProtocol?

        public init(resourceGroupName: String, subscriptionId: String, validateRequest: ValidateRequestProtocol) {
            self.resourceGroupName = resourceGroupName
            self.subscriptionId = subscriptionId
            self.validateRequest = validateRequest
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/validate"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

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

        }
        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(validateRequest as? ValidateRequestData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        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)
                let result = try decoder.decode(ValidateResponseData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (ValidateResponseProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: ValidateResponseData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


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

extension Commands.Service {
// ValidateMove validate whether a resource can be moved.
    internal class ValidateMoveCommand : BaseCommand, ServiceValidateMove {
        public var resourceGroupName : String
        public var subscriptionId : String
        public var apiVersion = "2016-03-01"
    public var moveResourceEnvelope :  CsmMoveResourceEnvelopeProtocol?

        public init(resourceGroupName: String, subscriptionId: String, moveResourceEnvelope: CsmMoveResourceEnvelopeProtocol) {
            self.resourceGroupName = resourceGroupName
            self.subscriptionId = subscriptionId
            self.moveResourceEnvelope = moveResourceEnvelope
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/validateMoveResources"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

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

        }
        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(moveResourceEnvelope as? CsmMoveResourceEnvelopeData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

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


import Foundation
import azureSwiftRuntime
public protocol ServiceVerifyHostingEnvironmentVnet  {
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var parameters :  VnetParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (VnetValidationFailureDetailsProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Service {
// VerifyHostingEnvironmentVnet verifies if this VNET is compatible with an App Service Environment by analyzing the
// Network Security Group rules.
    internal class VerifyHostingEnvironmentVnetCommand : BaseCommand, ServiceVerifyHostingEnvironmentVnet {
        public var subscriptionId : String
        public var apiVersion = "2016-03-01"
    public var parameters :  VnetParametersProtocol?

        public init(subscriptionId: String, parameters: VnetParametersProtocol) {
            self.subscriptionId = subscriptionId
            self.parameters = parameters
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.Web/verifyHostingEnvironmentVnet"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

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

        }
        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(parameters as? VnetParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        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)
                let result = try decoder.decode(VnetValidationFailureDetailsData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (VnetValidationFailureDetailsProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: VnetValidationFailureDetailsData?, 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.

// TopLevelDomains is the webSite Management Client
import Foundation
import azureSwiftRuntime
extension Commands {
public struct TopLevelDomains {
    public static func Get(name: String, subscriptionId: String) -> TopLevelDomainsGet {
        return GetCommand(name: name, subscriptionId: subscriptionId)
    }
    public static func List(subscriptionId: String) -> TopLevelDomainsList {
        return ListCommand(subscriptionId: subscriptionId)
    }
    public static func ListAgreements(name: String, subscriptionId: String, agreementOption: TopLevelDomainAgreementOptionProtocol) -> TopLevelDomainsListAgreements {
        return ListAgreementsCommand(name: name, subscriptionId: subscriptionId, agreementOption: agreementOption)
    }
}
}


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

extension Commands.TopLevelDomains {
// Get get details of a top-level domain.
    internal class GetCommand : BaseCommand, TopLevelDomainsGet {
        public var name : String
        public var subscriptionId : String
        public var apiVersion = "2015-04-01"

        public init(name: String, subscriptionId: String) {
            self.name = name
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/topLevelDomains/{name}"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{name}"] = String(describing: self.name)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            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)
                let result = try decoder.decode(TopLevelDomainData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (TopLevelDomainProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: TopLevelDomainData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


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

extension Commands.TopLevelDomains {
// List get all top-level domains supported for registration.
    internal class ListCommand : BaseCommand, TopLevelDomainsList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var apiVersion = "2015-04-01"

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

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            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(TopLevelDomainCollectionData?.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 (TopLevelDomainCollectionProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: TopLevelDomainCollectionData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


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

extension Commands.TopLevelDomains {
// ListAgreements gets all legal agreements that user needs to accept before purchasing a domain.
    internal class ListAgreementsCommand : BaseCommand, TopLevelDomainsListAgreements {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var name : String
        public var subscriptionId : String
        public var apiVersion = "2015-04-01"
    public var agreementOption :  TopLevelDomainAgreementOptionProtocol?

        public init(name: String, subscriptionId: String, agreementOption: TopLevelDomainAgreementOptionProtocol) {
            self.name = name
            self.subscriptionId = subscriptionId
            self.agreementOption = agreementOption
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/topLevelDomains/{name}/listAgreements"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

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

        }
        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(agreementOption as? TopLevelDomainAgreementOptionData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        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(TldLegalAgreementCollectionData?.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 (TldLegalAgreementCollectionProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: TldLegalAgreementCollectionData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}