// 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 IoTHubStreamInputDataSourcePropertiesData : IoTHubStreamInputDataSourcePropertiesProtocol {
    public var iotHubNamespace: String?
    public var sharedAccessPolicyName: String?
    public var sharedAccessPolicyKey: String?
    public var consumerGroupName: String?
    public var endpoint: String?

        enum CodingKeys: String, CodingKey {case iotHubNamespace = "iotHubNamespace"
        case sharedAccessPolicyName = "sharedAccessPolicyName"
        case sharedAccessPolicyKey = "sharedAccessPolicyKey"
        case consumerGroupName = "consumerGroupName"
        case endpoint = "endpoint"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.iotHubNamespace) {
        self.iotHubNamespace = try container.decode(String?.self, forKey: .iotHubNamespace)
    }
    if container.contains(.sharedAccessPolicyName) {
        self.sharedAccessPolicyName = try container.decode(String?.self, forKey: .sharedAccessPolicyName)
    }
    if container.contains(.sharedAccessPolicyKey) {
        self.sharedAccessPolicyKey = try container.decode(String?.self, forKey: .sharedAccessPolicyKey)
    }
    if container.contains(.consumerGroupName) {
        self.consumerGroupName = try container.decode(String?.self, forKey: .consumerGroupName)
    }
    if container.contains(.endpoint) {
        self.endpoint = try container.decode(String?.self, forKey: .endpoint)
    }
    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.iotHubNamespace != nil {try container.encode(self.iotHubNamespace, forKey: .iotHubNamespace)}
    if self.sharedAccessPolicyName != nil {try container.encode(self.sharedAccessPolicyName, forKey: .sharedAccessPolicyName)}
    if self.sharedAccessPolicyKey != nil {try container.encode(self.sharedAccessPolicyKey, forKey: .sharedAccessPolicyKey)}
    if self.consumerGroupName != nil {try container.encode(self.consumerGroupName, forKey: .consumerGroupName)}
    if self.endpoint != nil {try container.encode(self.endpoint, forKey: .endpoint)}
  }
}

extension DataFactory {
  public static func createIoTHubStreamInputDataSourcePropertiesProtocol() -> IoTHubStreamInputDataSourcePropertiesProtocol {
    return IoTHubStreamInputDataSourcePropertiesData()
  }
}
