Best Python code snippet using localstack_python
__init__.pyi
Source:__init__.pyi
1"""2Main interface for ssm service.3Usage::4 ```python5 import boto36 from mypy_boto3_ssm import (7 Client,8 CommandExecutedWaiter,9 DescribeActivationsPaginator,10 DescribeAssociationExecutionTargetsPaginator,11 DescribeAssociationExecutionsPaginator,12 DescribeAutomationExecutionsPaginator,13 DescribeAutomationStepExecutionsPaginator,14 DescribeAvailablePatchesPaginator,15 DescribeEffectiveInstanceAssociationsPaginator,16 DescribeEffectivePatchesForPatchBaselinePaginator,17 DescribeInstanceAssociationsStatusPaginator,18 DescribeInstanceInformationPaginator,19 DescribeInstancePatchStatesForPatchGroupPaginator,20 DescribeInstancePatchStatesPaginator,21 DescribeInstancePatchesPaginator,22 DescribeInventoryDeletionsPaginator,23 DescribeMaintenanceWindowExecutionTaskInvocationsPaginator,24 DescribeMaintenanceWindowExecutionTasksPaginator,25 DescribeMaintenanceWindowExecutionsPaginator,26 DescribeMaintenanceWindowSchedulePaginator,27 DescribeMaintenanceWindowTargetsPaginator,28 DescribeMaintenanceWindowTasksPaginator,29 DescribeMaintenanceWindowsForTargetPaginator,30 DescribeMaintenanceWindowsPaginator,31 DescribeOpsItemsPaginator,32 DescribeParametersPaginator,33 DescribePatchBaselinesPaginator,34 DescribePatchGroupsPaginator,35 DescribePatchPropertiesPaginator,36 DescribeSessionsPaginator,37 GetInventoryPaginator,38 GetInventorySchemaPaginator,39 GetOpsSummaryPaginator,40 GetParameterHistoryPaginator,41 GetParametersByPathPaginator,42 ListAssociationVersionsPaginator,43 ListAssociationsPaginator,44 ListCommandInvocationsPaginator,45 ListCommandsPaginator,46 ListComplianceItemsPaginator,47 ListComplianceSummariesPaginator,48 ListDocumentVersionsPaginator,49 ListDocumentsPaginator,50 ListOpsItemEventsPaginator,51 ListOpsItemRelatedItemsPaginator,52 ListOpsMetadataPaginator,53 ListResourceComplianceSummariesPaginator,54 ListResourceDataSyncPaginator,55 SSMClient,56 )57 session = boto3.Session()58 client: SSMClient = boto3.client("ssm")59 session_client: SSMClient = session.client("ssm")60 command_executed_waiter: CommandExecutedWaiter = client.get_waiter("command_executed")61 describe_activations_paginator: DescribeActivationsPaginator = client.get_paginator("describe_activations")62 describe_association_execution_targets_paginator: DescribeAssociationExecutionTargetsPaginator = client.get_paginator("describe_association_execution_targets")63 describe_association_executions_paginator: DescribeAssociationExecutionsPaginator = client.get_paginator("describe_association_executions")64 describe_automation_executions_paginator: DescribeAutomationExecutionsPaginator = client.get_paginator("describe_automation_executions")65 describe_automation_step_executions_paginator: DescribeAutomationStepExecutionsPaginator = client.get_paginator("describe_automation_step_executions")66 describe_available_patches_paginator: DescribeAvailablePatchesPaginator = client.get_paginator("describe_available_patches")67 describe_effective_instance_associations_paginator: DescribeEffectiveInstanceAssociationsPaginator = client.get_paginator("describe_effective_instance_associations")68 describe_effective_patches_for_patch_baseline_paginator: DescribeEffectivePatchesForPatchBaselinePaginator = client.get_paginator("describe_effective_patches_for_patch_baseline")69 describe_instance_associations_status_paginator: DescribeInstanceAssociationsStatusPaginator = client.get_paginator("describe_instance_associations_status")70 describe_instance_information_paginator: DescribeInstanceInformationPaginator = client.get_paginator("describe_instance_information")71 describe_instance_patch_states_paginator: DescribeInstancePatchStatesPaginator = client.get_paginator("describe_instance_patch_states")72 describe_instance_patch_states_for_patch_group_paginator: DescribeInstancePatchStatesForPatchGroupPaginator = client.get_paginator("describe_instance_patch_states_for_patch_group")73 describe_instance_patches_paginator: DescribeInstancePatchesPaginator = client.get_paginator("describe_instance_patches")74 describe_inventory_deletions_paginator: DescribeInventoryDeletionsPaginator = client.get_paginator("describe_inventory_deletions")75 describe_maintenance_window_execution_task_invocations_paginator: DescribeMaintenanceWindowExecutionTaskInvocationsPaginator = client.get_paginator("describe_maintenance_window_execution_task_invocations")76 describe_maintenance_window_execution_tasks_paginator: DescribeMaintenanceWindowExecutionTasksPaginator = client.get_paginator("describe_maintenance_window_execution_tasks")77 describe_maintenance_window_executions_paginator: DescribeMaintenanceWindowExecutionsPaginator = client.get_paginator("describe_maintenance_window_executions")78 describe_maintenance_window_schedule_paginator: DescribeMaintenanceWindowSchedulePaginator = client.get_paginator("describe_maintenance_window_schedule")79 describe_maintenance_window_targets_paginator: DescribeMaintenanceWindowTargetsPaginator = client.get_paginator("describe_maintenance_window_targets")80 describe_maintenance_window_tasks_paginator: DescribeMaintenanceWindowTasksPaginator = client.get_paginator("describe_maintenance_window_tasks")81 describe_maintenance_windows_paginator: DescribeMaintenanceWindowsPaginator = client.get_paginator("describe_maintenance_windows")82 describe_maintenance_windows_for_target_paginator: DescribeMaintenanceWindowsForTargetPaginator = client.get_paginator("describe_maintenance_windows_for_target")83 describe_ops_items_paginator: DescribeOpsItemsPaginator = client.get_paginator("describe_ops_items")84 describe_parameters_paginator: DescribeParametersPaginator = client.get_paginator("describe_parameters")85 describe_patch_baselines_paginator: DescribePatchBaselinesPaginator = client.get_paginator("describe_patch_baselines")86 describe_patch_groups_paginator: DescribePatchGroupsPaginator = client.get_paginator("describe_patch_groups")87 describe_patch_properties_paginator: DescribePatchPropertiesPaginator = client.get_paginator("describe_patch_properties")88 describe_sessions_paginator: DescribeSessionsPaginator = client.get_paginator("describe_sessions")89 get_inventory_paginator: GetInventoryPaginator = client.get_paginator("get_inventory")90 get_inventory_schema_paginator: GetInventorySchemaPaginator = client.get_paginator("get_inventory_schema")91 get_ops_summary_paginator: GetOpsSummaryPaginator = client.get_paginator("get_ops_summary")92 get_parameter_history_paginator: GetParameterHistoryPaginator = client.get_paginator("get_parameter_history")93 get_parameters_by_path_paginator: GetParametersByPathPaginator = client.get_paginator("get_parameters_by_path")94 list_association_versions_paginator: ListAssociationVersionsPaginator = client.get_paginator("list_association_versions")95 list_associations_paginator: ListAssociationsPaginator = client.get_paginator("list_associations")96 list_command_invocations_paginator: ListCommandInvocationsPaginator = client.get_paginator("list_command_invocations")97 list_commands_paginator: ListCommandsPaginator = client.get_paginator("list_commands")98 list_compliance_items_paginator: ListComplianceItemsPaginator = client.get_paginator("list_compliance_items")99 list_compliance_summaries_paginator: ListComplianceSummariesPaginator = client.get_paginator("list_compliance_summaries")100 list_document_versions_paginator: ListDocumentVersionsPaginator = client.get_paginator("list_document_versions")101 list_documents_paginator: ListDocumentsPaginator = client.get_paginator("list_documents")102 list_ops_item_events_paginator: ListOpsItemEventsPaginator = client.get_paginator("list_ops_item_events")103 list_ops_item_related_items_paginator: ListOpsItemRelatedItemsPaginator = client.get_paginator("list_ops_item_related_items")104 list_ops_metadata_paginator: ListOpsMetadataPaginator = client.get_paginator("list_ops_metadata")105 list_resource_compliance_summaries_paginator: ListResourceComplianceSummariesPaginator = client.get_paginator("list_resource_compliance_summaries")106 list_resource_data_sync_paginator: ListResourceDataSyncPaginator = client.get_paginator("list_resource_data_sync")107 ```108"""109from .client import SSMClient110from .paginator import (111 DescribeActivationsPaginator,112 DescribeAssociationExecutionsPaginator,113 DescribeAssociationExecutionTargetsPaginator,114 DescribeAutomationExecutionsPaginator,115 DescribeAutomationStepExecutionsPaginator,116 DescribeAvailablePatchesPaginator,117 DescribeEffectiveInstanceAssociationsPaginator,118 DescribeEffectivePatchesForPatchBaselinePaginator,119 DescribeInstanceAssociationsStatusPaginator,120 DescribeInstanceInformationPaginator,121 DescribeInstancePatchesPaginator,122 DescribeInstancePatchStatesForPatchGroupPaginator,123 DescribeInstancePatchStatesPaginator,124 DescribeInventoryDeletionsPaginator,125 DescribeMaintenanceWindowExecutionsPaginator,126 DescribeMaintenanceWindowExecutionTaskInvocationsPaginator,127 DescribeMaintenanceWindowExecutionTasksPaginator,128 DescribeMaintenanceWindowSchedulePaginator,129 DescribeMaintenanceWindowsForTargetPaginator,130 DescribeMaintenanceWindowsPaginator,131 DescribeMaintenanceWindowTargetsPaginator,132 DescribeMaintenanceWindowTasksPaginator,133 DescribeOpsItemsPaginator,134 DescribeParametersPaginator,135 DescribePatchBaselinesPaginator,136 DescribePatchGroupsPaginator,137 DescribePatchPropertiesPaginator,138 DescribeSessionsPaginator,139 GetInventoryPaginator,140 GetInventorySchemaPaginator,141 GetOpsSummaryPaginator,142 GetParameterHistoryPaginator,143 GetParametersByPathPaginator,144 ListAssociationsPaginator,145 ListAssociationVersionsPaginator,146 ListCommandInvocationsPaginator,147 ListCommandsPaginator,148 ListComplianceItemsPaginator,149 ListComplianceSummariesPaginator,150 ListDocumentsPaginator,151 ListDocumentVersionsPaginator,152 ListOpsItemEventsPaginator,153 ListOpsItemRelatedItemsPaginator,154 ListOpsMetadataPaginator,155 ListResourceComplianceSummariesPaginator,156 ListResourceDataSyncPaginator,157)158from .waiter import CommandExecutedWaiter159Client = SSMClient160__all__ = (161 "Client",162 "CommandExecutedWaiter",163 "DescribeActivationsPaginator",164 "DescribeAssociationExecutionTargetsPaginator",165 "DescribeAssociationExecutionsPaginator",166 "DescribeAutomationExecutionsPaginator",167 "DescribeAutomationStepExecutionsPaginator",168 "DescribeAvailablePatchesPaginator",169 "DescribeEffectiveInstanceAssociationsPaginator",170 "DescribeEffectivePatchesForPatchBaselinePaginator",171 "DescribeInstanceAssociationsStatusPaginator",172 "DescribeInstanceInformationPaginator",173 "DescribeInstancePatchStatesForPatchGroupPaginator",174 "DescribeInstancePatchStatesPaginator",175 "DescribeInstancePatchesPaginator",176 "DescribeInventoryDeletionsPaginator",177 "DescribeMaintenanceWindowExecutionTaskInvocationsPaginator",178 "DescribeMaintenanceWindowExecutionTasksPaginator",179 "DescribeMaintenanceWindowExecutionsPaginator",180 "DescribeMaintenanceWindowSchedulePaginator",181 "DescribeMaintenanceWindowTargetsPaginator",182 "DescribeMaintenanceWindowTasksPaginator",183 "DescribeMaintenanceWindowsForTargetPaginator",184 "DescribeMaintenanceWindowsPaginator",185 "DescribeOpsItemsPaginator",186 "DescribeParametersPaginator",187 "DescribePatchBaselinesPaginator",188 "DescribePatchGroupsPaginator",189 "DescribePatchPropertiesPaginator",190 "DescribeSessionsPaginator",191 "GetInventoryPaginator",192 "GetInventorySchemaPaginator",193 "GetOpsSummaryPaginator",194 "GetParameterHistoryPaginator",195 "GetParametersByPathPaginator",196 "ListAssociationVersionsPaginator",197 "ListAssociationsPaginator",198 "ListCommandInvocationsPaginator",199 "ListCommandsPaginator",200 "ListComplianceItemsPaginator",201 "ListComplianceSummariesPaginator",202 "ListDocumentVersionsPaginator",203 "ListDocumentsPaginator",204 "ListOpsItemEventsPaginator",205 "ListOpsItemRelatedItemsPaginator",206 "ListOpsMetadataPaginator",207 "ListResourceComplianceSummariesPaginator",208 "ListResourceDataSyncPaginator",209 "SSMClient",...
rootmail_test.py
Source:rootmail_test.py
...41 return res42 @classmethod43 @retry(wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_delay=20000)44 def get_ops_item_by_title(cls, title):45 res = ssm.get_ops_summary(46 Filters=[47 {48 'Key': 'AWS:OpsItem.Title',49 'Values': [50 title,51 ],52 'Type': 'Equal',53 },54 {55 'Key': 'AWS:OpsItem.Status',56 'Values': [57 'Open',58 ],59 'Type': 'Equal',60 },61 ],62 )63 if len(res['Entities']) == 0:64 raise # mail has probably not arrived yet65 return res66 def test_root_email_body_text(self):67 id = uuid.uuid4().hex68 self.send_email(id, 'This is a mail body')69 res = self.get_ops_item_by_title(id)70 self.assertEqual(1, len(res['Entities']))71 id = res['Entities'][0]['Id']72 description = res['Entities'][0]['Data']['AWS:OpsItem']['Content'][0]['Description']73 self.assertEqual('This is a mail body', description.rstrip())74 ssm.update_ops_item(75 OpsItemId=id,76 Status='Resolved',77 )78 def test_root_email_body_text_and_html(self):79 id = uuid.uuid4().hex80 self.send_email(id, 'This is another mail body', "<h1>This should be ignored</h1>")81 res = self.get_ops_item_by_title(id)82 self.assertEqual(1, len(res['Entities']))83 id = res['Entities'][0]['Id']84 description = res['Entities'][0]['Data']['AWS:OpsItem']['Content'][0]['Description']85 self.assertEqual('This is another mail body', description.rstrip())86 ssm.update_ops_item(87 OpsItemId=id,88 Status='Resolved',89 )90 def test_root_email_body_html(self):91 id = uuid.uuid4().hex92 self.send_email(id, None, "<script>alert('Hi!')</script><h1>Hello</h1>")93 res = self.get_ops_item_by_title(id)94 self.assertEqual(1, len(res['Entities']))95 id = res['Entities'][0]['Id']96 description = res['Entities'][0]['Data']['AWS:OpsItem']['Content'][0]['Description']97 self.assertEqual("<script>alert('Hi!')</script><h1>Hello</h1>", description.rstrip())98 ssm.update_ops_item(99 OpsItemId=id,100 Status='Resolved',101 )102 def test_root_email_virus(self):103 EICAR='X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'104 id = uuid.uuid4().hex105 self.send_email(id, EICAR)106 res = self.wait_for_get_ops_summary(107 Filters=[108 {109 'Key': 'AWS:OpsItem.Title',110 'Values': [111 id,112 ],113 'Type': 'Equal',114 },115 {116 'Key': 'AWS:OpsItem.Status',117 'Values': [118 'Open',119 ],120 'Type': 'Equal',121 },122 ],123 )124 self.assertEqual(0, len(res['Entities']))125 def test_welcome_mail_get_filtered(self):126 id = uuid.uuid4().hex127 subject = 'Welcome to Amazon Web Services'128 self.send_email(id=id, subject=subject, body_text='some mail body')129 res = self.wait_for_get_ops_summary(130 Filters=[131 {132 'Key': 'AWS:OpsItem.Title',133 'Values': [134 subject,135 ],136 'Type': 'Equal',137 },138 {139 'Key': 'AWS:OpsItem.Status',140 'Values': [141 'Open',142 ],143 'Type': 'Equal',144 },145 ],146 )147 self.assertEqual(0, len(res['Entities']))148 def test_account_ready_mail_get_filtered(self):149 id = uuid.uuid4().hex150 subject = 'Your AWS Account is Ready - Get Started Now'151 self.send_email(id=id, subject=subject, body_text='some mail body')152 res = self.wait_for_get_ops_summary(153 Filters=[154 {155 'Key': 'AWS:OpsItem.Title',156 'Values': [157 subject,158 ],159 'Type': 'Equal',160 },161 {162 'Key': 'AWS:OpsItem.Status',163 'Values': [164 'Open',165 ],166 'Type': 'Equal',167 },168 ],169 )170 self.assertEqual(0, len(res['Entities']))171 @retry(wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_delay=20000)172 def wait_for_get_ops_summary(self, **kwargs):...
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!!