@@ -28,7 +28,7 @@ public struct FunctionInvokeOptions: Sendable {
2828 /// Body data to be sent with the function invocation.
2929 let body : Data ?
3030 /// The Region to invoke the function in.
31- let region : String ?
31+ let region : FunctionRegion ?
3232 /// The query to be included in the function invocation.
3333 let query : [ URLQueryItem ]
3434
@@ -40,12 +40,11 @@ public struct FunctionInvokeOptions: Sendable {
4040 /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
4141 /// - region: The Region to invoke the function in.
4242 /// - body: The body data to be sent with the function invocation. (Default: nil)
43- @_disfavoredOverload
4443 public init (
4544 method: Method ? = nil ,
4645 query: [ URLQueryItem ] = [ ] ,
4746 headers: [ String : String ] = [ : ] ,
48- region: String ? = nil ,
47+ region: FunctionRegion ? = nil ,
4948 body: some Encodable
5049 ) {
5150 var defaultHeaders = HTTPFields ( )
@@ -76,12 +75,11 @@ public struct FunctionInvokeOptions: Sendable {
7675 /// - query: The query to be included in the function invocation.
7776 /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
7877 /// - region: The Region to invoke the function in.
79- @_disfavoredOverload
8078 public init (
8179 method: Method ? = nil ,
8280 query: [ URLQueryItem ] = [ ] ,
8381 headers: [ String : String ] = [ : ] ,
84- region: String ? = nil
82+ region: FunctionRegion ? = nil
8583 ) {
8684 self . method = method
8785 self . headers = HTTPFields ( headers)
@@ -116,56 +114,29 @@ public struct FunctionInvokeOptions: Sendable {
116114 }
117115}
118116
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
156121 }
157122
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)
170141 }
171142}
0 commit comments