// 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 DscConfigurationPropertiesData : DscConfigurationPropertiesProtocol {
    public var provisioningState: DscConfigurationProvisioningStateEnum?
    public var jobCount: Int32?
    public var parameters: [String:DscConfigurationParameterProtocol?]?
    public var source: ContentSourceProtocol?
    public var state: DscConfigurationStateEnum?
    public var logVerbose: Bool?
    public var creationTime: Date?
    public var lastModifiedTime: Date?
    public var description: String?

        enum CodingKeys: String, CodingKey {case provisioningState = "provisioningState"
        case jobCount = "jobCount"
        case parameters = "parameters"
        case source = "source"
        case state = "state"
        case logVerbose = "logVerbose"
        case creationTime = "creationTime"
        case lastModifiedTime = "lastModifiedTime"
        case description = "description"
        }

  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(DscConfigurationProvisioningStateEnum?.self, forKey: .provisioningState)
    }
    if container.contains(.jobCount) {
        self.jobCount = try container.decode(Int32?.self, forKey: .jobCount)
    }
    if container.contains(.parameters) {
        self.parameters = try container.decode([String:DscConfigurationParameterData?]?.self, forKey: .parameters)
    }
    if container.contains(.source) {
        self.source = try container.decode(ContentSourceData?.self, forKey: .source)
    }
    if container.contains(.state) {
        self.state = try container.decode(DscConfigurationStateEnum?.self, forKey: .state)
    }
    if container.contains(.logVerbose) {
        self.logVerbose = try container.decode(Bool?.self, forKey: .logVerbose)
    }
    if container.contains(.creationTime) {
        self.creationTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .creationTime)), format: .dateTime)
    }
    if container.contains(.lastModifiedTime) {
        self.lastModifiedTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .lastModifiedTime)), format: .dateTime)
    }
    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.provisioningState != nil {try container.encode(self.provisioningState, forKey: .provisioningState)}
    if self.jobCount != nil {try container.encode(self.jobCount, forKey: .jobCount)}
    if self.parameters != nil {try container.encode(self.parameters, forKey: .parameters)}
    if self.source != nil {try container.encode(self.source as! ContentSourceData?, forKey: .source)}
    if self.state != nil {try container.encode(self.state, forKey: .state)}
    if self.logVerbose != nil {try container.encode(self.logVerbose, forKey: .logVerbose)}
    if self.creationTime != nil {
        try container.encode(DateConverter.toString(date: self.creationTime!, format: .dateTime), forKey: .creationTime)
    }
    if self.lastModifiedTime != nil {
        try container.encode(DateConverter.toString(date: self.lastModifiedTime!, format: .dateTime), forKey: .lastModifiedTime)
    }
    if self.description != nil {try container.encode(self.description, forKey: .description)}
  }
}

extension DataFactory {
  public static func createDscConfigurationPropertiesProtocol() -> DscConfigurationPropertiesProtocol {
    return DscConfigurationPropertiesData()
  }
}
