How to use list_rule_names_by_target method in localstack

Best Python code snippet using localstack_python

lambda-for-daylight-saving

Source:lambda-for-daylight-saving Github

copy

Full Screen

...3import logging4cld=boto3.client('events')5logger = logging.getLogger()6logger.setLevel(logging.INFO)7#res=cld.list_rule_names_by_target(TargetArn="arn:aws:lambda:ap-southeast-1:460697895779:function:toebsconversion")8def Change_Cron_Scheduler_For_DayLight(LambdaCronExp,Daylight_Saving):9 splitLambdaCronExp = LambdaCronExp.split(' ')10 if Daylight_Saving == "START":11 if splitLambdaCronExp[1].isdigit():12 splitLambdaCronExp[1] = str(int(splitLambdaCronExp[1]) + 1)13 elif Daylight_Saving == "END":14 if splitLambdaCronExp[1].isdigit():15 splitLambdaCronExp[1] = str(int(splitLambdaCronExp[1]) - 1)16 else:17 sys.exit()18 LambdaCronExp = str(splitLambdaCronExp)19 LambdaCronExp = LambdaCronExp.replace('[','')20 LambdaCronExp = LambdaCronExp.replace(']','')21 LambdaCronExp = LambdaCronExp.replace("'","")22 LambdaCronExp = LambdaCronExp.replace(',','')23 return LambdaCronExp24def manage_daylightsaving(event,context):25 awsaccount=event['account']26 for j in event['listoflambdafunction']:27 #lambdaarn="arn:aws:lambda:ap-southeast-1:460697895779:function:"+j28 lambdaarn='arn:aws:lambda:'+event['region']+':'+str(event['account'])+':function:'+j29 #res=cld.list_rule_names_by_target(TargetArn="arn:aws:lambda:ap-southeast-1:460697895779:function:toebsconversion")30 res=cld.list_rule_names_by_target(TargetArn=lambdaarn)31 for i in res['RuleNames']:32 res1=cld.describe_rule(Name=i)33 print res134 print str(res1['ScheduleExpression'].strip('cron').strip('('')')).split()35 logger.info('Previous schedule expression - '+ str(str(res1['ScheduleExpression'].strip('cron').strip('('')')).split()))36 LambdaCronExp=str(res1['ScheduleExpression'].strip('cron').strip('('')'))37 if event['daylightsaving'].upper() == 'START':38 #LambdaCronExp=str(res1['ScheduleExpression'].strip('cron').strip('('')'))39 Daylight_Saving="START"40 print Change_Cron_Scheduler_For_DayLight(LambdaCronExp,Daylight_Saving)41 print 'cron'+'('+Change_Cron_Scheduler_For_DayLight(LambdaCronExp,Daylight_Saving)+')'42 updatedcronexp='cron'+'('+Change_Cron_Scheduler_For_DayLight(LambdaCronExp,Daylight_Saving)+')'43 res2=cld.put_rule(Name=res1['Name'],ScheduleExpression=updatedcronexp,Description=res1['Description'])44 elif event['daylightsaving'].upper() == 'END':...

Full Screen

Full Screen

search_target_lambda_among_event_rules.py

Source:search_target_lambda_among_event_rules.py Github

copy

Full Screen

...14 keep_going = True15 token = ''16 while keep_going:17 if token:18 response = clientE.list_rule_names_by_target(TargetArn = target, NextToken = token)19 else:20 response = clientE.list_rule_names_by_target(TargetArn = target)21 if 'NextToken' in response and response['NextToken']:22 token = response['NextToken']23 else:24 keep_going = False25 if response['RuleNames']:26 print(response['RuleNames'])27 28for region in regions:29 try:30 action(region)31 except Exception as e:...

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