How to use start_sync_execution method in localstack

Best Python code snippet using localstack_python

views.py

Source:views.py Github

copy

Full Screen

...21@api_view(['GET', 'POST', 'PUT'])22def mainMenu(request):23 if request.method == 'POST':24 sfn = boto3.client('stepfunctions', region_name='us-east-1')25 response = sfn.start_sync_execution(26 stateMachineArn=GET_MENU_LIST_ARN, name='getMenuItems', input='{}')27 data = json.loads(response['output'])28 data2 = data['Items']29 menu = dict()30 for i in data2:31 menu.update(32 {i['Item_Name']['S']: [i['price']['S'], i['type']['S']]})33 return JsonResponse(menu)34 if request.method == 'PUT':35 print(request.data)36 inputSfn = json.dumps(37 {"locationTag": request.data["locationTagNumber"], "name": request.data["name"]})38 sfn = boto3.client('stepfunctions', region_name='us-east-1')39 responseDelivered = sfn.start_sync_execution(40 stateMachineArn=MARK_AS_DELIVERED_ARN, name='receiveClientOrder', input=inputSfn) # Calculate price41 return JsonResponse({"msg": "Success", "orderStatus": json.loads(responseDelivered['output'])['msg']})42 else:43 return render(request, "mainMenu.html", {})44@api_view(['GET', 'POST'])45def checkup(request):46 if request.method == 'POST':47 try:48 inputSFN = request.data['itemsOrder']49 sfn = boto3.client('stepfunctions', region_name='us-east-1')50 responseOrderPrice = sfn.start_sync_execution(51 stateMachineArn=GET_ORDER_PRICE_ARN, name='getMenuItems', input=json.dumps(inputSFN)) # Calculate price52 price = json.loads(responseOrderPrice['output'])['body']53 return JsonResponse({"msg": "Success", "price": price})54 except:55 return JsonResponse({"msg": "Error"})56 else:57 return render(request, "mainMenu.html", {})58@api_view(['GET', 'POST', 'PUT'])59def checkout(request):60 if request.method == 'POST':61 try:62 # Treat data63 picture = request.data.dict()64 # Save foto in S365 s3 = boto3.resource('s3')66 object = s3.Object(S3_BUCKET, picture['image'].name)67 ret = object.put(Body=picture['image'])68 # Use Rekognition69 sfn = boto3.client('stepfunctions', region_name='us-east-1')70 responseCustomerName = sfn.start_sync_execution(71 stateMachineArn=GET_FACE_BY_PIC_ARN, name='validateFace', input=json.dumps({"name": picture['image'].name})) # Get name of customer72 if(json.loads(responseCustomerName['output'])['statusCode'] == 200):73 # Found client74 customerName = json.loads(75 responseCustomerName['output'])['success']76 return JsonResponse({"msg": "Success", "name": customerName})77 else:78 return JsonResponse({"msg": "Error! Please go to the customer support!"})79 except:80 return JsonResponse({"msg": "Error! Please go to the customer support!"})81 if request.method == 'PUT':82 print(request.data)83 # Treat data84 locationTagNumber = request.data['locationTagNumber']85 price = request.data['preco']86 orderList = request.data['pedido']87 customerName = request.data['customer']88 # Processes order of client89 sfn = boto3.client('stepfunctions', region_name='us-east-1')90 responseCustomerName = sfn.start_sync_execution(91 stateMachineArn=REGISTER_ORDER_ARN, name='processClientOrder', input=json.dumps(request.data)) # Register order for kitchen staff92 return JsonResponse({"msg": "Success", "name": customerName})93 else:...

Full Screen

Full Screen

mutations.py

Source:mutations.py Github

copy

Full Screen

...74 flow_table = dynamodb.Table("Flow")75 response = flow_table.get_item(Key={"id": id})76 object = response["Item"]77 # Execute the Step Function78 result = sfn.start_sync_execution(79 stateMachineArn=str(object["step_function_arn"]),80 input=json.dumps(input),81 )82 return FlowExecutionResult(83 input=input,84 output=result["output"],85 start_date=result["startDate"],86 end_date=result["stopDate"],87 status=FlowExecutionStatus(result["status"]),88 error_code=result["error"],89 error_message=result["cause"],...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful