Best Python code snippet using localstack_python
provider.py
Source:provider.py
...58 return GetParameterResult(**result)59 except client.exceptions.ResourceNotFoundException:60 return None61 @staticmethod62 def _get_params_and_secrets(names: ParameterNameList) -> GetParametersResult:63 ssm_client = aws_stack.connect_to_service("ssm")64 result = {"Parameters": [], "InvalidParameters": []}65 for name in names:66 if name.startswith(PARAM_PREFIX_SECRETSMANAGER):67 secret = SsmProvider._get_secrets_information(68 name, name[len(PARAM_PREFIX_SECRETSMANAGER) + 1 :]69 )70 if secret is not None:71 secret = secret["Parameter"]72 result["Parameters"].append(secret)73 else:74 result["InvalidParameters"].append(name)75 else:76 try:77 param = ssm_client.get_parameter(Name=name)78 param["Parameter"]["LastModifiedDate"] = time.mktime(79 param["Parameter"]["LastModifiedDate"].timetuple()80 )81 result["Parameters"].append(param["Parameter"])82 except ssm_client.exceptions.ParameterNotFound:83 result["InvalidParameters"].append(name)84 return GetParametersResult(**result)85 @staticmethod86 def _notify_event_subscribers(name: ParameterName, operation: str):87 """Publish an EventBridge event to notify subscribers of changes."""88 if not is_api_enabled("events"):89 return90 events = aws_stack.connect_to_service("events")91 detail = {"name": name, "operation": operation}92 event = {93 "Source": "aws.ssm",94 "Detail": json.dumps(detail),95 "DetailType": "Parameter Store Change",96 }97 events.put_events(Entries=[event])98 def get_parameters(99 self,100 context: RequestContext,101 names: ParameterNameList,102 with_decryption: Boolean = None,103 ) -> GetParametersResult:104 if SsmProvider._has_secrets(names):105 return SsmProvider._get_params_and_secrets(names)106 names = list([SsmProvider._normalize_name(name) for name in names])107 request = {"Names": names, "WithDecryption": bool(with_decryption)}108 res = call_moto_with_request(context, request)109 return GetParametersResult(**res)110 def put_parameter(111 self, context: RequestContext, request: PutParameterRequest112 ) -> PutParameterResult:113 name = request["Name"]114 nname = SsmProvider._normalize_name(name)115 if name != nname:116 request.update({"Name": nname})117 moto_res = call_moto_with_request(context, request)118 else:119 moto_res = call_moto(context)...
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!!