@@ -28,7 +28,7 @@ public struct FunctionInvokeOptions: Sendable {
28
28
/// Body data to be sent with the function invocation.
29
29
let body : Data ?
30
30
/// The Region to invoke the function in.
31
- let region : String ?
31
+ let region : FunctionRegion ?
32
32
/// The query to be included in the function invocation.
33
33
let query : [ URLQueryItem ]
34
34
@@ -40,12 +40,11 @@ public struct FunctionInvokeOptions: Sendable {
40
40
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
41
41
/// - region: The Region to invoke the function in.
42
42
/// - body: The body data to be sent with the function invocation. (Default: nil)
43
- @_disfavoredOverload
44
43
public init (
45
44
method: Method ? = nil ,
46
45
query: [ URLQueryItem ] = [ ] ,
47
46
headers: [ String : String ] = [ : ] ,
48
- region: String ? = nil ,
47
+ region: FunctionRegion ? = nil ,
49
48
body: some Encodable
50
49
) {
51
50
var defaultHeaders = HTTPFields ( )
@@ -76,12 +75,11 @@ public struct FunctionInvokeOptions: Sendable {
76
75
/// - query: The query to be included in the function invocation.
77
76
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
78
77
/// - region: The Region to invoke the function in.
79
- @_disfavoredOverload
80
78
public init (
81
79
method: Method ? = nil ,
82
80
query: [ URLQueryItem ] = [ ] ,
83
81
headers: [ String : String ] = [ : ] ,
84
- region: String ? = nil
82
+ region: FunctionRegion ? = nil
85
83
) {
86
84
self . method = method
87
85
self . headers = HTTPFields ( headers)
@@ -116,56 +114,29 @@ public struct FunctionInvokeOptions: Sendable {
116
114
}
117
115
}
118
116
119
- public enum FunctionRegion : String , Sendable {
120
- case apNortheast1 = " ap-northeast-1 "
121
- case apNortheast2 = " ap-northeast-2 "
122
- case apSouth1 = " ap-south-1 "
123
- case apSoutheast1 = " ap-southeast-1 "
124
- case apSoutheast2 = " ap-southeast-2 "
125
- case caCentral1 = " ca-central-1 "
126
- case euCentral1 = " eu-central-1 "
127
- case euWest1 = " eu-west-1 "
128
- case euWest2 = " eu-west-2 "
129
- case euWest3 = " eu-west-3 "
130
- case saEast1 = " sa-east-1 "
131
- case usEast1 = " us-east-1 "
132
- case usWest1 = " us-west-1 "
133
- case usWest2 = " us-west-2 "
134
- }
135
-
136
- extension FunctionInvokeOptions {
137
- /// Initializes the `FunctionInvokeOptions` structure.
138
- ///
139
- /// - Parameters:
140
- /// - method: Method to use in the function invocation.
141
- /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
142
- /// - region: The Region to invoke the function in.
143
- /// - body: The body data to be sent with the function invocation. (Default: nil)
144
- public init (
145
- method: Method ? = nil ,
146
- headers: [ String : String ] = [ : ] ,
147
- region: FunctionRegion ? = nil ,
148
- body: some Encodable
149
- ) {
150
- self . init (
151
- method: method,
152
- headers: headers,
153
- region: region? . rawValue,
154
- body: body
155
- )
117
+ public struct FunctionRegion : RawRepresentable , Sendable {
118
+ public let rawValue : String
119
+ public init ( rawValue: String ) {
120
+ self . rawValue = rawValue
156
121
}
157
122
158
- /// Initializes the `FunctionInvokeOptions` structure.
159
- ///
160
- /// - Parameters:
161
- /// - method: Method to use in the function invocation.
162
- /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
163
- /// - region: The Region to invoke the function in.
164
- public init (
165
- method: Method ? = nil ,
166
- headers: [ String : String ] = [ : ] ,
167
- region: FunctionRegion ? = nil
168
- ) {
169
- self . init ( method: method, headers: headers, region: region? . rawValue)
123
+ public static let apNortheast1 = FunctionRegion ( rawValue: " ap-northeast-1 " )
124
+ public static let apNortheast2 = FunctionRegion ( rawValue: " ap-northeast-2 " )
125
+ public static let apSouth1 = FunctionRegion ( rawValue: " ap-south-1 " )
126
+ public static let apSoutheast1 = FunctionRegion ( rawValue: " ap-southeast-1 " )
127
+ public static let apSoutheast2 = FunctionRegion ( rawValue: " ap-southeast-2 " )
128
+ public static let caCentral1 = FunctionRegion ( rawValue: " ca-central-1 " )
129
+ public static let euCentral1 = FunctionRegion ( rawValue: " eu-central-1 " )
130
+ public static let euWest1 = FunctionRegion ( rawValue: " eu-west-1 " )
131
+ public static let euWest2 = FunctionRegion ( rawValue: " eu-west-2 " )
132
+ public static let euWest3 = FunctionRegion ( rawValue: " eu-west-3 " )
133
+ public static let saEast1 = FunctionRegion ( rawValue: " sa-east-1 " )
134
+ public static let usEast1 = FunctionRegion ( rawValue: " us-east-1 " )
135
+ public static let usWest1 = FunctionRegion ( rawValue: " us-west-1 " )
136
+ public static let usWest2 = FunctionRegion ( rawValue: " us-west-2 " )
137
+ }
138
+ extension FunctionRegion : ExpressibleByStringLiteral {
139
+ public init ( stringLiteral value: String ) {
140
+ self . init ( rawValue: value)
170
141
}
171
142
}
0 commit comments