def process_request(self, req, body, project_id): try: validation.validate_params(self.schema, body) # parse request_items request_items = parser.Parser.parse_request_items( body[parser.Props.REQUEST_ITEMS]) except Exception: raise exception.ValidationException() try: req.context.tenant = project_id request_list = collections.deque() for rq_item in request_items: request_list.append(rq_item) response = {'unprocessed_items': {}} if not storage.execute_write_batch(req.context, request_list): raise exception.AWSErrorResponseException( 'Batch write failed') return response except exception.AWSErrorResponseException as e: raise e except Exception: raise exception.AWSErrorResponseException()
def batch_write_item(req, project_id): """The BatchWriteItem operation puts or deletes multiple items in one or more tables. """ with probe.Probe(__name__ + '.validation'): body = req.json_body validation.validate_object(body, "body") request_items_json = body.pop(parser.Props.REQUEST_ITEMS, None) validation.validate_object(request_items_json, parser.Props.REQUEST_ITEMS) validation.validate_unexpected_props(body, "body") # parse request_items request_map = parser.Parser.parse_batch_write_request_items( request_items_json ) unprocessed_items = storage.execute_write_batch(project_id, request_map) return { 'unprocessed_items': parser.Parser.format_request_items( unprocessed_items)}
def process_request(self, req, body, project_id): with probe.Probe(__name__ + ".validation"): validation.validate_object(body, "body") request_items_json = body.pop(parser.Props.REQUEST_ITEMS, None) validation.validate_object(request_items_json, parser.Props.REQUEST_ITEMS) validation.validate_unexpected_props(body, "body") # parse request_items request_map = parser.Parser.parse_batch_write_request_items(request_items_json) unprocessed_items = storage.execute_write_batch(req.context, request_map) return {"unprocessed_items": parser.Parser.format_request_items(unprocessed_items)}
def process_request(self, req, body, project_id): jsonschema.validate(body, self.schema) # parse request_items request_items = parser.Parser.parse_request_items( body[parser.Props.REQUEST_ITEMS]) req.context.tenant = project_id request_list = collections.deque() for rq_item in request_items: request_list.append(rq_item) unprocessed_items = storage.execute_write_batch( req.context, request_list) return { 'unprocessed_items': parser.Parser.format_request_items( unprocessed_items)}
def process_request(self, req, body, project_id): utils.check_project_id(req.context, project_id) jsonschema.validate(body, self.schema) # parse request_items request_items = parser.Parser.parse_request_items( body[parser.Props.REQUEST_ITEMS]) req.context.tenant = project_id request_list = collections.deque() for rq_item in request_items: request_list.append(rq_item) unprocessed_items = storage.execute_write_batch( req.context, request_list) return { 'unprocessed_items': parser.Parser.format_request_items( unprocessed_items)}
def process_request(self, req, body, project_id): with probe.Probe(__name__ + '.validation'): validation.validate_object(body, "body") request_items_json = body.pop(parser.Props.REQUEST_ITEMS, None) validation.validate_object(request_items_json, parser.Props.REQUEST_ITEMS) validation.validate_unexpected_props(body, "body") # parse request_items request_map = parser.Parser.parse_batch_write_request_items( request_items_json) unprocessed_items = storage.execute_write_batch( req.context, request_map) return { 'unprocessed_items': parser.Parser.format_request_items(unprocessed_items) }