Skip to content

Commit

Permalink
feat(Storage): Implementing support for multiple buckets (#3839)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas authored Sep 17, 2024
1 parent d55f04b commit c229b65
Show file tree
Hide file tree
Showing 35 changed files with 3,075 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public extension StorageDownloadDataRequest {
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// A Storage Bucket that contains the object to download. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
/// a way to utilize the underlying storage system's functionality. See plugin documentation for expected
/// key/values
Expand Down Expand Up @@ -91,11 +96,14 @@ public extension StorageDownloadDataRequest {
///
/// - Tag: StorageDownloadDataRequestOptions.init
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
pluginOptions: Any? = nil) {
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.bucket = nil
self.pluginOptions = pluginOptions
}

Expand All @@ -104,6 +112,18 @@ public extension StorageDownloadDataRequest {
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadDataRequestOptions.init
public init(
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = bucket
self.pluginOptions = pluginOptions
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public extension StorageDownloadFileRequest {
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// A Storage Bucket that contains the object to download. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
/// a way to utilize the underlying storage system's functionality. See plugin documentation for expected
/// key/values
Expand All @@ -80,19 +85,33 @@ public extension StorageDownloadFileRequest {

/// - Tag: StorageDownloadFileRequestOptions.init
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
pluginOptions: Any? = nil) {
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadFileRequestOptions.init
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadFileRequestOptions.init
public init(
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = bucket
self.pluginOptions = pluginOptions
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public extension StorageGetURLRequest {
/// - Tag: StorageGetURLRequest.Options.expires
public let expires: Int

/// A Storage Bucket that contains the object. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// Extra plugin specific options, only used in special circumstances when the existing options do
/// not provide a way to utilize the underlying storage system's functionality. See plugin
/// documentation or
Expand All @@ -84,20 +89,39 @@ public extension StorageGetURLRequest {

/// - Tag: StorageGetURLRequest.Options.init
@available(*, deprecated, message: "Use init(expires:pluginOptions)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
expires: Int = Options.defaultExpireInSeconds,
pluginOptions: Any? = nil) {
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
expires: Int = Options.defaultExpireInSeconds,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.expires = expires
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageGetURLRequest.Options.init
public init(expires: Int = Options.defaultExpireInSeconds,
pluginOptions: Any? = nil) {
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: some StorageBucket,
pluginOptions: Any? = nil
) {
self.expires = expires
self.bucket = bucket
self.pluginOptions = pluginOptions
self.accessLevel = .guest
self.targetIdentityId = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public extension StorageListRequest {
/// - Tag: StorageListRequestOptions.pageSize
public let pageSize: UInt

/// A Storage Bucket that contains the objects to list. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// Opaque string indicating the page offset at which to resume a listing. This is usually a copy of
/// the value from [StorageListResult.nextToken](x-source-tag://StorageListResult.nextToken).
///
Expand All @@ -96,18 +101,39 @@ public extension StorageListRequest {
public let pluginOptions: Any?

/// - Tag: StorageListRequestOptions.init
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
path: String? = nil,
subpathStrategy: SubpathStrategy = .include,
pageSize: UInt = 1000,
nextToken: String? = nil,
pluginOptions: Any? = nil) {
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
path: String? = nil,
subpathStrategy: SubpathStrategy = .include,
pageSize: UInt = 1000,
nextToken: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public extension StorageRemoveRequest {
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// A Storage Bucket that contains the object to remove. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
/// a way to utilize the underlying storage system's functionality. See plugin documentation for expected
/// key/values
Expand All @@ -64,9 +69,22 @@ public extension StorageRemoveRequest {
public let pluginOptions: Any?

/// - Tag: StorageRemoveRequestOptions.init
public init(accessLevel: StorageAccessLevel = .guest,
pluginOptions: Any? = nil) {
public init(
accessLevel: StorageAccessLevel = .guest,
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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public extension StorageUploadDataRequest {
/// - Tag: StorageUploadDataRequestOptions.metadata
public let metadata: [String: String]?

/// A specific Storage Bucket to upload the data. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageDownloadDataRequest.bucket
public let bucket: (any StorageBucket)?

/// The standard MIME type describing the format of the object to store
///
/// - Tag: StorageUploadDataRequestOptions.contentType
Expand All @@ -89,27 +94,46 @@ public extension StorageUploadDataRequest {

/// - Tag: StorageUploadDataRequestOptions.init
@available(*, deprecated, message: "Use init(metadata:contentType:options)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.metadata = metadata
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
}

/// - Tag: StorageUploadDataRequestOptions.init
public init(metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
public init(
metadata: [String: String]? = nil,
bucket: some StorageBucket,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.metadata = metadata
self.bucket = bucket
self.contentType = contentType
self.pluginOptions = pluginOptions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public extension StorageUploadFileRequest {
/// - Tag: StorageUploadFileRequestOptions.metadata
public let metadata: [String: String]?

/// A specific Storage Bucket to upload the file. Defaults to `nil`, in which case the default one will be used.
///
/// - Tag: StorageUploadFileRequestOptions.bucket
public let bucket: (any StorageBucket)?

/// The standard MIME type describing the format of the object to store
///
/// - Tag: StorageUploadFileRequestOptions.contentType
Expand All @@ -86,27 +91,46 @@ public extension StorageUploadFileRequest {

/// - Tag: StorageUploadFileRequestOptions.init
@available(*, deprecated, message: "Use init(metadata:contentType:pluginOptions)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.metadata = metadata
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
}

/// - Tag: StorageUploadFileRequestOptions.init
public init(metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
public init(
metadata: [String: String]? = nil,
bucket: some StorageBucket,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.metadata = metadata
self.bucket = bucket
self.contentType = contentType
self.pluginOptions = pluginOptions
}
Expand Down
Loading

0 comments on commit c229b65

Please sign in to comment.