def _key_response_post(self, request, body, bucket_name, query, key_name):
    self._set_action('KEY', 'POST', query)
    self._authenticate_and_authorize_s3_action()
    if ((body == b'') and ('uploads' in query)):
        metadata = metadata_from_headers(request.headers)
        storage_type = request.headers.get('x-amz-storage-class', 'STANDARD')
        multipart_id = self.backend.create_multipart_upload(bucket_name, key_name, metadata, storage_type)
        template = self.response_template(S3_MULTIPART_INITIATE_RESPONSE)
        response = template.render(bucket_name=bucket_name, key_name=key_name, upload_id=multipart_id)
        return (200, {}, response)
    if query.get('uploadId'):
        body = self._complete_multipart_body(body)
        multipart_id = query['uploadId'][0]
        (multipart, value, etag) = self.backend.complete_multipart_upload(bucket_name, multipart_id, body)
        if (value is None):
            return (400, {}, '')
        key = self.backend.put_object(bucket_name, multipart.key_name, value, storage=multipart.storage, etag=etag, multipart=multipart)
        key.set_metadata(multipart.metadata)
        template = self.response_template(S3_MULTIPART_COMPLETE_RESPONSE)
        headers = {}
        if key.version_id:
            headers['x-amz-version-id'] = key.version_id
        return (200, headers, template.render(bucket_name=bucket_name, key_name=key.name, etag=key.etag))
    elif ('restore' in query):
        es = minidom.parseString(body).getElementsByTagName('Days')
        days = es[0].childNodes[0].wholeText
        key = self.backend.get_object(bucket_name, key_name)
        r = 202
        if (key.expiry_date is not None):
            r = 200
        key.restore(int(days))
        return (r, {}, '')
    else:
        raise NotImplementedError('Method POST had only been implemented for multipart uploads and restore operations, so far')
def _key_response_post(self, request, body, bucket_name, query, key_name):
    self._set_action('KEY', 'POST', query)
    self._authenticate_and_authorize_s3_action()
    if ((body == b) and ('uploads' in query)):
        metadata = metadata_from_headers(request.headers)
        storage_type = request.headers.get('x-amz-storage-class', 'STANDARD')
        multipart_id = self.backend.create_multipart_upload(bucket_name, key_name, metadata, storage_type)
        template = self.response_template(S3_MULTIPART_INITIATE_RESPONSE)
        response = template.render(bucket_name=bucket_name, key_name=key_name, upload_id=multipart_id)
        return (200, {}, response)
    if query.get('uploadId'):
        body = self._complete_multipart_body(body)
        multipart_id = query['uploadId'][0]
        (multipart, value, etag) = self.backend.complete_multipart_upload(bucket_name, multipart_id, body)
        if (value is None):
            return (400, {}, )
        key = self.backend.put_object(bucket_name, multipart.key_name, value, storage=multipart.storage, etag=etag, multipart=multipart)
        key.set_metadata(multipart.metadata)
        template = self.response_template(S3_MULTIPART_COMPLETE_RESPONSE)
        headers = {}
        if key.version_id:
            headers['x-amz-version-id'] = key.version_id
        return (200, headers, template.render(bucket_name=bucket_name, key_name=key.name, etag=key.etag))
    elif ('restore' in query):
        es = minidom.parseString(body).getElementsByTagName('Days')
        days = es[0].childNodes[0].wholeText
        key = self.backend.get_object(bucket_name, key_name)
        r = 202
        if (key.expiry_date is not None):
            r = 200
        key.restore(int(days))
        return (r, {}, )
    else:
        raise NotImplementedError('Method POST had only been implemented for multipart uploads and restore operations, so far')