2323"""
2424
2525from typing import Any , Dict , List , Optional , Union , cast , Mapping , Iterable , Callable
26+ import warnings
2627from azure .core .async_paging import AsyncItemPaged
2728from azure .core .credentials import TokenCredential
2829from azure .core .credentials_async import AsyncTokenCredential
29- from azure .core import MatchConditions
3030from azure .core .pipeline .policies import RetryMode
3131
3232from azure .core .tracing .decorator_async import distributed_trace_async
@@ -250,10 +250,7 @@ async def create_database(
250250 id : str ,
251251 * ,
252252 offer_throughput : Optional [Union [int , ThroughputProperties ]] = None ,
253- session_token : Optional [str ] = None ,
254253 initial_headers : Optional [Dict [str , str ]] = None ,
255- etag : Optional [str ] = None ,
256- match_condition : Optional [MatchConditions ] = None ,
257254 ** kwargs : Any
258255 ) -> DatabaseProxy :
259256 """
@@ -262,12 +259,7 @@ async def create_database(
262259 :param str id: ID (name) of the database to create.
263260 :keyword offer_throughput: The provisioned throughput for this offer.
264261 :paramtype offer_throughput: Union[int, ~azure.cosmos.ThroughputProperties]
265- :keyword str session_token: Token for use with Session consistency.
266262 :keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
267- :keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
268- has changed, and act according to the condition specified by the `match_condition` parameter.
269- :keyword match_condition: The match condition to use upon the etag.
270- :paramtype match_condition: ~azure.core.MatchConditions
271263 :keyword response_hook: A callable invoked with the response metadata.
272264 :paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
273265 :raises ~azure.cosmos.exceptions.CosmosResourceExistsError: Database with the given ID already exists.
@@ -284,14 +276,26 @@ async def create_database(
284276 :caption: Create a database in the Cosmos DB account:
285277 :name: create_database
286278 """
279+ session_token = kwargs .get ('session_token' )
287280 if session_token is not None :
288- kwargs ["session_token" ] = session_token
289- if initial_headers is not None :
290- kwargs ["initial_headers" ] = initial_headers
281+ warnings .warn (
282+ "The 'session_token' flag does not apply to this method and is always ignored even if passed."
283+ " It will now be removed in the future." ,
284+ DeprecationWarning )
285+ etag = kwargs .get ('etag' )
291286 if etag is not None :
292- kwargs ["etag" ] = etag
287+ warnings .warn (
288+ "The 'etag' flag does not apply to this method and is always ignored even if passed."
289+ " It will now be removed in the future." ,
290+ DeprecationWarning )
291+ match_condition = kwargs .get ('match_condition' )
293292 if match_condition is not None :
294- kwargs ["match_condition" ] = match_condition
293+ warnings .warn (
294+ "The 'match_condition' flag does not apply to this method and is always ignored even if passed."
295+ " It will now be removed in the future." ,
296+ DeprecationWarning )
297+ if initial_headers is not None :
298+ kwargs ["initial_headers" ] = initial_headers
295299 request_options = _build_options (kwargs )
296300 _set_throughput_options (offer = offer_throughput , request_options = request_options )
297301
@@ -304,10 +308,7 @@ async def create_database_if_not_exists( # pylint: disable=redefined-builtin
304308 id : str ,
305309 * ,
306310 offer_throughput : Optional [Union [int , ThroughputProperties ]] = None ,
307- session_token : Optional [str ] = None ,
308311 initial_headers : Optional [Dict [str , str ]] = None ,
309- etag : Optional [str ] = None ,
310- match_condition : Optional [MatchConditions ] = None ,
311312 ** kwargs : Any
312313 ) -> DatabaseProxy :
313314 """
@@ -322,26 +323,33 @@ async def create_database_if_not_exists( # pylint: disable=redefined-builtin
322323 :param str id: ID (name) of the database to read or create.
323324 :keyword offer_throughput: The provisioned throughput for this offer.
324325 :paramtype offer_throughput: Union[int, ~azure.cosmos.ThroughputProperties]
325- :keyword str session_token: Token for use with Session consistency.
326326 :keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
327- :keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
328- has changed, and act according to the condition specified by the `match_condition` parameter.
329- :keyword match_condition: The match condition to use upon the etag.
330- :paramtype match_condition: ~azure.core.MatchConditions
331327 :keyword response_hook: A callable invoked with the response metadata.
332328 :paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
333329 :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The database read or creation failed.
334330 :returns: A DatabaseProxy instance representing the database.
335331 :rtype: ~azure.cosmos.DatabaseProxy
336332 """
333+ session_token = kwargs .get ('session_token' )
337334 if session_token is not None :
338- kwargs ["session_token" ] = session_token
339- if initial_headers is not None :
340- kwargs ["initial_headers" ] = initial_headers
335+ warnings .warn (
336+ "The 'session_token' flag does not apply to this method and is always ignored even if passed."
337+ " It will now be removed in the future." ,
338+ DeprecationWarning )
339+ etag = kwargs .get ('etag' )
341340 if etag is not None :
342- kwargs ["etag" ] = etag
341+ warnings .warn (
342+ "The 'etag' flag does not apply to this method and is always ignored even if passed."
343+ " It will now be removed in the future." ,
344+ DeprecationWarning )
345+ match_condition = kwargs .get ('match_condition' )
343346 if match_condition is not None :
344- kwargs ["match_condition" ] = match_condition
347+ warnings .warn (
348+ "The 'match_condition' flag does not apply to this method and is always ignored even if passed."
349+ " It will now be removed in the future." ,
350+ DeprecationWarning )
351+ if initial_headers is not None :
352+ kwargs ["initial_headers" ] = initial_headers
345353 try :
346354 database_proxy = self .get_database_client (id )
347355 await database_proxy .read (** kwargs )
@@ -375,7 +383,6 @@ def list_databases(
375383 self ,
376384 * ,
377385 max_item_count : Optional [int ] = None ,
378- session_token : Optional [str ] = None ,
379386 initial_headers : Optional [Dict [str , str ]] = None ,
380387 response_hook : Optional [Callable [[Mapping [str , Any ]], None ]] = None ,
381388 ** kwargs : Any
@@ -390,8 +397,12 @@ def list_databases(
390397 :returns: An AsyncItemPaged of database properties (dicts).
391398 :rtype: AsyncItemPaged[Dict[str, str]]
392399 """
400+ session_token = kwargs .pop ('session_token' , None )
393401 if session_token is not None :
394- kwargs ["session_token" ] = session_token
402+ warnings .warn (
403+ "The 'session_token' flag does not apply to this method and is always ignored even if passed."
404+ " It will now be removed in the future." ,
405+ DeprecationWarning )
395406 if initial_headers is not None :
396407 kwargs ["initial_headers" ] = initial_headers
397408 feed_options = _build_options (kwargs )
@@ -410,7 +421,6 @@ def query_databases(
410421 * ,
411422 parameters : Optional [List [Dict [str , Any ]]] = None ,
412423 max_item_count : Optional [int ] = None ,
413- session_token : Optional [str ] = None ,
414424 initial_headers : Optional [Dict [str , str ]] = None ,
415425 response_hook : Optional [Callable [[Mapping [str , Any ]], None ]] = None ,
416426 ** kwargs : Any
@@ -429,8 +439,12 @@ def query_databases(
429439 :returns: An AsyncItemPaged of database properties (dicts).
430440 :rtype: AsyncItemPaged[Dict[str, str]]
431441 """
442+ session_token = kwargs .get ('session_token' )
432443 if session_token is not None :
433- kwargs ["session_token" ] = session_token
444+ warnings .warn (
445+ "The 'session_token' flag does not apply to this method and is always ignored even if passed."
446+ " It will now be removed in the future." ,
447+ DeprecationWarning )
434448 if initial_headers is not None :
435449 kwargs ["initial_headers" ] = initial_headers
436450 feed_options = _build_options (kwargs )
@@ -450,10 +464,7 @@ async def delete_database(
450464 self ,
451465 database : Union [str , DatabaseProxy , Dict [str , Any ]],
452466 * ,
453- session_token : Optional [str ] = None ,
454467 initial_headers : Optional [Dict [str , str ]] = None ,
455- etag : Optional [str ] = None ,
456- match_condition : Optional [MatchConditions ] = None ,
457468 response_hook : Optional [Callable [[Mapping [str , Any ]], None ]] = None ,
458469 ** kwargs : Any
459470 ) -> None :
@@ -462,27 +473,34 @@ async def delete_database(
462473 :param database: The ID (name), dict representing the properties, or :class:`DatabaseProxy`
463474 instance of the database to delete.
464475 :type database: Union[str, ~azure.cosmos.DatabaseProxy, Dict[str, Any]]
465- :keyword str session_token: Token for use with Session consistency.
466476 :keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
467- :keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
468- has changed, and act according to the condition specified by the `match_condition` parameter.
469- :keyword match_condition: The match condition to use upon the etag.
470- :paramtype match_condition: ~azure.core.MatchConditions
471477 :keyword response_hook: A callable invoked with the response metadata.
472478 :paramtype response_hook: Callable[[Mapping[str, Any]], None]
473479 :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: If the database couldn't be deleted.
474480 :rtype: None
475481 """
482+ session_token = kwargs .get ('session_token' )
476483 if session_token is not None :
477- kwargs ["session_token" ] = session_token
478- if initial_headers is not None :
479- kwargs ["initial_headers" ] = initial_headers
484+ warnings .warn (
485+ "The 'session_token' flag does not apply to this method and is always ignored even if passed."
486+ " It will now be removed in the future." ,
487+ DeprecationWarning )
488+ etag = kwargs .get ('etag' )
480489 if etag is not None :
481- kwargs ["etag" ] = etag
490+ warnings .warn (
491+ "The 'etag' flag does not apply to this method and is always ignored even if passed."
492+ " It will now be removed in the future." ,
493+ DeprecationWarning )
494+ match_condition = kwargs .get ('match_condition' )
482495 if match_condition is not None :
483- kwargs ["match_condition" ] = match_condition
484- request_options = _build_options (kwargs )
496+ warnings .warn (
497+ "The 'match_condition' flag does not apply to this method and is always ignored even if passed."
498+ " It will now be removed in the future." ,
499+ DeprecationWarning )
485500
501+ if initial_headers is not None :
502+ kwargs ["initial_headers" ] = initial_headers
503+ request_options = _build_options (kwargs )
486504 database_link = _get_database_link (database )
487505 await self .client_connection .DeleteDatabase (database_link , options = request_options , ** kwargs )
488506 if response_hook :
0 commit comments