#NEWLINE# def __validate_mutation( self , mutation ) : #NEWLINE# #INDENT# if mutation . HasField ( 'insert' ) : #NEWLINE# #INDENT# self . __entity_validator . validate_entity ( UPSERT , mutation . insert ) #NEWLINE# mutation_key = mutation . insert . key #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if mutation . HasField ( 'update' ) : #NEWLINE# #INDENT# self . __entity_validator . validate_entity ( UPDATE , mutation . update ) #NEWLINE# mutation_key = mutation . update . key #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if mutation . HasField ( 'upsert' ) : #NEWLINE# #INDENT# self . __entity_validator . validate_entity ( UPSERT , mutation . upsert ) #NEWLINE# mutation_key = mutation . upsert . key #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if mutation . HasField ( 'delete' ) : #NEWLINE# #INDENT# self . __entity_validator . validate_key ( DELETE , mutation . delete ) #NEWLINE# mutation_key = mutation_key . delete #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _assert_condition ( False , 'mutation lacks required op' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( mutation . WhichOneof ( 'conflict_detection_strategy' ) != None ) : #NEWLINE# #INDENT# _assert_condition ( datastore_pbs . is_complete_v1_key ( mutation_key ) , 'conflict detection is not allowed for incomplete keys' ) #NEWLINE# #UNINDENT# if mutation . HasField ( 'base_version' ) : #NEWLINE# #INDENT# _assert_condition ( ( mutation . base_version >= 0 ) , ( 'Invalid base_version: %d, it should be >= 0' % mutation . base_version ) )