How to use describe_scheduled_actions method in localstack

Best Python code snippet using localstack_python

aws_application_auto_scaling_info.py

Source:aws_application_auto_scaling_info.py Github

copy

Full Screen

...181 return paginator.paginate(182 ServiceNamespace=module.params['service_namespace'],183 ), True184 else:185 return client.describe_scheduled_actions(186 ServiceNamespace=module.params['service_namespace'],187 ), False188 else:189 return None, False190 except (BotoCoreError, ClientError) as e:191 module.fail_json_aws(e, msg='Failed to fetch aws application autoscaling details')192def main():193 argument_spec = dict(194 service_namespace=dict(required=True),195 describe_scalable_targets=dict(required=False, type=bool),196 describe_scaling_activities=dict(required=False, type=bool),197 describe_scaling_policies=dict(required=False, type=bool),198 describe_scheduled_actions=dict(required=False, type=bool),199 )...

Full Screen

Full Screen

ec2_asg_scheduled_action.py

Source:ec2_asg_scheduled_action.py Github

copy

Full Screen

...99 request['EndTime'] = module.params.get('end_time')100 return request101def delete_scheduled_action(client, module):102 changed = False103 actions = describe_scheduled_actions(client, module)104 if not "ScheduledUpdateGroupActions" in actions:105 return changed, actions106 xx = actions.get("ScheduledUpdateGroupActions")107 if len(xx) == 0:108 return changed, actions109 changed = True110 params = dict()111 params['AutoScalingGroupName'] = module.params.get('autoscaling_group_name')112 params['ScheduledActionName'] = module.params.get('scheduled_action_name')113 try:114 actions = client.delete_scheduled_action(**params)115 except botocore.exceptions.ClientError as e:116 module.fail_json(msg=str(e))117 return changed, actions118def describe_scheduled_actions(client, module):119 actions = dict()120 try:121 actions = client.describe_scheduled_actions(122 AutoScalingGroupName=module.params.get('autoscaling_group_name'),123 ScheduledActionNames=[module.params.get('scheduled_action_name')]124 )125 except botocore.exceptions.ClientError as e:126 pass127 return actions128def put_scheduled_update_group_action(client, module):129 changed = False130 params = format_request(module)131 exists = describe_scheduled_actions(client, module)132 xx = exists.get("ScheduledUpdateGroupActions")133 try:134 status = client.put_scheduled_update_group_action(**params)135 except botocore.exceptions.ClientError as e:136 module.fail_json(msg=str(e))137 if len(xx) == 0:138 changed = True139 else:140 xx = xx[0]141 exists = describe_scheduled_actions(client, module)142 yy = exists.get("ScheduledUpdateGroupActions")[0]143 if xx != yy:144 changed = True145 return changed, status146def main():147 argument_spec = ec2_argument_spec()148 argument_spec.update(dict(149 autoscaling_group_name=dict(default=None),150 scheduled_action_name=dict(default=None),151 start_time=dict(default=None),152 end_time=dict(default=None),153 recurrence=dict(default=None),154 min_size=dict(default=None, type='int'),155 max_size=dict(default=None, type='int'),...

Full Screen

Full Screen

test_autoscaling_scheduledactions.py

Source:test_autoscaling_scheduledactions.py Github

copy

Full Screen

...9 self.asg_name = "tester_group"10 def test_list_many_scheduled_scaling_actions(self):11 for i in range(30):12 self._create_scheduled_action(name=f"my-scheduled-action-{i}", idx=i)13 response = self.client.describe_scheduled_actions(14 AutoScalingGroupName=self.asg_name15 )16 actions = response["ScheduledUpdateGroupActions"]17 actions.should.have.length_of(30)18 def test_non_existing_group_name(self):19 self._create_scheduled_action(name="my-scheduled-action", idx=1)20 response = self.client.describe_scheduled_actions(21 AutoScalingGroupName="wrong_group"22 )23 actions = response["ScheduledUpdateGroupActions"]24 # since there is no such group name, no actions have been returned25 actions.should.have.length_of(0)26 def test_describe_scheduled_actions_returns_all_actions_when_no_argument_is_passed(27 self,28 ):29 for i in range(30):30 self._create_scheduled_action(name=f"my-scheduled-action-{i}", idx=i)31 for i in range(10):32 self._create_scheduled_action(33 name=f"my-scheduled-action-4{i}", idx=i, asg_name="test_group-2"34 )35 response = self.client.describe_scheduled_actions()36 actions = response["ScheduledUpdateGroupActions"]37 # Since no argument is passed describe_scheduled_actions, all scheduled actions are returned38 actions.should.have.length_of(40)39 def test_scheduled_action_delete(self):40 for i in range(3):41 self._create_scheduled_action(name=f"my-scheduled-action-{i}", idx=i)42 response = self.client.describe_scheduled_actions(43 AutoScalingGroupName=self.asg_name44 )45 actions = response["ScheduledUpdateGroupActions"]46 actions.should.have.length_of(3)47 self.client.delete_scheduled_action(48 AutoScalingGroupName=self.asg_name,49 ScheduledActionName="my-scheduled-action-2",50 )51 self.client.delete_scheduled_action(52 AutoScalingGroupName=self.asg_name,53 ScheduledActionName="my-scheduled-action-1",54 )55 response = self.client.describe_scheduled_actions(56 AutoScalingGroupName=self.asg_name57 )58 actions = response["ScheduledUpdateGroupActions"]59 actions.should.have.length_of(1)60 def _create_scheduled_action(self, name, idx, asg_name=None):61 self.client.put_scheduled_update_group_action(62 AutoScalingGroupName=asg_name or self.asg_name,63 ScheduledActionName=name,64 StartTime=f"2022-07-01T00:00:{idx}Z",65 EndTime=f"2022-09-01T00:00:{idx}Z",66 Recurrence="* * * * *",67 MinSize=idx + 1,68 MaxSize=idx + 5,69 DesiredCapacity=idx + 3,...

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