diff --git a/Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift index 7879f87846..73cf9f57fc 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift @@ -95,23 +95,30 @@ public extension StorageDownloadDataRequest { /// /// - Tag: StorageDownloadDataRequestOptions.init - @available(*, deprecated, message: "Use init(bucket:pluginOptions)") + @available(*, deprecated, message: "Use init(pluginOptions)") public init( accessLevel: StorageAccessLevel = .guest, targetIdentityId: String? = nil, - bucket: (any StorageBucket)? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel self.targetIdentityId = targetIdentityId - self.bucket = bucket + self.bucket = nil self.pluginOptions = pluginOptions } /// + /// - Tag: StorageDownloadDataRequestOptions.init + public init(pluginOptions: Any? = nil) { + self.accessLevel = .guest + self.targetIdentityId = nil + self.bucket = nil + self.pluginOptions = pluginOptions + } + /// - Tag: StorageDownloadDataRequestOptions.init public init( - bucket: (any StorageBucket)? = nil, + bucket: some StorageBucket, pluginOptions: Any? = nil ) { self.accessLevel = .guest diff --git a/Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift index 7ac9cc65f6..cc68d539bd 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift @@ -84,22 +84,29 @@ public extension StorageDownloadFileRequest { public let pluginOptions: Any? /// - Tag: StorageDownloadFileRequestOptions.init - @available(*, deprecated, message: "Use init(bucket:pluginOptions)") + @available(*, deprecated, message: "Use init(pluginOptions)") public init( accessLevel: StorageAccessLevel = .guest, targetIdentityId: String? = nil, - bucket: (any StorageBucket)? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel self.targetIdentityId = targetIdentityId - self.bucket = bucket + self.bucket = nil + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageDownloadFileRequestOptions.init + public init(pluginOptions: Any? = nil) { + self.accessLevel = .guest + self.targetIdentityId = nil + self.bucket = nil self.pluginOptions = pluginOptions } /// - Tag: StorageDownloadFileRequestOptions.init public init( - bucket: (any StorageBucket)? = nil, + bucket: some StorageBucket, pluginOptions: Any? = nil ) { self.accessLevel = .guest diff --git a/Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift index bdc6731762..c86db0b4ba 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift @@ -88,25 +88,36 @@ public extension StorageGetURLRequest { public let pluginOptions: Any? /// - Tag: StorageGetURLRequest.Options.init - @available(*, deprecated, message: "Use init(expires:bucket:pluginOptions)") + @available(*, deprecated, message: "Use init(expires:pluginOptions)") public init( accessLevel: StorageAccessLevel = .guest, targetIdentityId: String? = nil, expires: Int = Options.defaultExpireInSeconds, - bucket: (any StorageBucket)? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel self.targetIdentityId = targetIdentityId self.expires = expires - self.bucket = bucket + self.bucket = nil + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageGetURLRequest.Options.init + public init( + expires: Int = Options.defaultExpireInSeconds, + pluginOptions: Any? = nil + ) { + self.expires = expires + self.bucket = nil self.pluginOptions = pluginOptions + self.accessLevel = .guest + self.targetIdentityId = nil } /// - Tag: StorageGetURLRequest.Options.init public init( expires: Int = Options.defaultExpireInSeconds, - bucket: (any StorageBucket)? = nil, + bucket: some StorageBucket, pluginOptions: Any? = nil ) { self.expires = expires diff --git a/Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift index 506fad2b8d..0c66976aeb 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift @@ -107,7 +107,6 @@ public extension StorageListRequest { path: String? = nil, subpathStrategy: SubpathStrategy = .include, pageSize: UInt = 1000, - bucket: (any StorageBucket)? = nil, nextToken: String? = nil, pluginOptions: Any? = nil ) { @@ -116,6 +115,24 @@ public extension StorageListRequest { self.path = path self.subpathStrategy = subpathStrategy self.pageSize = pageSize + self.bucket = nil + self.nextToken = nextToken + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageListRequestOptions.init + public init( + subpathStrategy: SubpathStrategy = .include, + pageSize: UInt = 1000, + bucket: some StorageBucket, + nextToken: String? = nil, + pluginOptions: Any? = nil + ) { + self.accessLevel = .guest + self.targetIdentityId = nil + self.path = nil + self.subpathStrategy = subpathStrategy + self.pageSize = pageSize self.bucket = bucket self.nextToken = nextToken self.pluginOptions = pluginOptions diff --git a/Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift index 26d083a583..39b10e099d 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift @@ -71,10 +71,19 @@ public extension StorageRemoveRequest { /// - Tag: StorageRemoveRequestOptions.init public init( accessLevel: StorageAccessLevel = .guest, - bucket: (any StorageBucket)? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel + self.bucket = nil + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageRemoveRequestOptions.init + public init( + bucket: some StorageBucket, + pluginOptions: Any? = nil + ) { + self.accessLevel = .guest self.bucket = bucket self.pluginOptions = pluginOptions } diff --git a/Amplify/Categories/Storage/Operation/Request/StorageUploadDataRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageUploadDataRequest.swift index 8a3e043346..174aa06fc9 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageUploadDataRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageUploadDataRequest.swift @@ -93,19 +93,32 @@ public extension StorageUploadDataRequest { public let pluginOptions: Any? /// - Tag: StorageUploadDataRequestOptions.init - @available(*, deprecated, message: "Use init(metadata:bucket:contentType:options)") + @available(*, deprecated, message: "Use init(metadata:contentType:options)") public init( accessLevel: StorageAccessLevel = .guest, targetIdentityId: String? = nil, metadata: [String: String]? = nil, - bucket: (any StorageBucket)? = nil, contentType: String? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel self.targetIdentityId = targetIdentityId self.metadata = metadata - self.bucket = bucket + self.bucket = nil + self.contentType = contentType + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageUploadDataRequestOptions.init + public init( + metadata: [String: String]? = nil, + contentType: String? = nil, + pluginOptions: Any? = nil + ) { + self.accessLevel = .guest + self.targetIdentityId = nil + self.metadata = metadata + self.bucket = nil self.contentType = contentType self.pluginOptions = pluginOptions } @@ -113,7 +126,7 @@ public extension StorageUploadDataRequest { /// - Tag: StorageUploadDataRequestOptions.init public init( metadata: [String: String]? = nil, - bucket: (any StorageBucket)? = nil, + bucket: some StorageBucket, contentType: String? = nil, pluginOptions: Any? = nil ) { diff --git a/Amplify/Categories/Storage/Operation/Request/StorageUploadFileRequest.swift b/Amplify/Categories/Storage/Operation/Request/StorageUploadFileRequest.swift index fd430476e4..b7c2e73830 100644 --- a/Amplify/Categories/Storage/Operation/Request/StorageUploadFileRequest.swift +++ b/Amplify/Categories/Storage/Operation/Request/StorageUploadFileRequest.swift @@ -90,19 +90,32 @@ public extension StorageUploadFileRequest { public let pluginOptions: Any? /// - Tag: StorageUploadFileRequestOptions.init - @available(*, deprecated, message: "Use init(metadata:bucket:contentType:pluginOptions)") + @available(*, deprecated, message: "Use init(metadata:contentType:pluginOptions)") public init( accessLevel: StorageAccessLevel = .guest, targetIdentityId: String? = nil, metadata: [String: String]? = nil, - bucket: (any StorageBucket)? = nil, contentType: String? = nil, pluginOptions: Any? = nil ) { self.accessLevel = accessLevel self.targetIdentityId = targetIdentityId self.metadata = metadata - self.bucket = bucket + self.bucket = nil + self.contentType = contentType + self.pluginOptions = pluginOptions + } + + /// - Tag: StorageUploadFileRequestOptions.init + public init( + metadata: [String: String]? = nil, + contentType: String? = nil, + pluginOptions: Any? = nil + ) { + self.accessLevel = .guest + self.targetIdentityId = nil + self.metadata = metadata + self.bucket = nil self.contentType = contentType self.pluginOptions = pluginOptions } @@ -110,7 +123,7 @@ public extension StorageUploadFileRequest { /// - Tag: StorageUploadFileRequestOptions.init public init( metadata: [String: String]? = nil, - bucket: (any StorageBucket)? = nil, + bucket: some StorageBucket, contentType: String? = nil, pluginOptions: Any? = nil ) { diff --git a/Amplify/Categories/Storage/StorageBucket.swift b/Amplify/Categories/Storage/StorageBucket.swift index 1f485e8f46..f987f2b949 100644 --- a/Amplify/Categories/Storage/StorageBucket.swift +++ b/Amplify/Categories/Storage/StorageBucket.swift @@ -16,7 +16,6 @@ public protocol StorageBucket { } /// /// - Tag: BucketInfo public struct BucketInfo: Hashable { - /// The name of the bucket /// - Tag: BucketInfo.bucketName public let bucketName: String @@ -32,7 +31,6 @@ public struct BucketInfo: Hashable { } public extension StorageBucket where Self == OutputsStorageBucket { - /// References a `StorageBucket` in the AmplifyOutputs file using the given name. /// /// - Parameter name: The name of the bucket @@ -63,19 +61,3 @@ public struct OutputsStorageBucket: StorageBucket { public struct ResolvedStorageBucket: StorageBucket { public let bucketInfo: BucketInfo } - -public extension Optional where Wrapped == any StorageBucket { - /// References a `StorageBucket` in the AmplifyOutputs file using the given name. - /// - /// - Parameter name: The name of the bucket - static func fromOutputs(name: String) -> (any StorageBucket)? { - return OutputsStorageBucket.fromOutputs(name: name) - } - - /// References a `StorageBucket` using the data from the given `BucketInfo`. - /// - /// - Parameter bucketInfo: A `BucketInfo` instance - static func fromBucketInfo(_ bucketInfo: BucketInfo) -> (any StorageBucket)? { - return ResolvedStorageBucket.fromBucketInfo(bucketInfo) - } -}