// 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 OperationStatusData : OperationStatusProtocol {
    public var id: String?
    public var name: String?
    public var startTime: String?
    public var endTime: String?
    public var status: String?
    public var error: ErrorResponseProtocol?

        enum CodingKeys: String, CodingKey {case id = "id"
        case name = "name"
        case startTime = "startTime"
        case endTime = "endTime"
        case status = "status"
        case error = "error"
        }

  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(.name) {
        self.name = try container.decode(String?.self, forKey: .name)
    }
    if container.contains(.startTime) {
        self.startTime = try container.decode(String?.self, forKey: .startTime)
    }
    if container.contains(.endTime) {
        self.endTime = try container.decode(String?.self, forKey: .endTime)
    }
    if container.contains(.status) {
        self.status = try container.decode(String?.self, forKey: .status)
    }
    if container.contains(.error) {
        self.error = try container.decode(ErrorResponseData?.self, forKey: .error)
    }
    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.startTime != nil {try container.encode(self.startTime, forKey: .startTime)}
    if self.endTime != nil {try container.encode(self.endTime, forKey: .endTime)}
    if self.status != nil {try container.encode(self.status, forKey: .status)}
    if self.error != nil {try container.encode(self.error as! ErrorResponseData?, forKey: .error)}
  }
}

extension DataFactory {
  public static func createOperationStatusProtocol() -> OperationStatusProtocol {
    return OperationStatusData()
  }
}
