5555 'post_trigger_include' : Constants .Kwargs .POST_TRIGGER_INCLUDE ,
5656 'access_condition' : Constants .Kwargs .ACCESS_CONDITION ,
5757 'session_token' : Constants .Kwargs .SESSION_TOKEN ,
58- 'resource_token_expiry_seconds' : Constants .Kwargs .RESOURCE_TOKEN_EXPIRY_SECONDS ,
59- 'offer_enable_ru_per_minute_throughput' : Constants .Kwargs .OFFER_ENABLE_RU_PER_MINUTE_THROUGHPUT ,
60- 'disable_ru_per_minute_usage' : Constants .Kwargs .DISABLE_RU_PER_MINUTE_USAGE ,
58+ 'resource_token_expiry_seconds' : (
59+ Constants .Kwargs .RESOURCE_TOKEN_EXPIRY_SECONDS
60+ ),
61+ 'offer_enable_ru_per_minute_throughput' : (
62+ Constants .Kwargs .OFFER_ENABLE_RU_PER_MINUTE_THROUGHPUT
63+ ),
64+ 'disable_ru_per_minute_usage' : (
65+ Constants .Kwargs .DISABLE_RU_PER_MINUTE_USAGE
66+ ),
6167 'continuation' : Constants .Kwargs .CONTINUATION ,
6268 'content_type' : Constants .Kwargs .CONTENT_TYPE ,
6369 'is_query_plan_request' : Constants .Kwargs .IS_QUERY_PLAN_REQUEST ,
64- 'supported_query_features' : Constants .Kwargs .SUPPORTED_QUERY_FEATURES ,
70+ 'supported_query_features' : (
71+ Constants .Kwargs .SUPPORTED_QUERY_FEATURES
72+ ),
6573 'query_version' : Constants .Kwargs .QUERY_VERSION ,
6674 'priority' : Constants .Kwargs .PRIORITY_LEVEL ,
67- 'no_response' : Constants .Kwargs .RESPONSE_PAYLOAD_ON_WRITE_DISABLED ,
75+ 'no_response' : (
76+ Constants .Kwargs .RESPONSE_PAYLOAD_ON_WRITE_DISABLED
77+ ),
6878 'retry_write' : Constants .Kwargs .RETRY_WRITE ,
6979 'max_item_count' : Constants .Kwargs .MAX_ITEM_COUNT ,
7080 'throughput_bucket' : Constants .Kwargs .THROUGHPUT_BUCKET ,
@@ -174,17 +184,25 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
174184 headers [http_constants .HttpHeaders .IfNoneMatch ] = access_condition ["condition" ]
175185
176186 if options .get (Constants .Kwargs .INDEXING_DIRECTIVE ):
177- headers [http_constants .HttpHeaders .IndexingDirective ] = options [Constants .Kwargs .INDEXING_DIRECTIVE ]
187+ headers [http_constants .HttpHeaders .IndexingDirective ] = options [
188+ Constants .Kwargs .INDEXING_DIRECTIVE
189+ ]
178190
179191 # set request consistency level - if session consistency, the client should be setting this on its own
180192 if options .get (Constants .Kwargs .CONSISTENCY_LEVEL ):
181- headers [http_constants .HttpHeaders .ConsistencyLevel ] = options [Constants .Kwargs .CONSISTENCY_LEVEL ]
193+ headers [http_constants .HttpHeaders .ConsistencyLevel ] = options [
194+ Constants .Kwargs .CONSISTENCY_LEVEL
195+ ]
182196
183197 if options .get (Constants .Kwargs .ENABLE_SCAN_IN_QUERY ):
184- headers [http_constants .HttpHeaders .EnableScanInQuery ] = options [Constants .Kwargs .ENABLE_SCAN_IN_QUERY ]
198+ headers [http_constants .HttpHeaders .EnableScanInQuery ] = options [
199+ Constants .Kwargs .ENABLE_SCAN_IN_QUERY
200+ ]
185201
186202 if options .get (Constants .Kwargs .RESOURCE_TOKEN_EXPIRY_SECONDS ):
187- headers [http_constants .HttpHeaders .ResourceTokenExpiry ] = options [Constants .Kwargs .RESOURCE_TOKEN_EXPIRY_SECONDS ]
203+ headers [http_constants .HttpHeaders .ResourceTokenExpiry ] = options [
204+ Constants .Kwargs .RESOURCE_TOKEN_EXPIRY_SECONDS
205+ ]
188206
189207 if options .get (Constants .Kwargs .OFFER_TYPE ):
190208 headers [http_constants .HttpHeaders .OfferType ] = options [Constants .Kwargs .OFFER_TYPE ]
@@ -196,10 +214,14 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
196214 headers [http_constants .HttpHeaders .ContentType ] = options [Constants .Kwargs .CONTENT_TYPE ]
197215
198216 if options .get (Constants .Kwargs .IS_QUERY_PLAN_REQUEST ):
199- headers [http_constants .HttpHeaders .IsQueryPlanRequest ] = options [Constants .Kwargs .IS_QUERY_PLAN_REQUEST ]
217+ headers [http_constants .HttpHeaders .IsQueryPlanRequest ] = options [
218+ Constants .Kwargs .IS_QUERY_PLAN_REQUEST
219+ ]
200220
201221 if options .get (Constants .Kwargs .SUPPORTED_QUERY_FEATURES ):
202- headers [http_constants .HttpHeaders .SupportedQueryFeatures ] = options [Constants .Kwargs .SUPPORTED_QUERY_FEATURES ]
222+ headers [http_constants .HttpHeaders .SupportedQueryFeatures ] = options [
223+ Constants .Kwargs .SUPPORTED_QUERY_FEATURES
224+ ]
203225
204226 if options .get (Constants .Kwargs .QUERY_VERSION ):
205227 headers [http_constants .HttpHeaders .QueryVersion ] = options [Constants .Kwargs .QUERY_VERSION ]
@@ -214,27 +236,38 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
214236 # else serialize using json dumps method which apart from regular values will serialize None into null
215237 else :
216238 # single partitioning uses a string and needs to be turned into a list
217- is_sequence_not_string = (isinstance (options [Constants .Kwargs .PARTITION_KEY ], Sequence ) and
218- not isinstance (options [Constants .Kwargs .PARTITION_KEY ], str ))
239+ is_sequence_not_string = (
240+ isinstance (options [Constants .Kwargs .PARTITION_KEY ], Sequence ) and
241+ not isinstance (options [Constants .Kwargs .PARTITION_KEY ], str )
242+ )
219243
220244 if is_sequence_not_string and options [Constants .Kwargs .PARTITION_KEY ]:
221- pk_val = json .dumps (list (options [Constants .Kwargs .PARTITION_KEY ]), separators = (',' , ':' ))
245+ pk_val = json .dumps (
246+ list (options [Constants .Kwargs .PARTITION_KEY ]), separators = (',' , ':' )
247+ )
222248 else :
223249 pk_val = json .dumps ([options [Constants .Kwargs .PARTITION_KEY ]])
224250 headers [http_constants .HttpHeaders .PartitionKey ] = pk_val
225251
226252 if options .get (Constants .Kwargs .ENABLE_CROSS_PARTITION_QUERY ):
227- headers [http_constants .HttpHeaders .EnableCrossPartitionQuery ] = options [Constants .Kwargs .ENABLE_CROSS_PARTITION_QUERY ]
253+ headers [http_constants .HttpHeaders .EnableCrossPartitionQuery ] = options [
254+ Constants .Kwargs .ENABLE_CROSS_PARTITION_QUERY
255+ ]
228256
229257 if options .get (Constants .Kwargs .POPULATE_QUERY_METRICS ):
230- headers [http_constants .HttpHeaders .PopulateQueryMetrics ] = options [Constants .Kwargs .POPULATE_QUERY_METRICS ]
258+ headers [http_constants .HttpHeaders .PopulateQueryMetrics ] = options [
259+ Constants .Kwargs .POPULATE_QUERY_METRICS
260+ ]
231261
232262 if options .get (Constants .Kwargs .POPULATE_INDEX_METRICS ):
233- headers [http_constants .HttpHeaders .PopulateIndexMetrics ] = options [Constants .Kwargs .POPULATE_INDEX_METRICS ]
263+ headers [http_constants .HttpHeaders .PopulateIndexMetrics ] = options [
264+ Constants .Kwargs .POPULATE_INDEX_METRICS
265+ ]
234266
235267 if options .get (Constants .Kwargs .RESPONSE_CONTINUATION_TOKEN_LIMIT_IN_KB ):
236268 headers [http_constants .HttpHeaders .ResponseContinuationTokenLimitInKb ] = options [
237- Constants .Kwargs .RESPONSE_CONTINUATION_TOKEN_LIMIT_IN_KB ]
269+ Constants .Kwargs .RESPONSE_CONTINUATION_TOKEN_LIMIT_IN_KB
270+ ]
238271
239272 if options .get (Constants .Kwargs .PRIORITY_LEVEL ):
240273 headers [http_constants .HttpHeaders .PriorityLevel ] = options [Constants .Kwargs .PRIORITY_LEVEL ]
@@ -269,15 +302,19 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
269302 headers [http_constants .HttpHeaders .ClientId ] = cosmos_client_connection .client_id
270303
271304 if options .get (Constants .Kwargs .ENABLE_SCRIPT_LOGGING ):
272- headers [http_constants .HttpHeaders .EnableScriptLogging ] = options [Constants .Kwargs .ENABLE_SCRIPT_LOGGING ]
305+ headers [http_constants .HttpHeaders .EnableScriptLogging ] = options [
306+ Constants .Kwargs .ENABLE_SCRIPT_LOGGING
307+ ]
273308
274309 if options .get (Constants .Kwargs .OFFER_ENABLE_RU_PER_MINUTE_THROUGHPUT ):
275310 headers [http_constants .HttpHeaders .OfferIsRUPerMinuteThroughputEnabled ] = options [
276311 Constants .Kwargs .OFFER_ENABLE_RU_PER_MINUTE_THROUGHPUT
277312 ]
278313
279314 if options .get (Constants .Kwargs .DISABLE_RU_PER_MINUTE_USAGE ):
280- headers [http_constants .HttpHeaders .DisableRUPerMinuteUsage ] = options [Constants .Kwargs .DISABLE_RU_PER_MINUTE_USAGE ]
315+ headers [http_constants .HttpHeaders .DisableRUPerMinuteUsage ] = options [
316+ Constants .Kwargs .DISABLE_RU_PER_MINUTE_USAGE
317+ ]
281318
282319 if options .get (Constants .Kwargs .CONTINUATION ):
283320 headers [http_constants .HttpHeaders .Continuation ] = options [Constants .Kwargs .CONTINUATION ]
@@ -291,30 +328,40 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
291328 headers [http_constants .HttpHeaders .PopulateQuotaInfo ] = options [Constants .Kwargs .POPULATE_QUOTA_INFO ]
292329
293330 if options .get (Constants .Kwargs .MAX_INTEGRATED_CACHE_STALENESS ):
294- headers [http_constants .HttpHeaders .DedicatedGatewayCacheStaleness ] = options [Constants .Kwargs .MAX_INTEGRATED_CACHE_STALENESS ]
331+ headers [http_constants .HttpHeaders .DedicatedGatewayCacheStaleness ] = options [
332+ Constants .Kwargs .MAX_INTEGRATED_CACHE_STALENESS
333+ ]
295334
296335 if options .get (Constants .Kwargs .AUTO_UPGRADE_POLICY ):
297336 headers [http_constants .HttpHeaders .AutoscaleSettings ] = options [Constants .Kwargs .AUTO_UPGRADE_POLICY ]
298337
299338 if options .get (Constants .Kwargs .CORRELATED_ACTIVITY_ID ):
300- headers [http_constants .HttpHeaders .CorrelatedActivityId ] = options [Constants .Kwargs .CORRELATED_ACTIVITY_ID ]
339+ headers [http_constants .HttpHeaders .CorrelatedActivityId ] = options [
340+ Constants .Kwargs .CORRELATED_ACTIVITY_ID
341+ ]
301342
302343 if options .get (Constants .Kwargs .THROUGHPUT_BUCKET ):
303344 headers [http_constants .HttpHeaders .ThroughputBucket ] = options [Constants .Kwargs .THROUGHPUT_BUCKET ]
304345
305346 if resource_type == "docs" and verb != "get" :
306347 if Constants .Kwargs .RESPONSE_PAYLOAD_ON_WRITE_DISABLED in options :
307- responsePayloadOnWriteDisabled = options [Constants .Kwargs .RESPONSE_PAYLOAD_ON_WRITE_DISABLED ]
348+ responsePayloadOnWriteDisabled = options [
349+ Constants .Kwargs .RESPONSE_PAYLOAD_ON_WRITE_DISABLED
350+ ]
308351 else :
309- responsePayloadOnWriteDisabled = cosmos_client_connection .connection_policy .ResponsePayloadOnWriteDisabled
352+ responsePayloadOnWriteDisabled = (
353+ cosmos_client_connection .connection_policy .ResponsePayloadOnWriteDisabled
354+ )
310355
311356 if responsePayloadOnWriteDisabled :
312357 headers [http_constants .HttpHeaders .Prefer ] = "return=minimal"
313358
314359 # If it is an operation at the container level, verify the rid of the container to see if the cache needs to be
315360 # refreshed.
316361 if resource_type != 'dbs' and options .get (Constants .Kwargs .CONTAINER_RID ):
317- headers [http_constants .HttpHeaders .IntendedCollectionRID ] = options [Constants .Kwargs .CONTAINER_RID ]
362+ headers [http_constants .HttpHeaders .IntendedCollectionRID ] = options [
363+ Constants .Kwargs .CONTAINER_RID
364+ ]
318365
319366 if resource_type == "" :
320367 resource_type = http_constants .ResourceType .DatabaseAccount
@@ -352,19 +399,22 @@ def set_session_token_header(
352399 if _is_session_token_request (cosmos_client_connection , headers , request_object ):
353400 # if there is a token set via option, then use it to override default
354401 if options .get (Constants .Kwargs .SESSION_TOKEN ):
355- headers [http_constants .HttpHeaders .SessionToken ] = options [Constants .Kwargs .SESSION_TOKEN ]
402+ headers [http_constants .HttpHeaders .SessionToken ] = options [
403+ Constants .Kwargs .SESSION_TOKEN
404+ ]
356405 else :
357406 # check if the client's default consistency is session (and request consistency level is same),
358407 # then update from session container
359408 if headers [http_constants .HttpHeaders .ConsistencyLevel ] == documents .ConsistencyLevel .Session and \
360409 cosmos_client_connection .session :
361410 # populate session token from the client's session container
362- session_token = (
363- cosmos_client_connection .session .get_session_token (path ,
364- options .get (Constants .Kwargs .PARTITION_KEY ),
365- cosmos_client_connection ._container_properties_cache ,
366- cosmos_client_connection ._routing_map_provider ,
367- partition_key_range_id ))
411+ session_token = cosmos_client_connection .session .get_session_token (
412+ path ,
413+ options .get (Constants .Kwargs .PARTITION_KEY ),
414+ cosmos_client_connection ._container_properties_cache ,
415+ cosmos_client_connection ._routing_map_provider ,
416+ partition_key_range_id
417+ )
368418 if session_token != "" :
369419 headers [http_constants .HttpHeaders .SessionToken ] = session_token
370420
@@ -379,19 +429,22 @@ async def set_session_token_header_async(
379429 if _is_session_token_request (cosmos_client_connection , headers , request_object ):
380430 # if there is a token set via option, then use it to override default
381431 if options .get (Constants .Kwargs .SESSION_TOKEN ):
382- headers [http_constants .HttpHeaders .SessionToken ] = options [Constants .Kwargs .SESSION_TOKEN ]
432+ headers [http_constants .HttpHeaders .SessionToken ] = options [
433+ Constants .Kwargs .SESSION_TOKEN
434+ ]
383435 else :
384436 # check if the client's default consistency is session (and request consistency level is same),
385437 # then update from session container
386438 if headers [http_constants .HttpHeaders .ConsistencyLevel ] == documents .ConsistencyLevel .Session and \
387439 cosmos_client_connection .session :
388440 # populate session token from the client's session container
389- session_token = \
390- await cosmos_client_connection .session .get_session_token_async (path ,
391- options .get (Constants .Kwargs .PARTITION_KEY ),
392- cosmos_client_connection ._container_properties_cache ,
393- cosmos_client_connection ._routing_map_provider ,
394- partition_key_range_id )
441+ session_token = await cosmos_client_connection .session .get_session_token_async (
442+ path ,
443+ options .get (Constants .Kwargs .PARTITION_KEY ),
444+ cosmos_client_connection ._container_properties_cache ,
445+ cosmos_client_connection ._routing_map_provider ,
446+ partition_key_range_id
447+ )
395448 if session_token != "" :
396449 headers [http_constants .HttpHeaders .SessionToken ] = session_token
397450
0 commit comments