11from mpt_api_client .constants import APPLICATION_JSON
22from mpt_api_client .http .async_client import AsyncHTTPClient
33from mpt_api_client .http .client import HTTPClient
4+ from mpt_api_client .http .query_options import QueryOptions
45from mpt_api_client .http .types import QueryParam , Response
56from mpt_api_client .http .url_utils import join_url_path
67from mpt_api_client .models .collection import ResourceList
@@ -37,6 +38,7 @@ def do_request( # noqa: WPS211
3738 json : _JsonPayload = None ,
3839 query_params : QueryParam | None = None ,
3940 headers : dict [str , str ] | None = None ,
41+ options : QueryOptions | None = None ,
4042 ) -> Response :
4143 """Perform an HTTP request and return the raw ``Response``.
4244
@@ -46,10 +48,11 @@ def do_request( # noqa: WPS211
4648 json: JSON body payload.
4749 query_params: Query-string parameters.
4850 headers: Extra HTTP headers.
51+ options: Query options.
4952 """
5053 url = join_url_path (self ._resource_url , action ) if action else self ._resource_url
5154 return self ._http_client .request (
52- method , url , json = json , query_params = query_params , headers = headers
55+ method , url , json = json , query_params = query_params , headers = headers , options = options
5356 )
5457
5558 # -- model-returning helpers ---------------------------------------------
@@ -59,9 +62,10 @@ def get(
5962 action : str | None = None ,
6063 * ,
6164 query_params : QueryParam | None = None ,
65+ options : QueryOptions | None = None ,
6266 ) -> ResourceModel :
6367 """``GET`` the resource (optionally with a sub-action)."""
64- return self ._action ("GET" , action , query_params = query_params )
68+ return self ._action ("GET" , action , query_params = query_params , options = options )
6569
6670 def post (
6771 self ,
@@ -94,13 +98,15 @@ def _action(
9498 * ,
9599 json : _JsonPayload = None ,
96100 query_params : QueryParam | None = None ,
101+ options : QueryOptions | None = None ,
97102 ) -> ResourceModel :
98103 response = self .do_request (
99104 method ,
100105 action ,
101106 json = json ,
102107 query_params = query_params ,
103108 headers = {"Accept" : APPLICATION_JSON },
109+ options = options ,
104110 )
105111 return self ._model_class .from_response (response )
106112
@@ -131,6 +137,7 @@ async def do_request( # noqa: WPS211
131137 json : _JsonPayload = None ,
132138 query_params : QueryParam | None = None ,
133139 headers : dict [str , str ] | None = None ,
140+ options : QueryOptions | None = None ,
134141 ) -> Response :
135142 """Perform an HTTP request and return the raw ``Response``.
136143
@@ -140,10 +147,11 @@ async def do_request( # noqa: WPS211
140147 json: JSON body payload.
141148 query_params: Query-string parameters.
142149 headers: Extra HTTP headers.
150+ options: Additional options for the request.
143151 """
144152 url = join_url_path (self ._resource_url , action ) if action else self ._resource_url
145153 return await self ._http_client .request (
146- method , url , json = json , query_params = query_params , headers = headers
154+ method , url , json = json , query_params = query_params , headers = headers , options = options
147155 )
148156
149157 # -- model-returning helpers ---------------------------------------------
@@ -153,9 +161,10 @@ async def get(
153161 action : str | None = None ,
154162 * ,
155163 query_params : QueryParam | None = None ,
164+ options : QueryOptions | None = None ,
156165 ) -> ResourceModel :
157166 """``GET`` the resource (optionally with a sub-action)."""
158- return await self ._action ("GET" , action , query_params = query_params )
167+ return await self ._action ("GET" , action , query_params = query_params , options = options )
159168
160169 async def post (
161170 self ,
@@ -188,12 +197,14 @@ async def _action(
188197 * ,
189198 json : _JsonPayload = None ,
190199 query_params : QueryParam | None = None ,
200+ options : QueryOptions | None = None ,
191201 ) -> ResourceModel :
192202 response = await self .do_request (
193203 method ,
194204 action ,
195205 json = json ,
196206 query_params = query_params ,
197207 headers = {"Accept" : APPLICATION_JSON },
208+ options = options ,
198209 )
199210 return self ._model_class .from_response (response )
0 commit comments