@@ -19,21 +19,30 @@ public enum FunctionsError: Error, LocalizedError {
1919}
2020
2121/// Options for invoking a function.
22- public struct FunctionInvokeOptions {
22+ public struct FunctionInvokeOptions : Sendable {
2323 /// Method to use in the function invocation.
2424 let method : Method ?
2525 /// Headers to be included in the function invocation.
2626 let headers : [ String : String ]
2727 /// Body data to be sent with the function invocation.
2828 let body : Data ?
29+ /// The Region to invoke the function in.
30+ let region : String ?
2931
3032 /// Initializes the `FunctionInvokeOptions` structure.
3133 ///
3234 /// - Parameters:
3335 /// - method: Method to use in the function invocation.
3436 /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
37+ /// - region: The Region to invoke the function in.
3538 /// - body: The body data to be sent with the function invocation. (Default: nil)
36- public init ( method: Method ? = nil , headers: [ String : String ] = [ : ] , body: some Encodable ) {
39+ @_disfavoredOverload
40+ public init (
41+ method: Method ? = nil ,
42+ headers: [ String : String ] = [ : ] ,
43+ region: String ? = nil ,
44+ body: some Encodable
45+ ) {
3746 var defaultHeaders = headers
3847
3948 switch body {
@@ -51,24 +60,86 @@ public struct FunctionInvokeOptions {
5160
5261 self . method = method
5362 self . headers = defaultHeaders. merging ( headers) { _, new in new }
63+ self . region = region
5464 }
5565
5666 /// Initializes the `FunctionInvokeOptions` structure.
5767 ///
5868 /// - Parameters:
5969 /// - method: Method to use in the function invocation.
6070 /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
61- public init ( method: Method ? = nil , headers: [ String : String ] = [ : ] ) {
71+ /// - region: The Region to invoke the function in.
72+ @_disfavoredOverload
73+ public init (
74+ method: Method ? = nil ,
75+ headers: [ String : String ] = [ : ] ,
76+ region: String ? = nil
77+ ) {
6278 self . method = method
6379 self . headers = headers
80+ self . region = region
6481 body = nil
6582 }
6683
67- public enum Method : String {
84+ public enum Method : String , Sendable {
6885 case get = " GET "
6986 case post = " POST "
7087 case put = " PUT "
7188 case patch = " PATCH "
7289 case delete = " DELETE "
7390 }
7491}
92+
93+ public enum FunctionRegion : String , Sendable {
94+ case apNortheast1 = " ap-northeast-1 "
95+ case apNortheast2 = " ap-northeast-2 "
96+ case apSouth1 = " ap-south-1 "
97+ case apSoutheast1 = " ap-southeast-1 "
98+ case apSoutheast2 = " ap-southeast-2 "
99+ case caCentral1 = " ca-central-1 "
100+ case euCentral1 = " eu-central-1 "
101+ case euWest1 = " eu-west-1 "
102+ case euWest2 = " eu-west-2 "
103+ case euWest3 = " eu-west-3 "
104+ case saEast1 = " sa-east-1 "
105+ case usEast1 = " us-east-1 "
106+ case usWest1 = " us-west-1 "
107+ case usWest2 = " us-west-2 "
108+ }
109+
110+ extension FunctionInvokeOptions {
111+ /// Initializes the `FunctionInvokeOptions` structure.
112+ ///
113+ /// - Parameters:
114+ /// - method: Method to use in the function invocation.
115+ /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
116+ /// - region: The Region to invoke the function in.
117+ /// - body: The body data to be sent with the function invocation. (Default: nil)
118+ public init (
119+ method: Method ? = nil ,
120+ headers: [ String : String ] = [ : ] ,
121+ region: FunctionRegion ? = nil ,
122+ body: some Encodable
123+ ) {
124+ self . init (
125+ method: method,
126+ headers: headers,
127+ region: region? . rawValue,
128+ body: body
129+ )
130+ }
131+
132+ /// Initializes the `FunctionInvokeOptions` structure.
133+ ///
134+ /// - Parameters:
135+ /// - method: Method to use in the function invocation.
136+ /// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
137+ /// - region: The Region to invoke the function in.
138+ public init (
139+ method: Method ? = nil ,
140+ headers: [ String : String ] = [ : ] ,
141+ region: FunctionRegion ? = nil
142+ ) {
143+ self . init ( method: method, headers: headers, region: region? . rawValue)
144+ }
145+ }
0 commit comments