11import Foundation
2+ import HTTPTypes
3+ import HTTPTypesFoundation
4+ import Helpers
25
36#if canImport(FoundationNetworking)
47 import FoundationNetworking
@@ -9,25 +12,23 @@ public class StorageBucketApi: StorageApi, @unchecked Sendable {
912 /// Retrieves the details of all Storage buckets within an existing project.
1013 public func listBuckets( ) async throws -> [ Bucket ] {
1114 try await execute (
12- HTTPRequest (
13- url : configuration . url . appendingPathComponent ( " bucket " ) ,
14- method : . get
15+ HTTPTypes . HTTPRequest (
16+ method : . get ,
17+ url : configuration . url . appendingPathComponent ( " bucket " )
1518 )
16- )
17- . decoded ( decoder: configuration. decoder)
19+ ) . responseBody. decoded ( decoder: configuration. decoder)
1820 }
1921
2022 /// Retrieves the details of an existing Storage bucket.
2123 /// - Parameters:
2224 /// - id: The unique identifier of the bucket you would like to retrieve.
2325 public func getBucket( _ id: String ) async throws -> Bucket {
2426 try await execute (
25- HTTPRequest (
26- url : configuration . url . appendingPathComponent ( " bucket/ \( id ) " ) ,
27- method : . get
27+ HTTPTypes . HTTPRequest (
28+ method : . get ,
29+ url : configuration . url . appendingPathComponent ( " bucket/ \( id ) " )
2830 )
29- )
30- . decoded ( decoder: configuration. decoder)
31+ ) . responseBody. decoded ( decoder: configuration. decoder)
3132 }
3233
3334 struct BucketParameters : Encodable {
@@ -44,10 +45,15 @@ public class StorageBucketApi: StorageApi, @unchecked Sendable {
4445 /// - options: Options for creating the bucket.
4546 public func createBucket( _ id: String , options: BucketOptions = . init( ) ) async throws {
4647 try await execute (
47- HTTPRequest (
48- url: configuration. url. appendingPathComponent ( " bucket " ) ,
48+ HTTPTypes . HTTPRequest (
4949 method: . post,
50- body: configuration. encoder. encode (
50+ url: configuration. url. appendingPathComponent ( " bucket " ) ,
51+ headerFields: [
52+ . contentType: " application/json "
53+ ]
54+ ) ,
55+ requestBody: HTTPBody (
56+ configuration. encoder. encode (
5157 BucketParameters (
5258 id: id,
5359 name: id,
@@ -66,10 +72,15 @@ public class StorageBucketApi: StorageApi, @unchecked Sendable {
6672 /// - options: Options for updating the bucket.
6773 public func updateBucket( _ id: String , options: BucketOptions ) async throws {
6874 try await execute (
69- HTTPRequest (
70- url: configuration. url. appendingPathComponent ( " bucket/ \( id) " ) ,
75+ HTTPTypes . HTTPRequest (
7176 method: . put,
72- body: configuration. encoder. encode (
77+ url: configuration. url. appendingPathComponent ( " bucket/ \( id) " ) ,
78+ headerFields: [
79+ . contentType: " application/json "
80+ ]
81+ ) ,
82+ requestBody: HTTPBody (
83+ configuration. encoder. encode (
7384 BucketParameters (
7485 id: id,
7586 name: id,
@@ -87,9 +98,9 @@ public class StorageBucketApi: StorageApi, @unchecked Sendable {
8798 /// - id: The unique identifier of the bucket you would like to empty.
8899 public func emptyBucket( _ id: String ) async throws {
89100 try await execute (
90- HTTPRequest (
91- url : configuration . url . appendingPathComponent ( " bucket/ \( id ) /empty " ) ,
92- method : . post
101+ HTTPTypes . HTTPRequest (
102+ method : . post ,
103+ url : configuration . url . appendingPathComponent ( " bucket/ \( id ) /empty " )
93104 )
94105 )
95106 }
@@ -100,9 +111,9 @@ public class StorageBucketApi: StorageApi, @unchecked Sendable {
100111 /// - id: The unique identifier of the bucket you would like to delete.
101112 public func deleteBucket( _ id: String ) async throws {
102113 try await execute (
103- HTTPRequest (
104- url : configuration . url . appendingPathComponent ( " bucket/ \( id ) " ) ,
105- method : . delete
114+ HTTPTypes . HTTPRequest (
115+ method : . delete ,
116+ url : configuration . url . appendingPathComponent ( " bucket/ \( id ) " )
106117 )
107118 )
108119 }
0 commit comments