// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
internal struct ServiceSetPropertiesHeadersData : ServiceSetPropertiesHeadersProtocol {
    public var requestId: String?
    public var version: String?

    enum CodingKeys: String, CodingKey {
        case requestId = "x-ms-request-id"
        case version = "x-ms-version"
    }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    if container.contains(.requestId) {
        requestId = try container.decode(String.self, forKey: .requestId)
    }
    if container.contains(.version) {
        version = try container.decode(String.self, forKey: .version)
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.requestId != nil {try container.encode(requestId, forKey: .requestId)}
    if self.version != nil {try container.encode(version, forKey: .version)}
  }
}

extension DataFactory {
  public static func createServiceSetPropertiesHeadersProtocol() -> ServiceSetPropertiesHeadersProtocol {
    return ServiceSetPropertiesHeadersData()
  }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
public struct SignedIdentifierData : SignedIdentifierProtocol {
    public var id: String
    public var accessPolicy: AccessPolicyProtocol

    enum CodingKeys: String, CodingKey {
        case id = "Id"
        case accessPolicy = "AccessPolicy"
    }

  public init(id: String, accessPolicy: AccessPolicyProtocol)  {
    self.id = id
    self.accessPolicy = accessPolicy
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    id = try container.decode(String.self, forKey: .id)
    accessPolicy = try container.decode(AccessPolicyData.self, forKey: .accessPolicy)
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(id, forKey: .id)
    try container.encode(accessPolicy as! AccessPolicyData, forKey: .accessPolicy)
  }
}

extension DataFactory {
  public static func createSignedIdentifierProtocol(id: String, accessPolicy: AccessPolicyProtocol) -> SignedIdentifierProtocol {
    return SignedIdentifierData(id: id, accessPolicy: accessPolicy)
  }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
internal struct StorageServicePropertiesData : StorageServicePropertiesProtocol {
    public var logging: LoggingProtocol?
    public var hourMetrics: MetricsProtocol?
    public var minuteMetrics: MetricsProtocol?
    public var cors: [CorsRuleProtocol?]?
    public var defaultServiceVersion: String?

    enum CodingKeys: String, CodingKey {
        case logging = "Logging"
        case hourMetrics = "HourMetrics"
        case minuteMetrics = "MinuteMetrics"
        case cors = "Cors"
        case defaultServiceVersion = "DefaultServiceVersion"
    }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    if container.contains(.logging) {
        logging = try container.decode(LoggingData?.self, forKey: .logging)
    }
    if container.contains(.hourMetrics) {
        hourMetrics = try container.decode(MetricsData?.self, forKey: .hourMetrics)
    }
    if container.contains(.minuteMetrics) {
        minuteMetrics = try container.decode(MetricsData?.self, forKey: .minuteMetrics)
    }
    if container.contains(.cors) {
        cors = try container.decode([CorsRuleData?]?.self, forKey: .cors)
    }
    if container.contains(.defaultServiceVersion) {
        defaultServiceVersion = try container.decode(String.self, forKey: .defaultServiceVersion)
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.logging != nil {try container.encode(logging as! LoggingData?, forKey: .logging)}
    if self.hourMetrics != nil {try container.encode(hourMetrics as! MetricsData?, forKey: .hourMetrics)}
    if self.minuteMetrics != nil {try container.encode(minuteMetrics as! MetricsData?, forKey: .minuteMetrics)}
    if self.cors != nil {try container.encode(cors as! [CorsRuleData?]?, forKey: .cors)}
    if self.defaultServiceVersion != nil {try container.encode(defaultServiceVersion, forKey: .defaultServiceVersion)}
  }
}

extension DataFactory {
  public static func createStorageServicePropertiesProtocol() -> StorageServicePropertiesProtocol {
    return StorageServicePropertiesData()
  }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
internal struct StorageServiceStatsData : StorageServiceStatsProtocol {
    public var geoReplication: GeoReplicationProtocol?

