Best Python code snippet using localstack_python
dynamodbstreams_api.py
Source:dynamodbstreams_api.py
...61 if not result:62 return error_response('Requested resource not found', error_type='ResourceNotFoundException')63 elif action == '%s.GetShardIterator' % ACTION_HEADER_PREFIX:64 # forward request to Kinesis API65 stream_name = stream_name_from_stream_arn(data['StreamArn'])66 result = kinesis.get_shard_iterator(StreamName=stream_name,67 ShardId=data['ShardId'], ShardIteratorType=data['ShardIteratorType'])68 elif action == '%s.GetRecords' % ACTION_HEADER_PREFIX:69 kinesis_records = kinesis.get_records(**data)70 result = {'Records': []}71 for record in kinesis_records['Records']:72 result['Records'].append(json.loads(to_str(record['Data'])))73 else:74 print('WARNING: Unknown operation "%s"' % action)75 return jsonify(result)76# -----------------77# HELPER FUNCTIONS78# -----------------79def error_response(message=None, error_type=None, code=400):80 if not message:81 message = 'Unknown error'82 if not error_type:83 error_type = 'UnknownError'84 if 'com.amazonaws.dynamodb' not in error_type:85 error_type = 'com.amazonaws.dynamodb.v20120810#%s' % error_type86 content = {87 'message': message,88 '__type': error_type89 }90 return make_response(jsonify(content), code)91def get_kinesis_stream_name(table_name):92 return DDB_KINESIS_STREAM_NAME_PREFIX + table_name93def table_name_from_stream_arn(stream_arn):94 return stream_arn.split(':table/')[1].split('/')[0]95def stream_name_from_stream_arn(stream_arn):96 table_name = table_name_from_stream_arn(stream_arn)97 return get_kinesis_stream_name(table_name)98def serve(port, quiet=True):...
34079_dynamodbstreams_api.py
Source:34079_dynamodbstreams_api.py
...61 if not result:62 return error_response('Requested resource not found', error_type='ResourceNotFoundException')63 elif action == '%s.GetShardIterator' % ACTION_HEADER_PREFIX:64 # forward request to Kinesis API65 stream_name = stream_name_from_stream_arn(data['StreamArn'])66 result = kinesis.get_shard_iterator(StreamName=stream_name,67 ShardId=data['ShardId'], ShardIteratorType=data['ShardIteratorType'])68 elif action == '%s.GetRecords' % ACTION_HEADER_PREFIX:69 kinesis_records = kinesis.get_records(**data)70 result = {'Records': []}71 for record in kinesis_records['Records']:72 result['Records'].append(json.loads(to_str(record['Data'])))73 else:74 print('WARNING: Unknown operation "%s"' % action)75 return jsonify(result)76# -----------------77# HELPER FUNCTIONS78# -----------------79def error_response(message=None, error_type=None, code=400):80 if not message:81 message = 'Unknown error'82 if not error_type:83 error_type = 'UnknownError'84 if 'com.amazonaws.dynamodb' not in error_type:85 error_type = 'com.amazonaws.dynamodb.v20120810#%s' % error_type86 content = {87 'message': message,88 '__type': error_type89 }90 return make_response(jsonify(content), code)91def get_kinesis_stream_name(table_name):92 return DDB_KINESIS_STREAM_NAME_PREFIX + table_name93def table_name_from_stream_arn(stream_arn):94 return stream_arn.split(':table/')[1].split('/')[0]95def stream_name_from_stream_arn(stream_arn):96 table_name = table_name_from_stream_arn(stream_arn)97 return get_kinesis_stream_name(table_name)98def serve(port, quiet=True):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!