How to use delete_saml_provider method in localstack

Best Python code snippet using localstack_python

iam_saml_federation.py

Source:iam_saml_federation.py Github

copy

Full Screen

...127 @AWSRetry.backoff(tries=3, delay=5)128 def _create_saml_provider(self, metadata, name):129 return self.conn.create_saml_provider(SAMLMetadataDocument=metadata, Name=name)130 @AWSRetry.backoff(tries=3, delay=5)131 def _delete_saml_provider(self, arn):132 return self.conn.delete_saml_provider(SAMLProviderArn=arn)133 def _get_provider_arn(self, name):134 providers = self._list_saml_providers()135 for p in providers['SAMLProviderList']:136 provider_name = p['Arn'].split('/', 1)[1]137 if name == provider_name:138 return p['Arn']139 return None140 def create_or_update_saml_provider(self, name, metadata):141 if not metadata:142 self.module.fail_json(msg="saml_metadata_document must be defined for present state")143 res = {'changed': False}144 try:145 arn = self._get_provider_arn(name)146 except (botocore.exceptions.ValidationError, botocore.exceptions.ClientError) as e:147 self.module.fail_json_aws(e, msg="Could not get the ARN of the identity provider '{0}'".format(name))148 if arn: # see if metadata needs updating149 try:150 resp = self._get_saml_provider(arn)151 except (botocore.exceptions.ValidationError, botocore.exceptions.ClientError) as e:152 self.module.fail_json_aws(e, msg="Could not retrieve the identity provider '{0}'".format(name))153 if metadata.strip() != resp['SAMLMetadataDocument'].strip():154 # provider needs updating155 res['changed'] = True156 if not self.module.check_mode:157 try:158 resp = self._update_saml_provider(arn, metadata)159 res['saml_provider'] = self._build_res(resp['SAMLProviderArn'])160 except botocore.exceptions.ClientError as e:161 self.module.fail_json_aws(e, msg="Could not update the identity provider '{0}'".format(name))162 else: # create163 res['changed'] = True164 if not self.module.check_mode:165 try:166 resp = self._create_saml_provider(metadata, name)167 res['saml_provider'] = self._build_res(resp['SAMLProviderArn'])168 except botocore.exceptions.ClientError as e:169 self.module.fail_json_aws(e, msg="Could not create the identity provider '{0}'".format(name))170 self.module.exit_json(**res)171 def delete_saml_provider(self, name):172 res = {'changed': False}173 try:174 arn = self._get_provider_arn(name)175 except (botocore.exceptions.ValidationError, botocore.exceptions.ClientError) as e:176 self.module.fail_json_aws(e, msg="Could not get the ARN of the identity provider '{0}'".format(name))177 if arn: # delete178 res['changed'] = True179 if not self.module.check_mode:180 try:181 self._delete_saml_provider(arn)182 except botocore.exceptions.ClientError as e:183 self.module.fail_json_aws(e, msg="Could not delete the identity provider '{0}'".format(name))184 self.module.exit_json(**res)185 def _build_res(self, arn):186 saml_provider = self._get_saml_provider(arn)187 return {188 "arn": arn,189 "metadata_document": saml_provider["SAMLMetadataDocument"],190 "create_date": saml_provider["CreateDate"].isoformat(),191 "expire_date": saml_provider["ValidUntil"].isoformat()192 }193def main():194 argument_spec = dict(195 name=dict(required=True),196 saml_metadata_document=dict(default=None, required=False),197 state=dict(default='present', required=False, choices=['present', 'absent']),198 )199 module = AnsibleAWSModule(200 argument_spec=argument_spec,201 supports_check_mode=True,202 required_if=[('state', 'present', ['saml_metadata_document'])]203 )204 name = module.params['name']205 state = module.params.get('state')206 saml_metadata_document = module.params.get('saml_metadata_document')207 sp_man = SAMLProviderManager(module)208 if state == 'present':209 sp_man.create_or_update_saml_provider(name, saml_metadata_document)210 elif state == 'absent':211 sp_man.delete_saml_provider(name)212if __name__ == '__main__':...

Full Screen

Full Screen

deprovisioner.py

Source:deprovisioner.py Github

copy

Full Screen

...14# then remove the SAML provider.15 print("Removing SAML provider '{}'".format(args.saml_provider_name))16 # need the ARN of the saml provider, so lets look it up17 saml_provider_arn = look_up_saml_provider(args.saml_provider_name)18 delete_saml_provider(saml_provider_arn)19if __name__ == "__main__":20 import argparse21 __parser__ = argparse.ArgumentParser(description="Set up AWS account for SAML auth")22 __parser__.add_argument('-s --stack_name',23 type=str,24 help='name of the cloudformation stack',25 dest='stack_name',26 required=True,27 default='federated-trust-role-and-policy')28 __parser__.add_argument('-p --saml_provider_name',29 type=str,30 help='name to assign to the identity provider',31 dest="saml_provider_name",32 required=True,...

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