Best Python code snippet using localstack_python
provider.py
Source:provider.py
...1092 MotoMessage.update_binary_length_and_value(hash, decoded_binary_value)1093 # string_list_value, binary_list_value type is not implemented, reserved for the future use.1094 # See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_MessageAttributeValue.html1095 return hash.hexdigest()1096def get_queue_name_from_url(queue_url: str) -> str:1097 return queue_url.rstrip("/").split("/")[-1]1098def resolve_queue_key(1099 context: RequestContext, queue_name: Optional[str] = None, queue_url: Optional[str] = None1100) -> QueueKey:1101 """1102 Resolves a QueueKey from the given information.1103 :param context: the request context, used for getting region and account_id, and optionally the queue_url1104 :param queue_name: the queue name (if this is set, then this will be used for the key)1105 :param queue_url: the queue url (if name is not set, this will be used to determine the queue name)1106 :return: the QueueKey describing the queue being requested1107 """1108 if not queue_name:1109 if queue_url:1110 queue_name = get_queue_name_from_url(queue_url)1111 else:1112 queue_name = get_queue_name_from_url(context.request.base_url)...
SqsClient.py
Source:SqsClient.py
...126127 @staticmethod128 async def create_queue_url(queue_url):129 if not await SqsClient.queue_exists_url(queue_url):130 queue_name = SqsClient.get_queue_name_from_url(queue_url)131 response = await call_boto3_client_async('sqs', 'create_queue', {132 "QueueName": queue_name133 })134 return response['QueueUrl']135 else:136 return queue_url137138139 ####################140 ### Delete Queue ###141 ####################142143 @staticmethod144 async def delete_queue_url(queue_url):145 try:146 await call_boto3_client_async('sqs', 'delete_queue', {147 "QueueUrl": queue_url148 })149 except botocore.exceptions.ClientError as error:150 print('--> ERROR DELETING QUEUE', error)151 return None152153154 ###################155 ### Queue Facts ###156 ###################157158 @staticmethod159 async def get_queue_url(queue_name):160 try:161 response = await call_boto3_client_async('sqs', 'get_queue_url', {162 "QueueName": queue_name163 })164 return response["QueueUrl"]165 except botocore.exceptions.ClientError as error:166 print('--> ERROR', error)167 return None168169 @staticmethod170 async def get_queue_arn(queue_url):171 try:172 response = await call_boto3_client_async('sqs', 'get_queue_attributes', {173 "QueueUrl": queue_url,174 "AttributeNames": ["QueueArn"]175 })176 return response["Attributes"]["QueueArn"]177 except botocore.exceptions.ClientError as error:178 print('--> ERROR', error)179 return None180181182 ###############183 ### Helpers ###184 ###############185186 @staticmethod187 async def get_queue_name_from_url(queue_url):188 return queue_url.split("/")[-1]189
...
aws-lambda-helper-clean.py
Source:aws-lambda-helper-clean.py
...35 QueueNamePrefix="atd-vz-data-events-"36 )37 # Return our list38 return response.get("QueueUrls", [])39def get_queue_name_from_url(queue_url) -> str:40 """41 Returns a string with the name of the queue42 :param str queue_url:43 :return str:44 """45 return queue_url[41:]46def get_function_name_from_url(queue_url) -> str:47 """48 Returns a string with the name of the lambda function49 :param str queue_url:50 :return str:51 """52 return queue_url[41:]53def delete_queue(queue_url) -> dict:54 """55 Deletes an SQS queue by its URL56 :param str queue_url: The URL address of the SQS Queue57 :return dict:58 """59 return client.delete_queue(60 QueueUrl=queue_url61 )62def delete_function(function_name) -> dict:63 """64 Deletes an AWS Lambda function65 :param str function_name: The name of the function66 :return dict:67 """68 return client_lambda.delete_function(69 FunctionName=function_name70 )71#72# Main Function73#74def main():75 print(f"Current Branch: {BRANCH_NAME}")76 print(f"Current PR Num: {PR_NUMBER}")77 print("-----------------------------------------------------------------------------------------------------------")78 print("{:<10} {:<64} {:<64}".format("Remove?", "Queue Name", "Function Name"))79 print("-----------------------------------------------------------------------------------------------------------")80 queues = get_queue_list()81 for queue_url in queues:82 remove = is_removable(queue_url) and is_target_pr(queue_url, PR_NUMBER)83 queue_name = get_queue_name_from_url(queue_url)84 function_name = get_function_name_from_url(queue_url)85 print("{:<10} {:<64} {:<64}".format(str(remove), queue_name, function_name))86 if remove:87 print(f">> Removing SQS: '{queue_name}'")88 print(delete_queue(queue_url=queue_url))89 print(f">> Removing Function: '{function_name}'")90 print(delete_function(function_name=function_name))91 print("-----------------------------------------------------------------------------------------------------------")92if __name__ == "__main__":93 main()...
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!!