Skip to content

Commit

Permalink
feat(storage): update Storage APIs with StoragePath parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode authored Apr 26, 2024
2 parents bb7f747 + 45bd603 commit 162847a
Show file tree
Hide file tree
Showing 61 changed files with 3,287 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,35 @@ import Foundation
/// - Tag: StorageDownloadDataRequest
public struct StorageDownloadDataRequest: AmplifyOperationRequest {

/// The path for the object in storage
///
/// - Tag: StorageDownloadFileRequest.path
public let path: (any StoragePath)?

/// The unique identifier for the object in storage
///
/// - Tag: StorageDownloadDataRequest.key
@available(*, deprecated, message: "Use `path` instead of `key`")
public let key: String

/// Options to adjust the behavior of this request, including plugin-options
///
/// - Tag: StorageDownloadDataRequest.options
public let options: Options

/// - Tag: StorageDownloadDataRequest.key
/// - Tag: StorageDownloadDataRequest.init
@available(*, deprecated, message: "Use init(path:local:options)")
public init(key: String, options: Options) {
self.key = key
self.options = options
self.path = nil
}

/// - Tag: StorageDownloadDataRequest.init
public init(path: any StoragePath, options: Options) {
self.key = ""
self.options = options
self.path = path
}
}

Expand All @@ -40,11 +55,13 @@ public extension StorageDownloadDataRequest {
/// Access level of the storage system. Defaults to `public`
///
/// - Tag: StorageDownloadDataRequestOptions.accessLevel
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// Target user to apply the action on.
///
/// - Tag: StorageDownloadDataRequestOptions.targetIdentityId
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
Expand Down Expand Up @@ -73,12 +90,21 @@ public extension StorageDownloadDataRequest {

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

///
/// - Tag: StorageDownloadDataRequestOptions.init
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.pluginOptions = pluginOptions
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ import Foundation
/// - Tag: StorageDownloadFileRequest
public struct StorageDownloadFileRequest: AmplifyOperationRequest {

/// The path for the object in storage
///
/// - Tag: StorageDownloadFileRequest.path
public let path: (any StoragePath)?

/// The unique identifier for the object in storage
///
/// - Tag: StorageDownloadFileRequest.key
@available(*, deprecated, message: "Use `path` instead of `key`")
public let key: String

/// The local file to download the object to
Expand All @@ -29,10 +35,20 @@ public struct StorageDownloadFileRequest: AmplifyOperationRequest {
public let options: Options

/// - Tag: StorageDownloadFileRequest.init
@available(*, deprecated, message: "Use init(path:local:options)")
public init(key: String, local: URL, options: Options) {
self.key = key
self.local = local
self.options = options
self.path = nil
}

/// - Tag: StorageDownloadFileRequest.init
public init(path: any StoragePath, local: URL, options: Options) {
self.key = ""
self.local = local
self.options = options
self.path = path
}
}

Expand All @@ -46,11 +62,13 @@ public extension StorageDownloadFileRequest {
/// Access level of the storage system. Defaults to `public`
///
/// - Tag: StorageDownloadFileRequestOptions.accessLevel
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// Target user to apply the action on.
///
/// - Tag: StorageDownloadFileRequestOptions.targetIdentityId
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
Expand All @@ -61,12 +79,21 @@ public extension StorageDownloadFileRequest {
public let pluginOptions: Any?

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

/// - Tag: StorageDownloadFileRequestOptions.init
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.pluginOptions = pluginOptions
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,63 @@ public struct StorageGetURLRequest: AmplifyOperationRequest {

/// The unique identifier for the object in storage
///
/// - Tag: StorageListRequest.key
/// - Tag: StorageGetURLRequest.key
@available(*, deprecated, message: "Use `path` in Storage API instead of `key`")
public let key: String

/// Options to adjust the behavior of this request, including plugin-options
/// The unique path for the object in storage
///
/// - Tag: StorageGetURLRequest.path
public let path: (any StoragePath)?

/// Options to adjust the behaviour of this request, including plugin-options
///
/// - Tag: StorageListRequest.options
/// - Tag: StorageGetURLRequest.options
public let options: Options

/// - Tag: StorageListRequest.init
/// - Tag: StorageGetURLRequest.init
@available(*, deprecated, message: "Use init(path:options)")
public init(key: String, options: Options) {
self.key = key
self.options = options
self.path = nil
}

/// - Tag: StorageGetURLRequest.init
public init(path: any StoragePath, options: Options) {
self.key = ""
self.options = options
self.path = path
}
}

public extension StorageGetURLRequest {

/// Options to adjust the behavior of this request, including plugin-options
///
/// - Tag: StorageListRequestOptions
/// - Tag: StorageGetURLRequest.Options
struct Options {
/// The default amount of time before the URL expires is 18000 seconds, or 5 hours.
///
/// - Tag: StorageListRequestOptions.defaultExpireInSeconds
/// - Tag: StorageGetURLRequest.Options.defaultExpireInSeconds
public static let defaultExpireInSeconds = 18_000

/// Access level of the storage system. Defaults to `public`
///
/// - Tag: StorageListRequestOptions.accessLevel
/// - Tag: StorageGetURLRequest.Options.accessLevel
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// Target user to apply the action on.
///
/// - Tag: StorageListRequestOptions.targetIdentityId
/// - Tag: StorageGetURLRequest.Options.targetIdentityId
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// Number of seconds before the URL expires. Defaults to
/// [defaultExpireInSeconds](x-source-tag://StorageListRequestOptions.defaultExpireInSeconds)
///
/// - Tag: StorageListRequestOptions.expires
/// - Tag: StorageGetURLRequest.Options.expires
public let expires: Int

/// Extra plugin specific options, only used in special circumstances when the existing options do
Expand All @@ -62,10 +79,11 @@ public extension StorageGetURLRequest {
/// [AWSStorageGetURLOptions](x-source-tag://AWSStorageGetURLOptions) for
/// expected key/values.
///
/// - Tag: StorageListRequestOptions.pluginOptions
/// - Tag: StorageGetURLRequest.Options.pluginOptions
public let pluginOptions: Any?

/// - Tag: StorageListRequestOptions.init
/// - Tag: StorageGetURLRequest.Options.init
@available(*, deprecated, message: "Use init(expires:pluginOptions)")
public init(accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
expires: Int = Options.defaultExpireInSeconds,
Expand All @@ -75,5 +93,14 @@ public extension StorageGetURLRequest {
self.expires = expires
self.pluginOptions = pluginOptions
}

/// - Tag: StorageGetURLRequest.Options.init
public init(expires: Int = Options.defaultExpireInSeconds,
pluginOptions: Any? = nil) {
self.expires = expires
self.pluginOptions = pluginOptions
self.accessLevel = .guest
self.targetIdentityId = nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@ public struct StorageListRequest: AmplifyOperationRequest {
/// - Tag: StorageListRequest
public let options: Options

/// The unique path for the object in storage
///
/// - Tag: StorageListRequest.path
public let path: (any StoragePath)?

/// - Tag: StorageListRequest.init
@available(*, deprecated, message: "Use init(path:options)")
public init(options: Options) {
self.options = options
self.path = nil
}

/// - Tag: StorageListRequest.init
public init(path: any StoragePath, options: Options) {
self.options = options
self.path = path
}
}

Expand All @@ -32,16 +45,19 @@ public extension StorageListRequest {
/// Access level of the storage system. Defaults to `public`
///
/// - Tag: StorageListRequestOptions.accessLevel
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// Target user to apply the action on
///
/// - Tag: StorageListRequestOptions.targetIdentityId
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let targetIdentityId: String?

/// Path to the keys
///
/// - Tag: StorageListRequestOptions.path
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let path: String?

/// Number between 1 and 1,000 that indicates the limit of how many entries to fetch when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@ public struct StorageRemoveRequest: AmplifyOperationRequest {
/// The unique identifier for the object in storage
///
/// - Tag: StorageRemoveRequest.key
@available(*, deprecated, message: "Use `path` in Storage API instead of `key`")
public let key: String

/// The unique path for the object in storage
///
/// - Tag: StorageRemoveRequest.path
public let path: (any StoragePath)?

/// Options to adjust the behavior of this request, including plugin-options
///
/// - Tag: StorageRemoveRequest.options
public let options: Options

/// - Tag: StorageRemoveRequest.init
@available(*, deprecated, message: "Use init(path:options)")
public init(key: String, options: Options) {
self.key = key
self.options = options
self.path = nil
}

/// - Tag: StorageRemoveRequest.init
public init(path: any StoragePath, options: Options) {
self.key = ""
self.options = options
self.path = path
}
}

Expand All @@ -38,6 +53,7 @@ public extension StorageRemoveRequest {
/// Access level of the storage system. Defaults to `public`
///
/// - Tag: StorageRemoveRequestOptions.accessLevel
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
public let accessLevel: StorageAccessLevel

/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
Expand Down
Loading

0 comments on commit 162847a

Please sign in to comment.