Best Python code snippet using localstack_python
helpers.py
Source:helpers.py  
...244    region_details.gateway_responses[api_id] = [245        r for r in responses if r["responseType"] != response_type246    ]247    return make_accepted_response()248def update_gateway_response(api_id, response_type, data):249    region_details = APIGatewayRegion.get()250    responses = region_details.gateway_responses.setdefault(api_id, [])251    existing = ([r for r in responses if r["responseType"] == response_type] or [None])[0]252    if existing is None:253        return make_error_response(254            "Gateway response %s for API Gateway %s not found" % (response_type, api_id),255            code=404,256        )257    result = apply_json_patch_safe(existing, data["patchOperations"])258    return result259def handle_gateway_responses(method, path, data, headers):260    search_match = re.search(PATH_REGEX_RESPONSES, path)261    api_id = search_match.group(1)262    response_type = (search_match.group(2) or "").lstrip("/")263    if method == "GET":264        if response_type:265            return get_gateway_response(api_id, response_type)266        return get_gateway_responses(api_id)267    if method == "PUT":268        return put_gateway_response(api_id, response_type, data)269    if method == "PATCH":270        return update_gateway_response(api_id, response_type, data)271    if method == "DELETE":272        return delete_gateway_response(api_id, response_type)273    return make_error_response(274        "Not implemented for API Gateway gateway responses: %s" % method, code=404275    )276# ---------------277# UTIL FUNCTIONS278# ---------------279def find_api_subentity_by_id(api_id, entity_id, map_name):280    region_details = APIGatewayRegion.get()281    auth_list = getattr(region_details, map_name).get(api_id) or []282    entity = ([a for a in auth_list if a["id"] == entity_id] or [None])[0]283    return entity284def path_based_url(api_id, stage_name, path):...client.py
Source:client.py  
...228    def update_documentation_version(self, restApiId: str, documentationVersion: str, patchOperations: List = None) -> Dict:229        pass230    def update_domain_name(self, domainName: str, patchOperations: List = None) -> Dict:231        pass232    def update_gateway_response(self, restApiId: str, responseType: str, patchOperations: List = None) -> Dict:233        pass234    def update_integration(self, restApiId: str, resourceId: str, httpMethod: str, patchOperations: List = None) -> Dict:235        pass236    def update_integration_response(self, restApiId: str, resourceId: str, httpMethod: str, statusCode: str, patchOperations: List = None) -> Dict:237        pass238    def update_method(self, restApiId: str, resourceId: str, httpMethod: str, patchOperations: List = None) -> Dict:239        pass240    def update_method_response(self, restApiId: str, resourceId: str, httpMethod: str, statusCode: str, patchOperations: List = None) -> Dict:241        pass242    def update_model(self, restApiId: str, modelName: str, patchOperations: List = None) -> Dict:243        pass244    def update_request_validator(self, restApiId: str, requestValidatorId: str, patchOperations: List = None) -> Dict:245        pass246    def update_resource(self, restApiId: str, resourceId: str, patchOperations: List = None) -> Dict:...ApiTask.py
Source:ApiTask.py  
...30    if 'cors' in self.params:31      errResponse4 = client.get_gateway_response(restApiId=api['id'], responseType='DEFAULT_4XX')32      errResponse5 = client.get_gateway_response(restApiId=api['id'], responseType='DEFAULT_5XX')33      if self.params['cors'] == True:34        client.update_gateway_response(restApiId=api['id'], responseType='DEFAULT_4XX', patchOperations=[{'op': 'add', 'path': '/responseParameters/gatewayresponse.header.Access-Control-Allow-Origin', 'value': "'*'"}])35        client.update_gateway_response(restApiId=api['id'], responseType='DEFAULT_5XX', patchOperations=[{'op': 'add', 'path': '/responseParameters/gatewayresponse.header.Access-Control-Allow-Origin', 'value': "'*'"}])36        result = self.CHANGED      37      elif self.params['cors'] == False:38        client.update_gateway_response(restApiId=api['id'], responseType='DEFAULT_4XX', patchOperations=[{'op': 'remove', 'path': '/responseParameters/gatewayresponse.header.Access-Control-Allow-Origin'}])39        client.update_gateway_response(restApiId=api['id'], responseType='DEFAULT_5XX', patchOperations=[{'op': 'remove', 'path': '/responseParameters/gatewayresponse.header.Access-Control-Allow-Origin'}])40        result = self.CHANGED        41    cache.put('api', api['name'], api['id'])...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!!
