How to use put_compliance_items method in localstack

Best Python code snippet using localstack_python

client.py

Source:client.py Github

copy

Full Screen

...188 def list_tags_for_resource(self, ResourceType: str, ResourceId: str) -> Dict:189 pass190 def modify_document_permission(self, Name: str, PermissionType: str, AccountIdsToAdd: List = None, AccountIdsToRemove: List = None) -> Dict:191 pass192 def put_compliance_items(self, ResourceId: str, ResourceType: str, ComplianceType: str, ExecutionSummary: Dict, Items: List, ItemContentHash: str = None) -> Dict:193 pass194 def put_inventory(self, InstanceId: str, Items: List) -> Dict:195 pass196 def put_parameter(self, Name: str, Value: str, Type: str, Description: str = None, KeyId: str = None, Overwrite: bool = None, AllowedPattern: str = None, Tags: List = None, Tier: str = None, Policies: str = None) -> Dict:197 pass198 def register_default_patch_baseline(self, BaselineId: str) -> Dict:199 pass200 def register_patch_baseline_for_patch_group(self, BaselineId: str, PatchGroup: str) -> Dict:201 pass202 def register_target_with_maintenance_window(self, WindowId: str, ResourceType: str, Targets: List, OwnerInformation: str = None, Name: str = None, Description: str = None, ClientToken: str = None) -> Dict:203 pass204 def register_task_with_maintenance_window(self, WindowId: str, Targets: List, TaskArn: str, TaskType: str, MaxConcurrency: str, MaxErrors: str, ServiceRoleArn: str = None, TaskParameters: Dict = None, TaskInvocationParameters: Dict = None, Priority: int = None, LoggingInfo: Dict = None, Name: str = None, Description: str = None, ClientToken: str = None) -> Dict:205 pass206 def remove_tags_from_resource(self, ResourceType: str, ResourceId: str, TagKeys: List) -> Dict:...

Full Screen

Full Screen

compliance_uploader.py

Source:compliance_uploader.py Github

copy

Full Screen

...35 default_ssm_client = client_selector.get_default_client(instance_id, region)36 items = []37 if "Items" in compliance:38 items = compliance["Items"]39 default_ssm_client.put_compliance_items(40 ResourceId=compliance["ResourceId"],41 ResourceType=compliance["ResourceType"],42 ComplianceType=compliance["ComplianceType"],43 ExecutionSummary=compliance["ExecutionSummary"],44 Items=items,45 UploadType="PARTIAL",46 ItemContentHash=compliance["ItemContentHash"]47 )48 logger.info("Upload complete.")49 success = True50 _persist_inventory_hash(compliance)51 except (ClientError, PatchManagerError) as e:52 # Only worry about a specific service error code53 # TODO - check these Exception types with put compliance.54 if isinstance(e, ClientError) and e.response["Error"]["Code"] in ["InvalidItemContentException", "ItemContentMismatchException"]:55 logger.warn("Hash mismatch on upload, retry", exc_info=True)56 clobber = True57 elif not client_selector.is_managed_instance(instance_id):58 _upload_report_with_fallback_client(region, instance_id, compliance)59 return60 else:61 raise PatchManagerError("Unable to upload the inventory:", ExitCodes.PUT_INVENTORY_ERROR, e)62 except Exception as e:63 raise PatchManagerError("Encounter service side error when uploading the inventory", ExitCodes.PUT_INVENTORY_ERROR, e)64 if not success:65 raise PatchManagerError("Could not upload inventory report after retries.", ExitCodes.PUT_INVENTORY_ERROR)66def _upload_report_with_fallback_client(region,67 instance_id,68 compliance):69 """70 Upload an inventory report using fallback ssm client71 :param instance_id: for the items72 :param summary_item: to be uploaded with put_inventory73 :param compliance_item: to be uploaded with put_inventory, empty if hash has not changed74 """75 fallback_ssm_client = client_selector.get_fallback_client(region)76 try:77 items = []78 if "Items" in compliance:79 items = compliance["Items"]80 fallback_ssm_client.put_compliance_items(81 ResourceId=compliance["ResourceId"],82 ResourceType=compliance["ResourceType"],83 ComplianceType=compliance["ComplianceType"],84 ExecutionSummary=compliance["ExecutionSummary"],85 Items=items,86 ItemContentHash=compliance["ItemContentHash"]87 )88 logger.info("Upload complete.")89 _persist_inventory_hash(compliance)90 except Exception as e:91 # TODO - check these errors.92 raise PatchManagerError("Unable to upload the inventory using fallback creds:", ExitCodes.PUT_INVENTORY_ERROR, e)93def _persist_inventory_hash(item):94 """...

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