Best Python code snippet using localstack_python
generic_proxy.py
Source:generic_proxy.py  
...129    REGIONS: Dict[str, "RegionBackend"]130    @classmethod131    def get(cls, region=None):132        regions = cls.regions()133        region = region or cls.get_current_request_region()134        regions[region] = regions.get(region) or cls()135        return regions[region]136    @classmethod137    def regions(cls) -> Dict[str, "RegionBackend"]:138        if not hasattr(cls, "REGIONS"):139            # maps region name to region backend instance140            cls.REGIONS = {}141        return cls.REGIONS142    @classmethod143    def get_current_request_region(cls):144        return aws_stack.get_region()145    @classmethod146    def reset(cls):147        """Reset the (in-memory) state of this service region backend."""148        # for now, simply reset the regions and discard all existing region instances149        cls.REGIONS = {}150        return cls.regions()151# ---------------------152# PROXY LISTENER UTILS153# ---------------------154def append_cors_headers(request_headers=None, response=None):155    # Note: Use "response is not None" here instead of "not response"!156    headers = {} if response is None else response.headers157    # In case we have LambdaResponse copy multivalue headers to regular headers, since...kms_listener.py
Source:kms_listener.py  
...220    cipher_text_blob = None221    if create_cipher:222        cipher_text = kms.encrypt(KeyId=key_id, Plaintext=private_key)["CiphertextBlob"]223        cipher_text_blob = base64.b64encode(cipher_text)224    region = region_details.get_current_request_region()225    result = {226        "PrivateKeyCiphertextBlob": cipher_text_blob,227        "PrivateKeyPlaintext": base64.b64encode(private_key),228        "PublicKey": base64.b64encode(public_key),229        "KeyId": key_id,230        "KeyPairSpec": key_spec,231        "KeySpec": key_spec,232        "KeyUsage": "SIGN_VERIFY",233        "Policy": data.get("Policy"),234        "Region": region,235        "Description": data.get("Description"),236        "Arn": aws_stack.kms_key_arn(key_id),237        "_key_": key,238    }...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!!
