idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
35,500 | def _GetSerializedPartitionList ( self ) : partition_list = list ( ) for part in self . partitions : partition_list . append ( ( part . node , unpack ( "<L" , part . hash_value ) [ 0 ] ) ) return partition_list | Gets the serialized version of the ConsistentRing . Added this helper for the test code . |
35,501 | def _GetBytes ( partition_key ) : if isinstance ( partition_key , six . string_types ) : return bytearray ( partition_key , encoding = 'utf-8' ) else : raise ValueError ( "Unsupported " + str ( type ( partition_key ) ) + " for partitionKey." ) | Gets the bytes representing the value of the partition key . |
35,502 | def _LowerBoundSearch ( partitions , hash_value ) : for i in xrange ( 0 , len ( partitions ) - 1 ) : if partitions [ i ] . CompareTo ( hash_value ) <= 0 and partitions [ i + 1 ] . CompareTo ( hash_value ) > 0 : return i return len ( partitions ) - 1 | Searches the partition in the partition array using hashValue . |
35,503 | def _fetch_items_helper_no_retries ( self , fetch_function ) : fetched_items = [ ] while self . _continuation or not self . _has_started : if not self . _has_started : self . _has_started = True self . _options [ 'continuation' ] = self . _continuation ( fetched_items , response_headers ) = fetch_function ( self . _opt... | Fetches more items and doesn t retry on failure |
35,504 | def _fetch_next_block ( self ) : fetched_items = self . _fetch_items_helper_with_retries ( self . _fetch_function ) while not fetched_items : if self . _collection_links and self . _current_collection_index < self . _collection_links_length : path = base . GetPathFromLink ( self . _collection_links [ self . _current_co... | Fetches the next block of query results . This iterates fetches the next block of results from the current collection link . Once the current collection results were exhausted . It moves to the next collection link . |
35,505 | def Contains ( self , other ) : if other is None : raise ValueError ( "other is None." ) if isinstance ( other , Range ) : if other . low >= self . low and other . high <= self . high : return True return False else : return self . Contains ( Range ( other , other ) ) | Checks if the passed parameter is in the range of this object . |
35,506 | def Intersect ( self , other ) : if isinstance ( other , Range ) : max_low = self . low if ( self . low >= other . low ) else other . low min_high = self . high if ( self . high <= other . high ) else other . high if max_low <= min_high : return True return False | Checks if the passed parameter intersects the range of this object . |
35,507 | def RegisterPartitionResolver ( self , database_link , partition_resolver ) : if not database_link : raise ValueError ( "database_link is None or empty." ) if partition_resolver is None : raise ValueError ( "partition_resolver is None." ) self . partition_resolvers = { base . TrimBeginningAndEndingSlashes ( database_li... | Registers the partition resolver associated with the database link |
35,508 | def GetPartitionResolver ( self , database_link ) : if not database_link : raise ValueError ( "database_link is None or empty." ) return self . partition_resolvers . get ( base . TrimBeginningAndEndingSlashes ( database_link ) ) | Gets the partition resolver associated with the database link |
35,509 | def CreateDatabase ( self , database , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( database ) path = '/dbs' return self . Create ( database , path , 'dbs' , None , None , options ) | Creates a database . |
35,510 | def ReadDatabase ( self , database_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( database_link ) database_id = base . GetResourceIdOrFullNameFromLink ( database_link ) return self . Read ( path , 'dbs' , database_id , None , options ) | Reads a database . |
35,511 | def QueryDatabases ( self , query , options = None ) : if options is None : options = { } def fetch_fn ( options ) : return self . __QueryFeed ( '/dbs' , 'dbs' , '' , lambda r : r [ 'Databases' ] , lambda _ , b : b , query , options ) , self . last_response_headers return query_iterable . QueryIterable ( self , query ,... | Queries databases . |
35,512 | def ReadContainers ( self , database_link , options = None ) : if options is None : options = { } return self . QueryContainers ( database_link , None , options ) | Reads all collections in a database . |
35,513 | def CreateContainer ( self , database_link , collection , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( collection ) path = base . GetPathFromLink ( database_link , 'colls' ) database_id = base . GetResourceIdOrFullNameFromLink ( database_link ) return self . Create ( collect... | Creates a collection in a database . |
35,514 | def ReplaceContainer ( self , collection_link , collection , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( collection ) path = base . GetPathFromLink ( collection_link ) collection_id = base . GetResourceIdOrFullNameFromLink ( collection_link ) return self . Replace ( collect... | Replaces a collection and return it . |
35,515 | def ReadContainer ( self , collection_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( collection_link ) collection_id = base . GetResourceIdOrFullNameFromLink ( collection_link ) return self . Read ( path , 'colls' , collection_id , None , options ) | Reads a collection . |
35,516 | def UpsertUser ( self , database_link , user , options = None ) : if options is None : options = { } database_id , path = self . _GetDatabaseIdWithPathForUser ( database_link , user ) return self . Upsert ( user , path , 'users' , database_id , None , options ) | Upserts a user . |
35,517 | def ReadUser ( self , user_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( user_link ) user_id = base . GetResourceIdOrFullNameFromLink ( user_link ) return self . Read ( path , 'users' , user_id , None , options ) | Reads a user . |
35,518 | def ReadUsers ( self , database_link , options = None ) : if options is None : options = { } return self . QueryUsers ( database_link , None , options ) | Reads all users in a database . |
35,519 | def QueryUsers ( self , database_link , query , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( database_link , 'users' ) database_id = base . GetResourceIdOrFullNameFromLink ( database_link ) def fetch_fn ( options ) : return self . __QueryFeed ( path , 'users' , database_id , lam... | Queries users in a database . |
35,520 | def DeleteDatabase ( self , database_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( database_link ) database_id = base . GetResourceIdOrFullNameFromLink ( database_link ) return self . DeleteResource ( path , 'dbs' , database_id , None , options ) | Deletes a database . |
35,521 | def CreatePermission ( self , user_link , permission , options = None ) : if options is None : options = { } path , user_id = self . _GetUserIdWithPathForPermission ( permission , user_link ) return self . Create ( permission , path , 'permissions' , user_id , None , options ) | Creates a permission for a user . |
35,522 | def UpsertPermission ( self , user_link , permission , options = None ) : if options is None : options = { } path , user_id = self . _GetUserIdWithPathForPermission ( permission , user_link ) return self . Upsert ( permission , path , 'permissions' , user_id , None , options ) | Upserts a permission for a user . |
35,523 | def ReadPermission ( self , permission_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( permission_link ) permission_id = base . GetResourceIdOrFullNameFromLink ( permission_link ) return self . Read ( path , 'permissions' , permission_id , None , options ) | Reads a permission . |
35,524 | def ReadPermissions ( self , user_link , options = None ) : if options is None : options = { } return self . QueryPermissions ( user_link , None , options ) | Reads all permissions for a user . |
35,525 | def QueryPermissions ( self , user_link , query , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( user_link , 'permissions' ) user_id = base . GetResourceIdOrFullNameFromLink ( user_link ) def fetch_fn ( options ) : return self . __QueryFeed ( path , 'permissions' , user_id , lambd... | Queries permissions for a user . |
35,526 | def ReplaceUser ( self , user_link , user , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( user ) path = base . GetPathFromLink ( user_link ) user_id = base . GetResourceIdOrFullNameFromLink ( user_link ) return self . Replace ( user , path , 'users' , user_id , None , options... | Replaces a user and return it . |
35,527 | def DeleteUser ( self , user_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( user_link ) user_id = base . GetResourceIdOrFullNameFromLink ( user_link ) return self . DeleteResource ( path , 'users' , user_id , None , options ) | Deletes a user . |
35,528 | def ReplacePermission ( self , permission_link , permission , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( permission ) path = base . GetPathFromLink ( permission_link ) permission_id = base . GetResourceIdOrFullNameFromLink ( permission_link ) return self . Replace ( permis... | Replaces a permission and return it . |
35,529 | def DeletePermission ( self , permission_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( permission_link ) permission_id = base . GetResourceIdOrFullNameFromLink ( permission_link ) return self . DeleteResource ( path , 'permissions' , permission_id , None , options ) | Deletes a permission . |
35,530 | def ReadItems ( self , collection_link , feed_options = None ) : if feed_options is None : feed_options = { } return self . QueryItems ( collection_link , None , feed_options ) | Reads all documents in a collection . |
35,531 | def QueryItems ( self , database_or_Container_link , query , options = None , partition_key = None ) : database_or_Container_link = base . TrimBeginningAndEndingSlashes ( database_or_Container_link ) if options is None : options = { } if ( base . IsDatabaseLink ( database_or_Container_link ) ) : return query_iterable .... | Queries documents in a collection . |
35,532 | def QueryItemsChangeFeed ( self , collection_link , options = None ) : partition_key_range_id = None if options is not None and 'partitionKeyRangeId' in options : partition_key_range_id = options [ 'partitionKeyRangeId' ] return self . _QueryChangeFeed ( collection_link , "Documents" , options , partition_key_range_id ... | Queries documents change feed in a collection . |
35,533 | def _QueryChangeFeed ( self , collection_link , resource_type , options = None , partition_key_range_id = None ) : if options is None : options = { } options [ 'changeFeed' ] = True resource_key_map = { 'Documents' : 'docs' } if resource_type not in resource_key_map : raise NotImplementedError ( resource_type + " chang... | Queries change feed of a resource in a collection . |
35,534 | def _ReadPartitionKeyRanges ( self , collection_link , feed_options = None ) : if feed_options is None : feed_options = { } return self . _QueryPartitionKeyRanges ( collection_link , None , feed_options ) | Reads Partition Key Ranges . |
35,535 | def CreateItem ( self , database_or_Container_link , document , options = None ) : if options is None : options = { } if ( base . IsItemContainerLink ( database_or_Container_link ) ) : options = self . _AddPartitionKey ( database_or_Container_link , document , options ) collection_id , document , path = self . _GetCont... | Creates a document in a collection . |
35,536 | def UpsertItem ( self , database_or_Container_link , document , options = None ) : if options is None : options = { } if ( base . IsItemContainerLink ( database_or_Container_link ) ) : options = self . _AddPartitionKey ( database_or_Container_link , document , options ) collection_id , document , path = self . _GetCont... | Upserts a document in a collection . |
35,537 | def ReadItem ( self , document_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( document_link ) document_id = base . GetResourceIdOrFullNameFromLink ( document_link ) return self . Read ( path , 'docs' , document_id , None , options ) | Reads a document . |
35,538 | def ReadTriggers ( self , collection_link , options = None ) : if options is None : options = { } return self . QueryTriggers ( collection_link , None , options ) | Reads all triggers in a collection . |
35,539 | def CreateTrigger ( self , collection_link , trigger , options = None ) : if options is None : options = { } collection_id , path , trigger = self . _GetContainerIdWithPathForTrigger ( collection_link , trigger ) return self . Create ( trigger , path , 'triggers' , collection_id , None , options ) | Creates a trigger in a collection . |
35,540 | def UpsertTrigger ( self , collection_link , trigger , options = None ) : if options is None : options = { } collection_id , path , trigger = self . _GetContainerIdWithPathForTrigger ( collection_link , trigger ) return self . Upsert ( trigger , path , 'triggers' , collection_id , None , options ) | Upserts a trigger in a collection . |
35,541 | def ReadTrigger ( self , trigger_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( trigger_link ) trigger_id = base . GetResourceIdOrFullNameFromLink ( trigger_link ) return self . Read ( path , 'triggers' , trigger_id , None , options ) | Reads a trigger . |
35,542 | def ReadUserDefinedFunctions ( self , collection_link , options = None ) : if options is None : options = { } return self . QueryUserDefinedFunctions ( collection_link , None , options ) | Reads all user defined functions in a collection . |
35,543 | def QueryUserDefinedFunctions ( self , collection_link , query , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( collection_link , 'udfs' ) collection_id = base . GetResourceIdOrFullNameFromLink ( collection_link ) def fetch_fn ( options ) : return self . __QueryFeed ( path , 'udfs... | Queries user defined functions in a collection . |
35,544 | def CreateUserDefinedFunction ( self , collection_link , udf , options = None ) : if options is None : options = { } collection_id , path , udf = self . _GetContainerIdWithPathForUDF ( collection_link , udf ) return self . Create ( udf , path , 'udfs' , collection_id , None , options ) | Creates a user defined function in a collection . |
35,545 | def UpsertUserDefinedFunction ( self , collection_link , udf , options = None ) : if options is None : options = { } collection_id , path , udf = self . _GetContainerIdWithPathForUDF ( collection_link , udf ) return self . Upsert ( udf , path , 'udfs' , collection_id , None , options ) | Upserts a user defined function in a collection . |
35,546 | def ReadUserDefinedFunction ( self , udf_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( udf_link ) udf_id = base . GetResourceIdOrFullNameFromLink ( udf_link ) return self . Read ( path , 'udfs' , udf_id , None , options ) | Reads a user defined function . |
35,547 | def ReadStoredProcedures ( self , collection_link , options = None ) : if options is None : options = { } return self . QueryStoredProcedures ( collection_link , None , options ) | Reads all store procedures in a collection . |
35,548 | def CreateStoredProcedure ( self , collection_link , sproc , options = None ) : if options is None : options = { } collection_id , path , sproc = self . _GetContainerIdWithPathForSproc ( collection_link , sproc ) return self . Create ( sproc , path , 'sprocs' , collection_id , None , options ) | Creates a stored procedure in a collection . |
35,549 | def UpsertStoredProcedure ( self , collection_link , sproc , options = None ) : if options is None : options = { } collection_id , path , sproc = self . _GetContainerIdWithPathForSproc ( collection_link , sproc ) return self . Upsert ( sproc , path , 'sprocs' , collection_id , None , options ) | Upserts a stored procedure in a collection . |
35,550 | def ReadStoredProcedure ( self , sproc_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( sproc_link ) sproc_id = base . GetResourceIdOrFullNameFromLink ( sproc_link ) return self . Read ( path , 'sprocs' , sproc_id , None , options ) | Reads a stored procedure . |
35,551 | def ReadConflicts ( self , collection_link , feed_options = None ) : if feed_options is None : feed_options = { } return self . QueryConflicts ( collection_link , None , feed_options ) | Reads conflicts . |
35,552 | def ReadConflict ( self , conflict_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( conflict_link ) conflict_id = base . GetResourceIdOrFullNameFromLink ( conflict_link ) return self . Read ( path , 'conflicts' , conflict_id , None , options ) | Reads a conflict . |
35,553 | def DeleteContainer ( self , collection_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( collection_link ) collection_id = base . GetResourceIdOrFullNameFromLink ( collection_link ) return self . DeleteResource ( path , 'colls' , collection_id , None , options ) | Deletes a collection . |
35,554 | def ReplaceItem ( self , document_link , new_document , options = None ) : CosmosClient . __ValidateResource ( new_document ) path = base . GetPathFromLink ( document_link ) document_id = base . GetResourceIdOrFullNameFromLink ( document_link ) if options is None : options = { } collection_link = base . GetItemContaine... | Replaces a document and returns it . |
35,555 | def CreateAttachment ( self , document_link , attachment , options = None ) : if options is None : options = { } document_id , path = self . _GetItemIdWithPathForAttachment ( attachment , document_link ) return self . Create ( attachment , path , 'attachments' , document_id , None , options ) | Creates an attachment in a document . |
35,556 | def UpsertAttachment ( self , document_link , attachment , options = None ) : if options is None : options = { } document_id , path = self . _GetItemIdWithPathForAttachment ( attachment , document_link ) return self . Upsert ( attachment , path , 'attachments' , document_id , None , options ) | Upserts an attachment in a document . |
35,557 | def CreateAttachmentAndUploadMedia ( self , document_link , readable_stream , options = None ) : if options is None : options = { } document_id , initial_headers , path = self . _GetItemIdWithPathForAttachmentMedia ( document_link , options ) return self . Create ( readable_stream , path , 'attachments' , document_id ,... | Creates an attachment and upload media . |
35,558 | def UpsertAttachmentAndUploadMedia ( self , document_link , readable_stream , options = None ) : if options is None : options = { } document_id , initial_headers , path = self . _GetItemIdWithPathForAttachmentMedia ( document_link , options ) return self . Upsert ( readable_stream , path , 'attachments' , document_id ,... | Upserts an attachment and upload media . |
35,559 | def ReadAttachment ( self , attachment_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( attachment_link ) attachment_id = base . GetResourceIdOrFullNameFromLink ( attachment_link ) return self . Read ( path , 'attachments' , attachment_id , None , options ) | Reads an attachment . |
35,560 | def ReadAttachments ( self , document_link , options = None ) : if options is None : options = { } return self . QueryAttachments ( document_link , None , options ) | Reads all attachments in a document . |
35,561 | def QueryAttachments ( self , document_link , query , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( document_link , 'attachments' ) document_id = base . GetResourceIdOrFullNameFromLink ( document_link ) def fetch_fn ( options ) : return self . __QueryFeed ( path , 'attachments' ,... | Queries attachments in a document . |
35,562 | def ReadMedia ( self , media_link ) : default_headers = self . default_headers path = base . GetPathFromLink ( media_link ) media_id = base . GetResourceIdOrFullNameFromLink ( media_link ) attachment_id = base . GetAttachmentIdFromMediaId ( media_id ) headers = base . GetHeaders ( self , default_headers , 'get' , path ... | Reads a media . |
35,563 | def UpdateMedia ( self , media_link , readable_stream , options = None ) : if options is None : options = { } initial_headers = dict ( self . default_headers ) if options . get ( 'slug' ) : initial_headers [ http_constants . HttpHeaders . Slug ] = options [ 'slug' ] if options . get ( 'contentType' ) : initial_headers ... | Updates a media and returns it . |
35,564 | def ReplaceAttachment ( self , attachment_link , attachment , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( attachment ) path = base . GetPathFromLink ( attachment_link ) attachment_id = base . GetResourceIdOrFullNameFromLink ( attachment_link ) return self . Replace ( attach... | Replaces an attachment and returns it . |
35,565 | def DeleteAttachment ( self , attachment_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( attachment_link ) attachment_id = base . GetResourceIdOrFullNameFromLink ( attachment_link ) return self . DeleteResource ( path , 'attachments' , attachment_id , None , options ) | Deletes an attachment . |
35,566 | def ReplaceTrigger ( self , trigger_link , trigger , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( trigger ) trigger = trigger . copy ( ) if trigger . get ( 'serverScript' ) : trigger [ 'body' ] = str ( trigger [ 'serverScript' ] ) elif trigger . get ( 'body' ) : trigger [ 'b... | Replaces a trigger and returns it . |
35,567 | def DeleteTrigger ( self , trigger_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( trigger_link ) trigger_id = base . GetResourceIdOrFullNameFromLink ( trigger_link ) return self . DeleteResource ( path , 'triggers' , trigger_id , None , options ) | Deletes a trigger . |
35,568 | def ReplaceUserDefinedFunction ( self , udf_link , udf , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( udf ) udf = udf . copy ( ) if udf . get ( 'serverScript' ) : udf [ 'body' ] = str ( udf [ 'serverScript' ] ) elif udf . get ( 'body' ) : udf [ 'body' ] = str ( udf [ 'body' ... | Replaces a user defined function and returns it . |
35,569 | def DeleteUserDefinedFunction ( self , udf_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( udf_link ) udf_id = base . GetResourceIdOrFullNameFromLink ( udf_link ) return self . DeleteResource ( path , 'udfs' , udf_id , None , options ) | Deletes a user defined function . |
35,570 | def ExecuteStoredProcedure ( self , sproc_link , params , options = None ) : if options is None : options = { } initial_headers = dict ( self . default_headers ) initial_headers . update ( { http_constants . HttpHeaders . Accept : ( runtime_constants . MediaTypes . Json ) } ) if params and not type ( params ) is list :... | Executes a store procedure . |
35,571 | def ReplaceStoredProcedure ( self , sproc_link , sproc , options = None ) : if options is None : options = { } CosmosClient . __ValidateResource ( sproc ) sproc = sproc . copy ( ) if sproc . get ( 'serverScript' ) : sproc [ 'body' ] = str ( sproc [ 'serverScript' ] ) elif sproc . get ( 'body' ) : sproc [ 'body' ] = str... | Replaces a stored procedure and returns it . |
35,572 | def DeleteStoredProcedure ( self , sproc_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( sproc_link ) sproc_id = base . GetResourceIdOrFullNameFromLink ( sproc_link ) return self . DeleteResource ( path , 'sprocs' , sproc_id , None , options ) | Deletes a stored procedure . |
35,573 | def DeleteConflict ( self , conflict_link , options = None ) : if options is None : options = { } path = base . GetPathFromLink ( conflict_link ) conflict_id = base . GetResourceIdOrFullNameFromLink ( conflict_link ) return self . DeleteResource ( path , 'conflicts' , conflict_id , None , options ) | Deletes a conflict . |
35,574 | def ReplaceOffer ( self , offer_link , offer ) : CosmosClient . __ValidateResource ( offer ) path = base . GetPathFromLink ( offer_link ) offer_id = base . GetResourceIdOrFullNameFromLink ( offer_link ) return self . Replace ( offer , path , 'offers' , offer_id , None , None ) | Replaces an offer and returns it . |
35,575 | def ReadOffer ( self , offer_link ) : path = base . GetPathFromLink ( offer_link ) offer_id = base . GetResourceIdOrFullNameFromLink ( offer_link ) return self . Read ( path , 'offers' , offer_id , None , { } ) | Reads an offer . |
35,576 | def GetDatabaseAccount ( self , url_connection = None ) : if url_connection is None : url_connection = self . url_connection initial_headers = dict ( self . default_headers ) headers = base . GetHeaders ( self , initial_headers , 'get' , '' , '' , '' , { } ) request = request_object . _RequestObject ( 'databaseaccount'... | Gets database account info . |
35,577 | def Create ( self , body , path , type , id , initial_headers , options = None ) : if options is None : options = { } initial_headers = initial_headers or self . default_headers headers = base . GetHeaders ( self , initial_headers , 'post' , path , id , type , options ) request = request_object . _RequestObject ( type ... | Creates a Azure Cosmos resource and returns it . |
35,578 | def Replace ( self , resource , path , type , id , initial_headers , options = None ) : if options is None : options = { } initial_headers = initial_headers or self . default_headers headers = base . GetHeaders ( self , initial_headers , 'put' , path , id , type , options ) request = request_object . _RequestObject ( t... | Replaces a Azure Cosmos resource and returns it . |
35,579 | def Read ( self , path , type , id , initial_headers , options = None ) : if options is None : options = { } initial_headers = initial_headers or self . default_headers headers = base . GetHeaders ( self , initial_headers , 'get' , path , id , type , options ) request = request_object . _RequestObject ( type , document... | Reads a Azure Cosmos resource and returns it . |
35,580 | def DeleteResource ( self , path , type , id , initial_headers , options = None ) : if options is None : options = { } initial_headers = initial_headers or self . default_headers headers = base . GetHeaders ( self , initial_headers , 'delete' , path , id , type , options ) request = request_object . _RequestObject ( ty... | Deletes a Azure Cosmos resource and returns it . |
35,581 | def __Get ( self , path , request , headers ) : return synchronized_request . SynchronizedRequest ( self , request , self . _global_endpoint_manager , self . connection_policy , self . _requests_session , 'GET' , path , None , None , headers ) | Azure Cosmos GET http request . |
35,582 | def __Post ( self , path , request , body , headers ) : return synchronized_request . SynchronizedRequest ( self , request , self . _global_endpoint_manager , self . connection_policy , self . _requests_session , 'POST' , path , body , query_params = None , headers = headers ) | Azure Cosmos POST http request . |
35,583 | def __Delete ( self , path , request , headers ) : return synchronized_request . SynchronizedRequest ( self , request , self . _global_endpoint_manager , self . connection_policy , self . _requests_session , 'DELETE' , path , request_data = None , query_params = None , headers = headers ) | Azure Cosmos DELETE http request . |
35,584 | def QueryFeed ( self , path , collection_id , query , options , partition_key_range_id = None ) : return self . __QueryFeed ( path , 'docs' , collection_id , lambda r : r [ 'Documents' ] , lambda _ , b : b , query , options , partition_key_range_id ) , self . last_response_headers | Query Feed for Document Collection resource . |
35,585 | def __QueryFeed ( self , path , type , id , result_fn , create_fn , query , options = None , partition_key_range_id = None ) : if options is None : options = { } if query : __GetBodiesFromQueryResult = result_fn else : def __GetBodiesFromQueryResult ( result ) : if result is not None : return [ create_fn ( self , body ... | Query for more than one Azure Cosmos resources . |
35,586 | def __CheckAndUnifyQueryFormat ( self , query_body ) : if ( self . _query_compatibility_mode == CosmosClient . _QueryCompatibilityMode . Default or self . _query_compatibility_mode == CosmosClient . _QueryCompatibilityMode . Query ) : if not isinstance ( query_body , dict ) and not isinstance ( query_body , six . strin... | Checks and unifies the format of the query body . |
35,587 | def _UpdateSessionIfRequired ( self , request_headers , response_result , response_headers ) : if response_result is None or response_headers is None : return is_session_consistency = False if http_constants . HttpHeaders . ConsistencyLevel in request_headers : if documents . ConsistencyLevel . Session == request_heade... | Updates session if necessary . |
35,588 | def GetResourceIdOrFullNameFromLink ( resource_link ) : if IsNameBased ( resource_link ) : return TrimBeginningAndEndingSlashes ( resource_link ) if resource_link [ - 1 ] != '/' : resource_link = resource_link + '/' if resource_link [ 0 ] != '/' : resource_link = '/' + resource_link path_parts = resource_link . split (... | Gets resource id or full name from resource link . |
35,589 | def GetAttachmentIdFromMediaId ( media_id ) : altchars = '+-' if not six . PY2 : altchars = altchars . encode ( 'utf-8' ) buffer = base64 . b64decode ( str ( media_id ) , altchars ) resoure_id_length = 20 attachment_id = '' if len ( buffer ) > resoure_id_length : attachment_id = base64 . b64encode ( buffer [ 0 : resour... | Gets attachment id from media id . |
35,590 | def GetPathFromLink ( resource_link , resource_type = '' ) : resource_link = TrimBeginningAndEndingSlashes ( resource_link ) if IsNameBased ( resource_link ) : resource_link = urllib_quote ( resource_link ) if resource_type : return '/' + resource_link + '/' + resource_type + '/' else : return '/' + resource_link + '/' | Gets path from resource link with optional resource type |
35,591 | def IsNameBased ( link ) : if not link : return False if link . startswith ( '/' ) and len ( link ) > 1 : link = link [ 1 : ] parts = link . split ( '/' ) if len ( parts ) == 0 or not parts [ 0 ] or not parts [ 0 ] . lower ( ) == 'dbs' : return False if len ( parts ) < 2 or not parts [ 1 ] : return False databaseID = p... | Finds whether the link is name based or not |
35,592 | def IsDatabaseLink ( link ) : if not link : return False link = TrimBeginningAndEndingSlashes ( link ) parts = link . split ( '/' ) if len ( parts ) != 2 : return False if not parts [ 0 ] or not parts [ 0 ] . lower ( ) == 'dbs' : return False if not parts [ 1 ] : return False return True | Finds whether the link is a database Self Link or a database ID based link |
35,593 | def GetItemContainerInfo ( self_link , alt_content_path , id_from_response ) : self_link = TrimBeginningAndEndingSlashes ( self_link ) + '/' index = IndexOfNth ( self_link , '/' , 4 ) if index != - 1 : collection_id = self_link [ 0 : index ] if 'colls' in self_link : index_second_slash = IndexOfNth ( alt_content_path ,... | Given the self link and alt_content_path from the reponse header and result extract the collection name and collection id |
35,594 | def GetItemContainerLink ( link ) : link = TrimBeginningAndEndingSlashes ( link ) + '/' index = IndexOfNth ( link , '/' , 4 ) if index != - 1 : return link [ 0 : index ] else : raise ValueError ( 'Unable to parse document collection link from ' + link ) | Gets the document collection link |
35,595 | def IndexOfNth ( s , value , n ) : remaining = n for i in xrange ( 0 , len ( s ) ) : if s [ i ] == value : remaining -= 1 if remaining == 0 : return i return - 1 | Gets the index of Nth occurance of a given character in a string |
35,596 | def TrimBeginningAndEndingSlashes ( path ) : if path . startswith ( '/' ) : path = path [ 1 : ] if path . endswith ( '/' ) : path = path [ : - 1 ] return path | Trims beginning and ending slashes |
35,597 | def _RequestBodyFromData ( data ) : if isinstance ( data , six . string_types ) or _IsReadableStream ( data ) : return data elif isinstance ( data , ( dict , list , tuple ) ) : json_dumped = json . dumps ( data , separators = ( ',' , ':' ) ) if six . PY2 : return json_dumped . decode ( 'utf-8' ) else : return json_dump... | Gets request body from data . |
35,598 | def _Request ( global_endpoint_manager , request , connection_policy , requests_session , path , request_options , request_body ) : is_media = request_options [ 'path' ] . find ( 'media' ) > - 1 is_media_stream = is_media and connection_policy . MediaReadMode == documents . MediaReadMode . Streamed connection_timeout =... | Makes one http request using the requests module . |
35,599 | def SynchronizedRequest ( client , request , global_endpoint_manager , connection_policy , requests_session , method , path , request_data , query_params , headers ) : request_body = None if request_data : request_body = _RequestBodyFromData ( request_data ) if not request_body : raise errors . UnexpectedDataType ( 'pa... | Performs one synchronized http request according to the parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.