11
11
% % if applicable.
12
12
-module (aws_apigatewaymanagementapi ).
13
13
14
- -export ([delete_connection /4 ,
15
- delete_connection /5 ,
16
- get_connection /3 ,
17
- get_connection /5 ,
14
+ -export ([delete_connection /5 ,
15
+ delete_connection /6 ,
16
+ get_connection /4 ,
18
17
get_connection /6 ,
19
- post_to_connection /4 ,
20
- post_to_connection /5 ]).
18
+ get_connection /7 ,
19
+ post_to_connection /5 ,
20
+ post_to_connection /6 ]).
21
21
22
22
-include_lib (" hackney/include/hackney_lib.hrl" ).
23
23
94
94
% %====================================================================
95
95
96
96
% % @doc Delete the connection with the provided id.
97
- -spec delete_connection (aws_client :aws_client (), list () | binary (), binary () | list (), delete_connection_request ()) ->
97
+ -spec delete_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), delete_connection_request ()) ->
98
98
{ok , undefined , tuple ()} |
99
99
{error , any ()} |
100
100
{error , delete_connection_errors (), tuple ()}.
101
- delete_connection (Client , Stage , ConnectionId , Input ) ->
102
- delete_connection (Client , Stage , ConnectionId , Input , []).
101
+ delete_connection (Client , ApiId , Stage , ConnectionId , Input ) ->
102
+ delete_connection (Client , ApiId , Stage , ConnectionId , Input , []).
103
103
104
- -spec delete_connection (aws_client :aws_client (), list () | binary (), binary () | list (), delete_connection_request (), proplists :proplist ()) ->
104
+ -spec delete_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), delete_connection_request (), proplists :proplist ()) ->
105
105
{ok , undefined , tuple ()} |
106
106
{error , any ()} |
107
107
{error , delete_connection_errors (), tuple ()}.
108
- delete_connection (Client , Stage , ConnectionId , Input0 , Options0 ) ->
108
+ delete_connection (Client , ApiId , Stage , ConnectionId , Input0 , Options0 ) ->
109
109
Method = delete ,
110
110
Path = [" /" , Stage , " /@connections/" , aws_util :encode_uri (ConnectionId ), " " ],
111
111
SuccessStatusCode = 204 ,
@@ -125,30 +125,30 @@ delete_connection(Client, Stage, ConnectionId, Input0, Options0) ->
125
125
Query_ = [],
126
126
Input = Input2 ,
127
127
128
- request (Client , Method , Path , Query_ , CustomHeaders ++ Headers , Input , Options , SuccessStatusCode ).
128
+ request (Client #{ api_id => ApiId } , Method , Path , Query_ , CustomHeaders ++ Headers , Input , Options , SuccessStatusCode ).
129
129
130
130
% % @doc Get information about the connection with the provided id.
131
- -spec get_connection (aws_client :aws_client (), list () | binary (), binary () | list ()) ->
131
+ -spec get_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list ()) ->
132
132
{ok , get_connection_response (), tuple ()} |
133
133
{error , any ()} |
134
134
{error , get_connection_errors (), tuple ()}.
135
- get_connection (Client , Stage , ConnectionId )
135
+ get_connection (Client , ApiId , Stage , ConnectionId )
136
136
when is_map (Client ) ->
137
- get_connection (Client , Stage , ConnectionId , #{}, #{}).
137
+ get_connection (Client , ApiId , Stage , ConnectionId , #{}, #{}).
138
138
139
- -spec get_connection (aws_client :aws_client (), list () | binary (), binary () | list (), map (), map ()) ->
139
+ -spec get_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), map (), map ()) ->
140
140
{ok , get_connection_response (), tuple ()} |
141
141
{error , any ()} |
142
142
{error , get_connection_errors (), tuple ()}.
143
- get_connection (Client , Stage , ConnectionId , QueryMap , HeadersMap )
143
+ get_connection (Client , ApiId , Stage , ConnectionId , QueryMap , HeadersMap )
144
144
when is_map (Client ), is_map (QueryMap ), is_map (HeadersMap ) ->
145
- get_connection (Client , Stage , ConnectionId , QueryMap , HeadersMap , []).
145
+ get_connection (Client , ApiId , Stage , ConnectionId , QueryMap , HeadersMap , []).
146
146
147
- -spec get_connection (aws_client :aws_client (), list () | binary (), binary () | list (), map (), map (), proplists :proplist ()) ->
147
+ -spec get_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), map (), map (), proplists :proplist ()) ->
148
148
{ok , get_connection_response (), tuple ()} |
149
149
{error , any ()} |
150
150
{error , get_connection_errors (), tuple ()}.
151
- get_connection (Client , Stage , ConnectionId , QueryMap , HeadersMap , Options0 )
151
+ get_connection (Client , ApiId , Stage , ConnectionId , QueryMap , HeadersMap , Options0 )
152
152
when is_map (Client ), is_map (QueryMap ), is_map (HeadersMap ), is_list (Options0 ) ->
153
153
Path = [" /" , Stage , " /@connections/" , aws_util :encode_uri (ConnectionId ), " " ],
154
154
SuccessStatusCode = 200 ,
@@ -162,21 +162,21 @@ get_connection(Client, Stage, ConnectionId, QueryMap, HeadersMap, Options0)
162
162
163
163
Query_ = [],
164
164
165
- request (Client , get , Path , Query_ , Headers , undefined , Options , SuccessStatusCode ).
165
+ request (Client #{ api_id => ApiId } , get , Path , Query_ , Headers , undefined , Options , SuccessStatusCode ).
166
166
167
167
% % @doc Sends the provided data to the specified connection.
168
- -spec post_to_connection (aws_client :aws_client (), list () | binary (), binary () | list (), post_to_connection_request ()) ->
168
+ -spec post_to_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), post_to_connection_request ()) ->
169
169
{ok , undefined , tuple ()} |
170
170
{error , any ()} |
171
171
{error , post_to_connection_errors (), tuple ()}.
172
- post_to_connection (Client , Stage , ConnectionId , Input ) ->
173
- post_to_connection (Client , Stage , ConnectionId , Input , []).
172
+ post_to_connection (Client , ApiId , Stage , ConnectionId , Input ) ->
173
+ post_to_connection (Client , ApiId , Stage , ConnectionId , Input , []).
174
174
175
- -spec post_to_connection (aws_client :aws_client (), list () | binary (), binary () | list (), post_to_connection_request (), proplists :proplist ()) ->
175
+ -spec post_to_connection (aws_client :aws_client (), list () | binary (), list () | binary (), binary () | list (), post_to_connection_request (), proplists :proplist ()) ->
176
176
{ok , undefined , tuple ()} |
177
177
{error , any ()} |
178
178
{error , post_to_connection_errors (), tuple ()}.
179
- post_to_connection (Client , Stage , ConnectionId , Input0 , Options0 ) ->
179
+ post_to_connection (Client , ApiId , Stage , ConnectionId , Input0 , Options0 ) ->
180
180
Method = post ,
181
181
Path = [" /" , Stage , " /@connections/" , aws_util :encode_uri (ConnectionId ), " " ],
182
182
SuccessStatusCode = 200 ,
@@ -196,7 +196,7 @@ post_to_connection(Client, Stage, ConnectionId, Input0, Options0) ->
196
196
Query_ = [],
197
197
Input = Input2 ,
198
198
199
- request (Client , Method , Path , Query_ , CustomHeaders ++ Headers , Input , Options , SuccessStatusCode ).
199
+ request (Client #{ api_id => ApiId } , Method , Path , Query_ , CustomHeaders ++ Headers , Input , Options , SuccessStatusCode ).
200
200
201
201
% %====================================================================
202
202
% % Internal functions
@@ -243,7 +243,7 @@ do_request(Client, Method, Path, Query, Headers0, Input, Options, SuccessStatusC
243
243
Headers1 = aws_request :add_headers (AdditionalHeaders , Headers0 ),
244
244
245
245
MethodBin = aws_request :method_to_binary (Method ),
246
- SignedHeaders = aws_request :sign_request (Client1 , MethodBin , URL , Headers1 , Payload ),
246
+ SignedHeaders = aws_request :sign_request (Client1 , MethodBin , URL , Headers1 , Payload , [{ uri_encode_path , true }] ),
247
247
Response = hackney :request (Method , URL , SignedHeaders , Payload , Options ),
248
248
DecodeBody = not proplists :get_value (receive_body_as_binary , Options ),
249
249
handle_response (Response , SuccessStatusCode , DecodeBody ).
@@ -305,8 +305,8 @@ build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
305
305
Endpoint ;
306
306
build_host (_EndpointPrefix , #{region := <<" local" >>}) ->
307
307
<<" localhost" >>;
308
- build_host (EndpointPrefix , #{region := Region , endpoint := Endpoint }) ->
309
- aws_util :binary_join ([EndpointPrefix , Region , Endpoint ], <<" ." >>).
308
+ build_host (EndpointPrefix , #{api_id : = ApiId , region := Region , endpoint := Endpoint }) ->
309
+ aws_util :binary_join ([ApiId , EndpointPrefix , Region , Endpoint ], <<" ." >>).
310
310
311
311
build_url (Host , Path0 , Client ) ->
312
312
Proto = aws_client :proto (Client ),
0 commit comments