@@ -178,6 +178,7 @@ async def create_container(
178178 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
179179 change_feed_policy : Optional [dict [str , Any ]] = None ,
180180 full_text_policy : Optional [dict [str , Any ]] = None ,
181+ global_secondary_index_definition : Optional [Any ] = None ,
181182 return_properties : Literal [False ] = False ,
182183 ** kwargs : Any
183184 ) -> ContainerProxy :
@@ -255,6 +256,7 @@ async def create_container( # pylint: disable=too-many-statements
255256 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
256257 change_feed_policy : Optional [dict [str , Any ]] = None ,
257258 full_text_policy : Optional [dict [str , Any ]] = None ,
259+ global_secondary_index_definition : Optional [Any ] = None ,
258260 return_properties : Literal [True ],
259261 ** kwargs : Any
260262 ) -> tuple [ContainerProxy , CosmosDict ]:
@@ -353,6 +355,9 @@ async def create_container( # pylint:disable=docstring-should-be-keyword, too-ma
353355 :keyword dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
354356 Used to denote the default language to be used for all full text indexes, or to individually
355357 assign a language to each full text index path.
358+ :keyword global_secondary_index_definition: The global secondary index definition for the container.
359+ Used to create a GSI container derived from a source container via a SQL projection query.
360+ :paramtype global_secondary_index_definition: ~azure.cosmos.GlobalSecondaryIndexDefinition or dict[str, Any]
356361 :keyword bool return_properties: Specifies whether to return either a ContainerProxy
357362 or a Tuple of a ContainerProxy and the container properties.
358363 :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The container creation failed.
@@ -393,6 +398,7 @@ async def create_container( # pylint:disable=docstring-should-be-keyword, too-ma
393398 computed_properties = kwargs .pop ('computed_properties' , None )
394399 change_feed_policy = kwargs .pop ('change_feed_policy' , None )
395400 full_text_policy = kwargs .pop ('full_text_policy' , None )
401+ global_secondary_index_definition = kwargs .pop ('global_secondary_index_definition' , None )
396402 return_properties = kwargs .pop ('return_properties' , False )
397403
398404 session_token = kwargs .get ('session_token' )
@@ -440,6 +446,12 @@ async def create_container( # pylint:disable=docstring-should-be-keyword, too-ma
440446 definition ["changeFeedPolicy" ] = change_feed_policy
441447 if full_text_policy is not None :
442448 definition ["fullTextPolicy" ] = full_text_policy
449+ if global_secondary_index_definition is not None :
450+ gsi_dict = (global_secondary_index_definition ._to_dict ()
451+ if hasattr (global_secondary_index_definition , '_to_dict' )
452+ else global_secondary_index_definition )
453+ definition ["globalSecondaryIndexDefinition" ] = gsi_dict
454+ definition ["materializedViewDefinition" ] = gsi_dict
443455 request_options = _build_options (kwargs )
444456 _set_throughput_options (offer = offer_throughput , request_options = request_options )
445457
@@ -467,6 +479,7 @@ async def create_container_if_not_exists(
467479 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
468480 change_feed_policy : Optional [dict [str , Any ]] = None ,
469481 full_text_policy : Optional [dict [str , Any ]] = None ,
482+ global_secondary_index_definition : Optional [Any ] = None ,
470483 return_properties : Literal [False ] = False ,
471484 ** kwargs : Any
472485 ) -> ContainerProxy :
@@ -528,6 +541,7 @@ async def create_container_if_not_exists(
528541 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
529542 change_feed_policy : Optional [dict [str , Any ]] = None ,
530543 full_text_policy : Optional [dict [str , Any ]] = None ,
544+ global_secondary_index_definition : Optional [Any ] = None ,
531545 return_properties : Literal [True ],
532546 ** kwargs : Any
533547 ) -> tuple [ContainerProxy , CosmosDict ]:
@@ -612,6 +626,9 @@ async def create_container_if_not_exists( # pylint:disable=docstring-should-be-k
612626 :keyword dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
613627 Used to denote the default language to be used for all full text indexes, or to individually
614628 assign a language to each full text index path.
629+ :keyword global_secondary_index_definition: The global secondary index definition for the container.
630+ Used to create a GSI container derived from a source container via a SQL projection query.
631+ :paramtype global_secondary_index_definition: ~azure.cosmos.GlobalSecondaryIndexDefinition or dict[str, Any]
615632 :keyword bool return_properties: Specifies whether to return either a ContainerProxy
616633 or a Tuple of a ContainerProxy and the container properties.
617634 :raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The container creation failed.
@@ -635,6 +652,7 @@ async def create_container_if_not_exists( # pylint:disable=docstring-should-be-k
635652 computed_properties = kwargs .pop ('computed_properties' , None )
636653 change_feed_policy = kwargs .pop ('change_feed_policy' , None )
637654 full_text_policy = kwargs .pop ('full_text_policy' , None )
655+ global_secondary_index_definition = kwargs .pop ('global_secondary_index_definition' , None )
638656 return_properties = kwargs .pop ('return_properties' , False )
639657
640658 session_token = kwargs .get ('session_token' )
@@ -679,6 +697,7 @@ async def create_container_if_not_exists( # pylint:disable=docstring-should-be-k
679697 vector_embedding_policy = vector_embedding_policy ,
680698 change_feed_policy = change_feed_policy ,
681699 full_text_policy = full_text_policy ,
700+ global_secondary_index_definition = global_secondary_index_definition ,
682701 return_properties = return_properties ,
683702 ** kwargs
684703 )
@@ -816,6 +835,7 @@ async def replace_container(
816835 analytical_storage_ttl : Optional [int ] = None ,
817836 computed_properties : Optional [list [dict [str , str ]]] = None ,
818837 full_text_policy : Optional [dict [str , Any ]] = None ,
838+ global_secondary_index_definition : Optional [Any ] = None ,
819839 return_properties : Literal [False ] = False ,
820840 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
821841 ** kwargs : Any
@@ -877,6 +897,7 @@ async def replace_container( # pylint:disable=docstring-missing-param
877897 analytical_storage_ttl : Optional [int ] = None ,
878898 computed_properties : Optional [list [dict [str , str ]]] = None ,
879899 full_text_policy : Optional [dict [str , Any ]] = None ,
900+ global_secondary_index_definition : Optional [Any ] = None ,
880901 return_properties : Literal [True ],
881902 vector_embedding_policy : Optional [dict [str , Any ]] = None ,
882903 ** kwargs : Any
@@ -959,6 +980,9 @@ async def replace_container( # pylint:disable=docstring-should-be-keyword
959980 :keyword dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
960981 Used to denote the default language to be used for all full text indexes, or to individually
961982 assign a language to each full text index path.
983+ :keyword global_secondary_index_definition: The global secondary index definition for the container.
984+ Used to create a GSI container derived from a source container via a SQL projection query.
985+ :paramtype global_secondary_index_definition: ~azure.cosmos.GlobalSecondaryIndexDefinition or dict[str, Any]
962986 :keyword bool return_properties: Specifies whether to return either a ContainerProxy
963987 or a Tuple of a ContainerProxy and the container properties.
964988 :returns: A `ContainerProxy` instance representing the new container or a tuple of the ContainerProxy
@@ -989,6 +1013,7 @@ async def replace_container( # pylint:disable=docstring-should-be-keyword
9891013 analytical_storage_ttl = kwargs .pop ('analytical_storage_ttl' , None )
9901014 computed_properties = kwargs .pop ('computed_properties' , None )
9911015 full_text_policy = kwargs .pop ('full_text_policy' , None )
1016+ global_secondary_index_definition = kwargs .pop ('global_secondary_index_definition' , None )
9921017 return_properties = kwargs .pop ('return_properties' , False )
9931018 vector_embedding_policy = kwargs .pop ('vector_embedding_policy' , None )
9941019
@@ -1031,6 +1056,12 @@ async def replace_container( # pylint:disable=docstring-should-be-keyword
10311056 }.items ()
10321057 if value is not None
10331058 }
1059+ if global_secondary_index_definition is not None :
1060+ gsi_dict = (global_secondary_index_definition ._to_dict ()
1061+ if hasattr (global_secondary_index_definition , '_to_dict' )
1062+ else global_secondary_index_definition )
1063+ parameters ["globalSecondaryIndexDefinition" ] = gsi_dict
1064+ parameters ["materializedViewDefinition" ] = gsi_dict
10341065
10351066 container_properties = await self .client_connection .ReplaceContainer (
10361067 container_link , collection = parameters , options = request_options , ** kwargs
0 commit comments