def _insert_or_replace_entity(entity, require_encryption=False,
                              key_encryption_key=None, encryption_resolver=None):
    '''
    Constructs an insert or replace entity request.
    '''
    _validate_entity(entity, key_encryption_key is not None)
    _validate_encryption_required(require_encryption, key_encryption_key)

    request = HTTPRequest()
    request.method = 'PUT'
    request.headers = {
        _DEFAULT_CONTENT_TYPE_HEADER[0]: _DEFAULT_CONTENT_TYPE_HEADER[1],
        _DEFAULT_ACCEPT_HEADER[0]: _DEFAULT_ACCEPT_HEADER[1],
    }

    if(key_encryption_key):
        entity = _encrypt_entity(entity, key_encryption_key, encryption_resolver)
    request.body = _get_request_body(_convert_entity_to_json(entity))

    return request
def _insert_or_replace_entity ( entity , require_encryption = False , key_encryption_key = None , encryption_resolver = None ) : _validate_entity ( entity , key_encryption_key is not None ) _validate_encryption_required ( require_encryption , key_encryption_key ) request = HTTPRequest ( ) request . method = 'PUT' request . headers = { _DEFAULT_CONTENT_TYPE_HEADER [ 0 ] : _DEFAULT_CONTENT_TYPE_HEADER [ 1 ] , _DEFAULT_ACCEPT_HEADER [ 0 ] : _DEFAULT_ACCEPT_HEADER [ 1 ] , } if ( key_encryption_key ) : entity = _encrypt_entity ( entity , key_encryption_key , encryption_resolver ) request . body = _get_request_body ( _convert_entity_to_json ( entity ) ) return request
Constructs an insert or replace entity request.