// 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 ConnectivityParametersData : ConnectivityParametersProtocol {
    public var source: ConnectivitySourceProtocol
    public var destination: ConnectivityDestinationProtocol

        enum CodingKeys: String, CodingKey {case source = "source"
        case destination = "destination"
        }

  public init(source: ConnectivitySourceProtocol, destination: ConnectivityDestinationProtocol)  {
    self.source = source
    self.destination = destination
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      self.source = try container.decode(ConnectivitySourceData.self, forKey: .source)
    self.destination = try container.decode(ConnectivityDestinationData.self, forKey: .destination)
    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.source as! ConnectivitySourceData, forKey: .source)
    try container.encode(self.destination as! ConnectivityDestinationData, forKey: .destination)
  }
}

extension DataFactory {
  public static func createConnectivityParametersProtocol(source: ConnectivitySourceProtocol, destination: ConnectivityDestinationProtocol) -> ConnectivityParametersProtocol {
    return ConnectivityParametersData(source: source, destination: destination)
  }
}
