// 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 ResourceFileData : ResourceFileProtocol {
    public var blobSource: String
    public var filePath: String
    public var fileMode: String?

        enum CodingKeys: String, CodingKey {case blobSource = "blobSource"
        case filePath = "filePath"
        case fileMode = "fileMode"
        }

  public init(blobSource: String, filePath: String)  {
    self.blobSource = blobSource
    self.filePath = filePath
  }

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

extension DataFactory {
  public static func createResourceFileProtocol(blobSource: String, filePath: String) -> ResourceFileProtocol {
    return ResourceFileData(blobSource: blobSource, filePath: filePath)
  }
}