    enum CodingKeys: String, CodingKey {
        case geoReplication = "GeoReplication"
    }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    if container.contains(.geoReplication) {
        geoReplication = try container.decode(GeoReplicationData?.self, forKey: .geoReplication)
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.geoReplication != nil {try container.encode(geoReplication as! GeoReplicationData?, forKey: .geoReplication)}
  }
}

extension DataFactory {
  public static func createStorageServiceStatsProtocol() -> StorageServiceStatsProtocol {
    return StorageServiceStatsData()
  }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// AccessPolicyProtocol is an Access policy
public protocol AccessPolicyProtocol : Codable {
     var start: Date? { get set }
     var expiry: Date? { get set }
     var permission: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobEnumerationResultsProtocol is an enumeration of blobs
public protocol BlobEnumerationResultsProtocol : Codable {
     var serviceEndpoint: String? { get set }
     var containerName: String? { get set }
     var prefix: String? { get set }
     var marker: String? { get set }
     var maxResults: Int32? { get set }
     var delimiter: String? { get set }
     var blobs: [BlobProtocol?]? { get set }
     var nextMarker: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobPropertiesProtocol is properties of a blob
public protocol BlobPropertiesProtocol : Codable {
     var lastModified: Date? { get set }
     var etag: String? { get set }
     var contentLength: Int32? { get set }
     var contentType: String? { get set }
     var contentEncoding: String? { get set }
     var contentLanguage: String? { get set }
     var contentMD5: String? { get set }
     var contentDisposition: String? { get set }
     var cacheControl: String? { get set }
     var xMsBlobSequenceNumber: String? { get set }
     var blobType: String? { get set }
     var leaseStatus: LeaseStatusType? { get set }
     var leaseState: LeaseStateType? { get set }
     var leaseDuration: LeaseDurationType? { get set }
     var copyId: String? { get set }
     var copyStatus: CopyStatusType? { get set }
     var copySource: String? { get set }
     var copyProgress: String? { get set }
     var copyCompletionTime: Date? { get set }
     var copyStatusDescription: String? { get set }
     var serverEncrypted: Bool? { get set }
     var incrementalCopy: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobProtocol is an Azure Storage blob
public protocol BlobProtocol : Codable {
     var name: String? { get set }
     var snapshot: Date? { get set }
     var properties: BlobPropertiesProtocol? { get set }
     var metadata: [String:String]? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsAbortCopyHeadersProtocol is defines headers for AbortCopy operation.
public protocol BlobsAbortCopyHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsAppendBlockHeadersProtocol is defines headers for AppendBlock operation.
public protocol BlobsAppendBlockHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var contentMD5: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var blobAppendOffset: String? { get set }
     var blobCommittedBlockCount: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsCopyHeadersProtocol is defines headers for Copy operation.
public protocol BlobsCopyHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var copyId: String? { get set }
     var copyStatus: CopyStatusType? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsDeleteHeadersProtocol is defines headers for Delete operation.
public protocol BlobsDeleteHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsGetHeadersProtocol is defines headers for Get operation.
public protocol BlobsGetHeadersProtocol : Codable {
     var lastModified: String? { get set }
     var metadata: [String:String]? { get set }
     var contentLength: Int32? { get set }
     var contentType: String? { get set }
     var contentRange: String? { get set }
     var eTag: String? { get set }
     var contentMD5: String? { get set }
     var contentEncoding: String? { get set }
     var cacheControl: String? { get set }
     var contentDisposition: String? { get set }
     var blobSequenceNumber: String? { get set }
     var blobType: BlobType? { get set }
     var copyCompletionTime: Date? { get set }
     var copyStatusDescription: String? { get set }
     var copyId: String? { get set }
     var copyProgress: String? { get set }
     var copySource: String? { get set }
     var copyStatus: CopyStatusType? { get set }
     var leaseDuration: LeaseDurationType? { get set }
     var leaseState: LeaseStateType? { get set }
     var leaseStatus: LeaseStatusType? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var acceptRanges: String? { get set }
     var date: Date? { get set }
     var blobCommittedBlockCount: String? { get set }
     var isServerEncrypted: Bool? { get set }
     var blobContentMD5: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsGetMetadataHeadersProtocol is defines headers for GetMetadata operation.
public protocol BlobsGetMetadataHeadersProtocol : Codable {
     var metadata: [String:String]? { get set }
     var lastModified: String? { get set }
     var eTag: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsGetPropertiesHeadersProtocol is defines headers for GetProperties operation.
public protocol BlobsGetPropertiesHeadersProtocol : Codable {
     var lastModified: String? { get set }
     var metadata: [String:String]? { get set }
     var blobType: BlobType? { get set }
     var copyCompletionTime: Date? { get set }
     var copyStatusDescription: String? { get set }
     var copyId: String? { get set }
     var copyProgress: String? { get set }
     var copySource: String? { get set }
     var copyStatus: CopyStatusType? { get set }
     var isIncrementalCopy: Bool? { get set }
     var leaseDuration: LeaseDurationType? { get set }
     var leaseState: LeaseStateType? { get set }
     var leaseStatus: LeaseStatusType? { get set }
     var contentLength: Int32? { get set }
     var contentType: String? { get set }
     var eTag: String? { get set }
     var contentMD5: String? { get set }
     var contentEncoding: String? { get set }
     var contentDisposition: String? { get set }
     var cacheControl: String? { get set }
     var blobSequenceNumber: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var acceptRanges: String? { get set }
     var blobCommittedBlockCount: String? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsLeaseHeadersProtocol is defines headers for Lease operation.
public protocol BlobsLeaseHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var leaseId: String? { get set }
     var leaseTime: Int32? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsPutHeadersProtocol is defines headers for Put operation.
public protocol BlobsPutHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var contentMD5: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsSetMetadataHeadersProtocol is defines headers for SetMetadata operation.
public protocol BlobsSetMetadataHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsSetPropertiesHeadersProtocol is defines headers for SetProperties operation.
public protocol BlobsSetPropertiesHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var blobSequenceNumber: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlobsTakeSnapshotHeadersProtocol is defines headers for TakeSnapshot operation.
public protocol BlobsTakeSnapshotHeadersProtocol : Codable {
     var snapshot: String? { get set }
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlockBlobsGetBlockListHeadersProtocol is defines headers for GetBlockList operation.
public protocol BlockBlobsGetBlockListHeadersProtocol : Codable {
     var lastModified: String? { get set }
     var eTag: String? { get set }
     var contentType: String? { get set }
     var blobContentLength: Int32? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlockBlobsPutBlockHeadersProtocol is defines headers for PutBlock operation.
public protocol BlockBlobsPutBlockHeadersProtocol : Codable {
     var contentMD5: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlockBlobsPutBlockListHeadersProtocol is defines headers for PutBlockList operation.
public protocol BlockBlobsPutBlockListHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var contentMD5: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlockListProtocol is
public protocol BlockListProtocol : Codable {
     var committedBlocks: [BlockProtocol?]? { get set }
     var uncommittedBlocks: [BlockProtocol?]? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// BlockProtocol is
public protocol BlockProtocol : Codable {
     var name: String? { get set }
     var size: Int32? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerCreateHeadersProtocol is defines headers for Create operation.
public protocol ContainerCreateHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerDeleteHeadersProtocol is defines headers for Delete operation.
public protocol ContainerDeleteHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerEnumerationResultsProtocol is an enumaration of containers
public protocol ContainerEnumerationResultsProtocol : Codable {
     var serviceEndpoint: String? { get set }
     var prefix: String? { get set }
     var marker: String? { get set }
     var maxResults: Int32? { get set }
     var containers: [ContainerProtocol?]? { get set }
     var nextMarker: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerGetAclHeadersProtocol is defines headers for GetAcl operation.
public protocol ContainerGetAclHeadersProtocol : Codable {
     var blobPublicAccess: PublicAccessType? { get set }
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerGetMetadataHeadersProtocol is defines headers for GetMetadata operation.
public protocol ContainerGetMetadataHeadersProtocol : Codable {
     var metadata: [String:String]? { get set }
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerGetPropertiesHeadersProtocol is defines headers for GetProperties operation.
public protocol ContainerGetPropertiesHeadersProtocol : Codable {
     var metadata: [String:String]? { get set }
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var leaseDuration: LeaseDurationType? { get set }
     var leaseState: LeaseStateType? { get set }
     var leaseStatus: LeaseStatusType? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var blobPublicAccess: PublicAccessType? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerLeaseHeadersProtocol is defines headers for Lease operation.
public protocol ContainerLeaseHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var leaseId: String? { get set }
     var leaseTime: Int32? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerListBlobsHeadersProtocol is defines headers for ListBlobs operation.
public protocol ContainerListBlobsHeadersProtocol : Codable {
     var contentType: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerPropertiesProtocol is properties of a container
public protocol ContainerPropertiesProtocol : Codable {
     var lastModified: Date? { get set }
     var etag: String? { get set }
     var leaseStatus: LeaseStatusType? { get set }
     var leaseState: LeaseStateType? { get set }
     var leaseDuration: LeaseDurationType? { get set }
     var publicAccess: PublicAccessType? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerProtocol is an Azure Storage container
public protocol ContainerProtocol : Codable {
     var name: String? { get set }
     var properties: ContainerPropertiesProtocol? { get set }
     var metadata: [String:String]? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerSetAclHeadersProtocol is defines headers for SetAcl operation.
public protocol ContainerSetAclHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ContainerSetMetadataHeadersProtocol is defines headers for SetMetadata operation.
public protocol ContainerSetMetadataHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// CorsRuleProtocol is CORS is an HTTP feature that enables a web application running under one domain to access
// resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents
// a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin
// domain) to call APIs in another domain
public protocol CorsRuleProtocol : Codable {
     var allowedOrigins: String { get set }
     var allowedMethods: String { get set }
     var allowedHeaders: String { get set }
     var exposedHeaders: String { get set }
     var maxAgeInSeconds: Int32 { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ErrorExceptionDetailsProtocol is
public protocol ErrorExceptionDetailsProtocol : Codable {
     var exceptionMessage: String? { get set }
     var stackTrace: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ErrorProtocol is
public protocol ErrorProtocol : Codable {
     var code: String { get set }
     var message: String { get set }
     var exceptionDetails: ErrorExceptionDetailsProtocol? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// GeoReplicationProtocol is
public protocol GeoReplicationProtocol : Codable {
     var status: GeoReplicationStatus? { get set }
     var lastSyncTime: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// LoggingProtocol is azure Analytics Logging settings.
public protocol LoggingProtocol : Codable {
     var version: String { get set }
     var delete: Bool { get set }
     var read: Bool { get set }
     var write: Bool { get set }
     var retentionPolicy: RetentionPolicyProtocol { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// MetricsProtocol is
public protocol MetricsProtocol : Codable {
     var version: String? { get set }
     var enabled: Bool? { get set }
     var includeAPIs: Bool? { get set }
     var retentionPolicy: RetentionPolicyProtocol? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// PageBlobsGetPageRangesHeadersProtocol is defines headers for GetPageRanges operation.
public protocol PageBlobsGetPageRangesHeadersProtocol : Codable {
     var lastModified: String? { get set }
     var eTag: String? { get set }
     var blobContentLength: Int32? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// PageBlobsIncrementalCopyHeadersProtocol is defines headers for IncrementalCopy operation.
public protocol PageBlobsIncrementalCopyHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var copyId: String? { get set }
     var copyStatus: CopyStatusType? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// PageBlobsPutPageHeadersProtocol is defines headers for PutPage operation.
public protocol PageBlobsPutPageHeadersProtocol : Codable {
     var eTag: String? { get set }
     var lastModified: String? { get set }
     var contentMD5: String? { get set }
     var blobContentLength: Int32? { get set }
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
     var isServerEncrypted: Bool? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// RetentionPolicyProtocol is the retention policy
public protocol RetentionPolicyProtocol : Codable {
     var enabled: Bool { get set }
     var days: Int32? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ServiceGetPropertiesHeadersProtocol is defines headers for GetProperties operation.
public protocol ServiceGetPropertiesHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ServiceGetStatsHeadersProtocol is defines headers for GetStats operation.
public protocol ServiceGetStatsHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
     var date: Date? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ServiceListContainersHeadersProtocol is defines headers for ListContainers operation.
public protocol ServiceListContainersHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// ServiceSetPropertiesHeadersProtocol is defines headers for SetProperties operation.
public protocol ServiceSetPropertiesHeadersProtocol : Codable {
     var requestId: String? { get set }
     var version: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// SignedIdentifierProtocol is signed identifier
public protocol SignedIdentifierProtocol : Codable {
     var id: String { get set }
     var accessPolicy: AccessPolicyProtocol { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// StorageServicePropertiesProtocol is storage Service Properties.
public protocol StorageServicePropertiesProtocol : Codable {
     var logging: LoggingProtocol? { get set }
     var hourMetrics: MetricsProtocol? { get set }
     var minuteMetrics: MetricsProtocol? { get set }
     var cors: [CorsRuleProtocol?]? { get set }
     var defaultServiceVersion: String? { get set }
}


// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import Foundation
// StorageServiceStatsProtocol is stats for the storage service.
public protocol StorageServiceStatsProtocol : Codable {
     var geoReplication: GeoReplicationProtocol? { get set }
}


//
//  AccountCommandTests.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/19/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class o4AccountCommandsTests : StorageTestsBase {

    func test_AccountListContainers() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = Commands.Service.ListContainers (
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName)

        command.execute(client: self.azureClient) {
            (res, error) in
            defer { e.fulfill() }
            self.checkError(error: error)

            XCTAssertNotNil(res)

            if let containers = res!.containers,
                containers.count > 0 {
                print("=== Container list:")
                for container_ in containers {
                    if let container = container_ ,
                        let name = container.name,
                        let properties = container.properties,
                        let leaseStatus = properties.leaseStatus {
                        print("\t", "name: \(name),", "leaseStatus:", leaseStatus)
                    }
                }

            } else {
                print("=== No containers found in \(res?.serviceEndpoint ?? "no name")")
            }
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }
}


import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class o2BlobCommandsTests : StorageTestsBase {

    func test1_BlobsGetProperties() {

        let e = self.expectation(description: "Wait for HTTP request to complete")

        let cmd = Commands.Blobs.GetProperties(
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName,
            blobName: self.blobName)

        cmd.execute(client: self.azureClient) {
            (res, error) in
            defer { e.fulfill() }
            self.checkError(error: error)

            guard let blobProperties = res else {
                XCTFail("nil result")
                return
            }

            print("Blob \(self.blobName) properties:")
            print("\tcontentLength:", blobProperties.contentLength)
            print("\tcontentType:", blobProperties.contentType)
            print("\tdate:", blobProperties.date)
            print("\tlastModified:", blobProperties.lastModified)
            print("\teTag:", blobProperties.eTag)
            print("\txMsServerEncrypted:", blobProperties.xMsServerEncrypted)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }

    func test2_BlobsGet() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command =
            storage.Commands.Blobs.Get (
                azureStorageKey: self.azureStorageKey,
                accountName: self.accountName,
                containerName: self.containerName,
                blobName: self.blobName)

        command.execute(client: self.azureClient) {
            (result, error) in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }
}


//
//  ContainersCommandTests.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/18/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class o3ContainerCommandsTests : StorageTestsBase {

    func test1_ContainerGetProperties() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = Commands.Container.GetProperties (
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName)

        command.execute(client: self.azureClient) {
            error in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }

//    func test3_ContainerSetAcl() {
//        let e = expectation(description: "Wait for HTTP request to complete")
//
//        var command = Commands.Container.SetAcl (
//            azureStorageKey: self.azureStorageKey,
//            accountName: self.accountName,
//            containerName: self.containerName)
//        let ap = AccessPolicyData()
//        let sid = SignedIdentifierData(id: "sid1", accessPolicy: ap)
//
//        // FIXME: XML encoding throws
//        //command.containerAcl = [sid]
//
//        command.execute(client: self.azureClient) {
//            error in
//            defer { e.fulfill() }
//            self.checkError(error: error)
//        }
//
//        waitForExpectations(timeout: timeout, handler: nil)
//    }

    func test2_ContainerGetAcl() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = Commands.Container.GetAcl (
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName)

        command.execute(client: self.azureClient) {
            res, error in
            defer { e.fulfill() }
            self.checkError(error: error)
            if let signedIdentifiers = res {
                for si in signedIdentifiers {
                    print("=== Signed identifier id:", si?.id ?? "-")
                    print("\tAccessPolicy:")
                    print("\t\tstart:", si?.accessPolicy.start ?? "-")
                    print("\t\texpiry:", si?.accessPolicy.expiry ?? "-")
                    print("\t\tpermission:", si?.accessPolicy.permission ?? "-")

                }

            } else {
                print("=== No signed identifiers found.")
            }
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }

    func test3_ContainerListBlobs() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = Commands.Container.ListBlobs(
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName)

        command.execute(client: self.azureClient) {
            (res, error) in
            defer { e.fulfill() }
            self.checkError(error: error)

            XCTAssertNotNil(res)
            if let list = res,
                let blobs = list.blobs,
                blobs.count > 0 {
                print("=== Blob list:")
                for blob_ in blobs {
                    if let blob = blob_,
                        let name = blob.name,
                        let properties = blob.properties,
                        let blobType = properties.blobType,
                        let contentLength = properties.contentLength {
                        print("\t", "name: \(name), blobType: \(blobType), contentLength: \(contentLength), xMsBlobSequenceNumber: \(properties.xMsBlobSequenceNumber ?? "-")")
                    }
                }

            } else {
                print("=== No blobs found in the container \(res?.containerName ?? "name not found")")
            }
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }
}


//
//  CreateCommandsTests.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/29/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class o1CreateCommandsTests : StorageTestsBase {

    func test1_ContainerCreate() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = Commands.Container.Create (
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName)

        command.execute(client: self.azureClient) {
            error in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
        pause()
    }

    func test2_BlobsPut() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command = storage.Commands.Blobs.Put(
            azureStorageKey: self.azureStorageKey,
            accountName: self.accountName,
            containerName: self.containerName,
            blobName: self.blobName,
            blobType: BlobType.BlockBlob)

        command.optionalbody = Data("This is my text file! Hello world!".utf8)

        command.execute(client: self.azureClient) {
            (error) in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
        pause()
    }
}


//
//  DeleteCommandsTests.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/29/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class o9DeleteCommandsTests : StorageTestsBase {

    func BlobsDelete() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command =
            storage.Commands.Blobs.Delete (
                azureStorageKey: self.azureStorageKey,
                accountName: self.accountName,
                containerName: self.containerName,
                blobName: self.blobName)

        command.execute(client: self.azureClient) {
            error in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }

    func test3_ContainerDelete() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command =
            storage.Commands.Container.Delete (
                azureStorageKey: self.azureStorageKey,
                accountName: self.accountName,
                containerName: self.containerName)

        command.execute(client: self.azureClient) {
            error in
            defer { e.fulfill() }
            self.checkError(error: error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }
}


//
//  ScenarioTests.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/29/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

struct DataSize {
    static let b = 1
    static let kb = b << 10
    static let mb = kb * kb
    static let gb = mb * mb
    static let tb = gb * gb
    static let blobMaxLimit = 256 * mb
}

struct RangeBuilder {
    let size: Int
    let step: Int

    private var beg = 0

    init (size: Int, step: Int) {
        self.size = size
        self.step = step
    }

    func hasNext() -> Bool {
        return self.beg < self.size
    }

    mutating func next() -> (String, Int, Int) {
        var range = String()
        var first = 0
        var last = 0
        if hasNext() {
            let end = self.beg + self.step - 1
            if end >= self.size {
                range = "bytes=\(self.beg)-"
                first = self.beg
                last = self.size - 1
            } else {
                range =  ("bytes=\(self.beg)-\(end)")
                first = self.beg
                last = end
            }

            self.beg = end + 1
        }

        return (range, first, last)
    }
}

public class o5ScenarioTests : StorageTestsBase {

    let helloString = "Hello world!"
    let byeString = "Bye world."
    let bigBlobName = "bigBlob"

    func test1_BlobsPutBytes() {
        let e = expectation(description: "Wait for HTTP request to complete")

        var command =
            storage.Commands.Blobs.Put(
                azureStorageKey: self.azureStorageKey,
                accountName: self.accountName,
                containerName: self.containerName,
                blobName: self.bigBlobName,
                blobType: BlobType.BlockBlob)

        var testBytes = [UInt8]()
        let helloBytes = helloString.data(using: .utf8)!.bytes
        let byeBytes = byeString.data(using: .utf8)!.bytes
        let bytes = [UInt8](repeating: 0x01, count: 16 * DataSize.mb - helloBytes.count - byeBytes.count)

        testBytes.append(contentsOf: helloBytes)
        testBytes.append(contentsOf: bytes)
        testBytes.append(contentsOf: byeBytes)

        command.optionalbody = Data(bytes: testBytes)

        command.execute(client: self.azureClient) {
            (error) in
            defer { e.fulfill() }
            self.checkError(error: error)

            XCTAssertNil(error)
        }

        waitForExpectations(timeout: timeout, handler: nil)
    }

    func test2_BlobsGetBytesInParallel() {

        let cmd = Commands.Blobs.GetProperties(azureStorageKey: self.azureStorageKey, accountName: accountName, containerName: self.containerName, blobName: self.bigBlobName)
        guard let bp = try? cmd.execute(client: self.azureClient) else {
            XCTFail("nil result")
            return
        }

        let blobLength = bp.contentLength
        let readRange = 2 * DataSize.mb
        let threadsQnty = 8

        XCTAssertTrue(blobLength > readRange)
        XCTAssertTrue(blobLength/readRange <= threadsQnty)

        var rb = RangeBuilder(size: blobLength, step: readRange)
        var map = [Int:Data]()

        var exp = [XCTestExpectation]()

        for i in 0 ..< threadsQnty {

            if !rb.hasNext() {
                break
            }

            let (range, first, last) = rb.next()
            let e = self.expectation(description: "Wait for HTTP request to complete")
            exp.append(e)

            var command =
                storage.Commands.Blobs.Get(
                    azureStorageKey: self.azureStorageKey,
                    accountName: self.accountName,
                    containerName: self.containerName,
                    blobName: self.bigBlobName)

            command.range = range

            command.execute(client: self.azureClient) {
                (result, error) in
                defer { e.fulfill() }
                self.checkError(error: error)

                if let data = result {
                    map[first] = data
                }
            }
        }

        self.wait(for: exp, timeout: self.timeout, enforceOrder: false)

        var resultData = Data()
        let sortedKeys = Array(map.keys).sorted{$0<$1}
        for key in sortedKeys {
            resultData.append(map[key]!)
        }

        XCTAssertEqual(blobLength, resultData.bytes.count)

        let helloSize = helloString.data(using: .utf8)!.bytes.count
        let helloData = resultData[0..<helloSize]
        let receivedHelloString = String(data: helloData, encoding: .utf8)
        print("=== receivedHelloString", receivedHelloString!)

        let byeSize = byeString.data(using: .utf8)!.bytes.count
        let byeStartIndex = blobLength - byeSize
        let byeData = resultData[byeStartIndex..<blobLength]
        let receivedByeString = String(data: byeData, encoding: .utf8)
        print("=== receivedByeString", receivedByeString!)
    }
}


//
//  StorageTestsBase.swift
//  storage
//
//  Created by Vladimir Shcherbakov on 1/18/18.
//

import XCTest
import Foundation
import azureSwiftRuntime
import storage

public class StorageTestsBase : XCTestCase {
    let envVarName = "AZURE_STORAGE_KEY"
    var azureStorageKey = String()
    let timeout: TimeInterval = 102.0

    var applicationTokenCredentials: ApplicationTokenCredentials!
    var azureClient: AzureClient!

    let accountName = "swiftazurestoragesdktest"
    static let uuid = UUID().uuidString
    static let rnd = String(uuid[uuid.startIndex...uuid.index(uuid.startIndex, offsetBy: 7)]).lowercased()
    let containerName = "testcontainer" + rnd
    let blobName = "testblob" + rnd

    override public func setUp() {
        continueAfterFailure = false
        super.setUp()

        guard let azureStorageKey = self.getEnvironmentVar(name: envVarName.uppercased()) else {
            XCTFail("Azure storage key is not set in env var \(envVarName))")
            return
        }

        self.azureStorageKey = azureStorageKey

        self.azureClient = AzureClient()
            .withRequestInterceptor(LogRequestInterceptor(showOptions: .all))
            .withResponseInterceptor(LogResponseInterceptor(showOptions: .all))
    }

    func getEnvironmentVar(name: String) -> String? {
        guard let rawValue = getenv(name) else { return nil }
        return String(utf8String: rawValue)
    }

    func checkError(error: Error?) {
        if let e = error {
            if let azureError = AzureStorageDecoder.decode(error: e) {
                print("=== AzureError:", azureError.message)
                XCTFail(azureError.message)
            } else {
                print ("=== Error:", e)
                XCTFail(e.localizedDescription)
            }
        }
    }

    func pause() {
        let e = expectation(description: "Wait for HTTP request to complete")
        let queue = DispatchQueue(label: "com.azure.storage.sleep", qos: .userInitiated)
        queue.async {
            print("sleep...")
            defer { e.fulfill() }
            Thread.sleep(forTimeInterval: 2.0)
        }

        waitForExpectations(timeout: timeout, handler: nil)
        print("wakeUp!")
    }
}


// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
    name: "storage",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "storage",
            targets: ["storage"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.10"),
        .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "3.4.2"),
        .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "3.1.4"),
        .package(url: "git@github.com:alvadb/autorest-clientruntime-for-swift.git", .branch("master"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "storage",
            dependencies: ["Alamofire", "RxSwift", "SwiftyJSON", "azureSwiftRuntime"])
    ]
)


// 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.
public class DataFactory {
}
public class Commands {
}


// 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.

// Operations is the the Azure Storage Management API.
import Foundation
import azureSwiftRuntime
extension Commands {
public struct Operations {
    public static func List() -> OperationsList {
        return ListCommand()
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol OperationsList  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (OperationListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Operations {
// List lists all of the available Storage Rest API operations.
    internal class ListCommand : BaseCommand, OperationsList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var apiVersion = "2017-10-01"

    public override init() {
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/providers/Microsoft.Storage/operations"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(OperationListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (OperationListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: OperationListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// 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.

// Skus is the the Azure Storage Management API.
import Foundation
import azureSwiftRuntime
extension Commands {
public struct Skus {
    public static func List(subscriptionId: String) -> SkusList {
        return ListCommand(subscriptionId: subscriptionId)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol SkusList  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageSkuListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Skus {
// List lists the available SKUs supported by Microsoft.Storage for given subscription.
    internal class ListCommand : BaseCommand, SkusList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(subscriptionId: String) {
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(StorageSkuListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageSkuListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: StorageSkuListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// 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.

// StorageAccounts is the the Azure Storage Management API.
import Foundation
import azureSwiftRuntime
extension Commands {
public struct StorageAccounts {
    public static func CheckNameAvailability(subscriptionId: String, accountName: StorageAccountCheckNameAvailabilityParametersProtocol) -> StorageAccountsCheckNameAvailability {
        return CheckNameAvailabilityCommand(subscriptionId: subscriptionId, accountName: accountName)
    }
    public static func Create(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: StorageAccountCreateParametersProtocol) -> StorageAccountsCreate {
        return CreateCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId, parameters: parameters)
    }
    public static func Delete(resourceGroupName: String, accountName: String, subscriptionId: String) -> StorageAccountsDelete {
        return DeleteCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId)
    }
    public static func GetProperties(resourceGroupName: String, accountName: String, subscriptionId: String) -> StorageAccountsGetProperties {
        return GetPropertiesCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId)
    }
    public static func List(subscriptionId: String) -> StorageAccountsList {
        return ListCommand(subscriptionId: subscriptionId)
    }
    public static func ListAccountSAS(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: AccountSasParametersProtocol) -> StorageAccountsListAccountSAS {
        return ListAccountSASCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId, parameters: parameters)
    }
    public static func ListByResourceGroup(resourceGroupName: String, subscriptionId: String) -> StorageAccountsListByResourceGroup {
        return ListByResourceGroupCommand(resourceGroupName: resourceGroupName, subscriptionId: subscriptionId)
    }
    public static func ListKeys(resourceGroupName: String, accountName: String, subscriptionId: String) -> StorageAccountsListKeys {
        return ListKeysCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId)
    }
    public static func ListServiceSAS(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: ServiceSasParametersProtocol) -> StorageAccountsListServiceSAS {
        return ListServiceSASCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId, parameters: parameters)
    }
    public static func RegenerateKey(resourceGroupName: String, accountName: String, subscriptionId: String, regenerateKey: StorageAccountRegenerateKeyParametersProtocol) -> StorageAccountsRegenerateKey {
        return RegenerateKeyCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId, regenerateKey: regenerateKey)
    }
    public static func Update(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: StorageAccountUpdateParametersProtocol) -> StorageAccountsUpdate {
        return UpdateCommand(resourceGroupName: resourceGroupName, accountName: accountName, subscriptionId: subscriptionId, parameters: parameters)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsCheckNameAvailability  {
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var accountName :  StorageAccountCheckNameAvailabilityParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (CheckNameAvailabilityResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// CheckNameAvailability checks that the storage account name is valid and is not already in use.
    internal class CheckNameAvailabilityCommand : BaseCommand, StorageAccountsCheckNameAvailability {
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var accountName :  StorageAccountCheckNameAvailabilityParametersProtocol?

        public init(subscriptionId: String, accountName: StorageAccountCheckNameAvailabilityParametersProtocol) {
            self.subscriptionId = subscriptionId
            self.accountName = accountName
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = accountName

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(accountName as? StorageAccountCheckNameAvailabilityParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(CheckNameAvailabilityResultData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (CheckNameAvailabilityResultProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: CheckNameAvailabilityResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsCreate  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var parameters :  StorageAccountCreateParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// Create asynchronously creates a new storage account with the specified parameters. If an account is already created
// and a subsequent create request is issued with different properties, the account properties will be updated. If an
// account is already created and a subsequent create or update request is issued with the exact same set of
// properties, the request will succeed. This method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
    internal class CreateCommand : BaseCommand, StorageAccountsCreate {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var parameters :  StorageAccountCreateParametersProtocol?

        public init(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: StorageAccountCreateParametersProtocol) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            self.parameters = parameters
            super.init()
            self.method = "Put"
            self.isLongRunningOperation = true
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = parameters

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(parameters as? StorageAccountCreateParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(StorageAccountData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void {
            client.executeAsyncLRO(command: self) {
                (result: StorageAccountData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsDelete  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (Error?) -> Void) -> Void;
}

extension Commands.StorageAccounts {
// Delete deletes a storage account in Microsoft Azure.
    internal class DeleteCommand : BaseCommand, StorageAccountsDelete {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(resourceGroupName: String, accountName: String, subscriptionId: String) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Delete"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public func execute(client: RuntimeClient,
            completionHandler: @escaping (Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (error) in
                completionHandler(error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsGetProperties  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// GetProperties returns the properties for the specified storage account including but not limited to name, SKU name,
// location, and account status. The ListKeys operation should be used to retrieve storage keys.
    internal class GetPropertiesCommand : BaseCommand, StorageAccountsGetProperties {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(resourceGroupName: String, accountName: String, subscriptionId: String) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(StorageAccountData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: StorageAccountData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsList  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// List lists all the storage accounts available under the subscription. Note that storage keys are not returned; use
// the ListKeys operation for this.
    internal class ListCommand : BaseCommand, StorageAccountsList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(subscriptionId: String) {
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(StorageAccountListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: StorageAccountListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsListAccountSAS  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var parameters :  AccountSasParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (ListAccountSasResponseProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// ListAccountSAS list SAS credentials of a storage account.
    internal class ListAccountSASCommand : BaseCommand, StorageAccountsListAccountSAS {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var parameters :  AccountSasParametersProtocol?

        public init(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: AccountSasParametersProtocol) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            self.parameters = parameters
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = parameters

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(parameters as? AccountSasParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(ListAccountSasResponseData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (ListAccountSasResponseProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: ListAccountSasResponseData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsListByResourceGroup  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// ListByResourceGroup lists all the storage accounts available under the given resource group. Note that storage keys
// are not returned; use the ListKeys operation for this.
    internal class ListByResourceGroupCommand : BaseCommand, StorageAccountsListByResourceGroup {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var resourceGroupName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(resourceGroupName: String, subscriptionId: String) {
            self.resourceGroupName = resourceGroupName
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(StorageAccountListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: StorageAccountListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsListKeys  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountListKeysResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// ListKeys lists the access keys for the specified storage account.
    internal class ListKeysCommand : BaseCommand, StorageAccountsListKeys {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(resourceGroupName: String, accountName: String, subscriptionId: String) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(StorageAccountListKeysResultData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountListKeysResultProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: StorageAccountListKeysResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsListServiceSAS  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var parameters :  ServiceSasParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (ListServiceSasResponseProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// ListServiceSAS list service SAS credentials of a specific resource.
    internal class ListServiceSASCommand : BaseCommand, StorageAccountsListServiceSAS {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var parameters :  ServiceSasParametersProtocol?

        public init(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: ServiceSasParametersProtocol) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            self.parameters = parameters
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = parameters

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(parameters as? ServiceSasParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(ListServiceSasResponseData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (ListServiceSasResponseProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: ListServiceSasResponseData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsRegenerateKey  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var regenerateKey :  StorageAccountRegenerateKeyParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountListKeysResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// RegenerateKey regenerates one of the access keys for the specified storage account.
    internal class RegenerateKeyCommand : BaseCommand, StorageAccountsRegenerateKey {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var regenerateKey :  StorageAccountRegenerateKeyParametersProtocol?

        public init(resourceGroupName: String, accountName: String, subscriptionId: String, regenerateKey: StorageAccountRegenerateKeyParametersProtocol) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            self.regenerateKey = regenerateKey
            super.init()
            self.method = "Post"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = regenerateKey

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(regenerateKey as? StorageAccountRegenerateKeyParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(StorageAccountListKeysResultData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountListKeysResultProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: StorageAccountListKeysResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


import Foundation
import azureSwiftRuntime
public protocol StorageAccountsUpdate  {
    var headerParameters: [String: String] { get set }
    var resourceGroupName : String { get set }
    var accountName : String { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    var parameters :  StorageAccountUpdateParametersProtocol?  { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.StorageAccounts {
// Update the update operation can be used to update the SKU, encryption, access tier, or tags for a storage account.
// It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account;
// the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value
// must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This
// call does not change the storage keys for the account. If you want to change the storage account keys, use the
// regenerate keys operation. The location and name of the storage account cannot be changed after creation.
    internal class UpdateCommand : BaseCommand, StorageAccountsUpdate {
        public var resourceGroupName : String
        public var accountName : String
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"
    public var parameters :  StorageAccountUpdateParametersProtocol?

        public init(resourceGroupName: String, accountName: String, subscriptionId: String, parameters: StorageAccountUpdateParametersProtocol) {
            self.resourceGroupName = resourceGroupName
            self.accountName = accountName
            self.subscriptionId = subscriptionId
            self.parameters = parameters
            super.init()
            self.method = "Patch"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{resourceGroupName}"] = String(describing: self.resourceGroupName)
            self.pathParameters["{accountName}"] = String(describing: self.accountName)
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)
            self.body = parameters

        }
        public override func encodeBody() throws -> Data? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let encoder = try CoderFactory.encoder(for: mimeType)
                let encodedValue = try encoder.encode(parameters as? StorageAccountUpdateParametersData)
                return encodedValue
            }
            throw DecodeError.unknownMimeType
        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                let result = try decoder.decode(StorageAccountData?.self, from: data)
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (StorageAccountProtocol?, Error?) -> Void) -> Void {
            client.executeAsync(command: self) {
                (result: StorageAccountData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}


// 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.

// Usage is the the Azure Storage Management API.
import Foundation
import azureSwiftRuntime
extension Commands {
public struct Usage {
    public static func List(subscriptionId: String) -> UsageList {
        return ListCommand(subscriptionId: subscriptionId)
    }
}
}


import Foundation
import azureSwiftRuntime
public protocol UsageList  {
    var nextLink: String? { get }
    var hasAdditionalPages : Bool { get }
    var headerParameters: [String: String] { get set }
    var subscriptionId : String { get set }
    var apiVersion : String { get set }
    func execute(client: RuntimeClient,
    completionHandler: @escaping (UsageListResultProtocol?, Error?) -> Void) -> Void ;
}

extension Commands.Usage {
// List gets the current usage count and the limit for the resources under the subscription.
    internal class ListCommand : BaseCommand, UsageList {
        var nextLink: String?
        public var hasAdditionalPages : Bool {
        get {
            return nextLink != nil
        }
    }
        public var subscriptionId : String
        public var apiVersion = "2017-10-01"

        public init(subscriptionId: String) {
            self.subscriptionId = subscriptionId
            super.init()
            self.method = "Get"
            self.isLongRunningOperation = false
            self.path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"
            self.headerParameters = ["Content-Type":"application/json; charset=utf-8"]
        }

        public override func preCall()  {
            self.pathParameters["{subscriptionId}"] = String(describing: self.subscriptionId)
            self.queryParameters["api-version"] = String(describing: self.apiVersion)

        }

        public override func returnFunc(data: Data) throws -> Decodable? {
            let contentType = "application/json"
            if let mimeType = MimeType.getType(forStr: contentType) {
                let decoder = try CoderFactory.decoder(for: mimeType)
                if var pageDecoder = decoder as? PageDecoder {
                    pageDecoder.isPagedData = true
                    pageDecoder.nextLinkName = "nil"
                }
                let result = try decoder.decode(UsageListResultData?.self, from: data)
                if var pageDecoder = decoder as? PageDecoder {
                    self.nextLink = pageDecoder.nextLink
                }
                return result;
            }
            throw DecodeError.unknownMimeType
        }
        public func execute(client: RuntimeClient,
            completionHandler: @escaping (UsageListResultProtocol?, Error?) -> Void) -> Void {
            if self.nextLink != nil {
                self.path = nextLink!
                self.nextLink = nil;
                self.pathType = .absolute
            }
            client.executeAsync(command: self) {
                (result: UsageListResultData?, error: Error?) in
                completionHandler(result, error)
            }
        }
    }
}