How to use get_hosted_zone method in localstack

Best Python code snippet using localstack_python

zones.py

Source:zones.py Github

copy

Full Screen

...31 return render_template('zones/new.html', form=form)32@zones.route('/<zone_id>/delete', methods=['GET', 'POST'])33def zones_delete(zone_id):34 conn = get_connection()35 zone = conn.get_hosted_zone(zone_id)['GetHostedZoneResponse']['HostedZone']36 error = None37 if request.method == 'POST' and 'delete' in request.form:38 try:39 conn.delete_hosted_zone(zone_id)40 flash(u"A zone with id %s has been deleted" % zone_id)41 return redirect(url_for('zones_list'))42 except DNSServerError as error:43 error = error44 return render_template('zones/delete.html',45 zone_id=zone_id,46 zone=zone,47 error=error)48@zones.route('/<zone_id>')49def zones_detail(zone_id):50 conn = get_connection()51 resp = conn.get_hosted_zone(zone_id)52 zone = resp['GetHostedZoneResponse']['HostedZone']53 nameservers = resp['GetHostedZoneResponse']['DelegationSet']['NameServers']54 return render_template('zones/detail.html',55 zone_id=zone_id,56 zone=zone,57 nameservers=nameservers)58@zones.route('/<zone_id>/records')59def zones_records(zone_id):60 conn = get_connection()61 resp = conn.get_hosted_zone(zone_id)62 zone = resp['GetHostedZoneResponse']['HostedZone']63 record_resp = sorted(conn.get_all_rrsets(zone_id), key=lambda x: x.type)64 groups = groupby(record_resp, key=lambda x: x.type)65 groups = [(k, list(v)) for k, v in groups]66 return render_template('zones/records.html',67 zone_id=zone_id,68 zone=zone,69 groups=groups)70@zones.route('/clone/<zone_id>', methods=['GET', 'POST'])71def zones_clone(zone_id):72 conn = get_connection()73 zone_response = conn.get_hosted_zone(zone_id)74 original_zone = zone_response['GetHostedZoneResponse']['HostedZone']75 form = ZoneForm()76 errors = []77 if form.validate_on_submit():78 response = conn.create_hosted_zone(79 form.name.data,80 comment=form.comment.data)81 info = response['CreateHostedZoneResponse']82 nameservers = ', '.join(info['DelegationSet']['NameServers'])83 new_zone_id = info['HostedZone']['Id']84 original_records = conn.get_all_rrsets(zone_id)85 from route53.models import ChangeBatch, Change, db86 for recordset in original_records:87 if not recordset.type in ["SOA", "NS"]:...

Full Screen

Full Screen

test_route53_probes.py

Source:test_route53_probes.py Github

copy

Full Screen

...14 with open(os.path.join(module_path, "data", filename)) as fh:15 data = json.loads(fh.read())16 return data17@patch("chaosaws.route53.probes.aws_client", autospec=True)18def test_get_hosted_zone(m_client):19 mock_response = read_in_data("get_hosted_zone_1.json")20 client = MagicMock()21 m_client.return_value = client22 client.get_hosted_zone.return_value = mock_response23 response = get_hosted_zone(zone_id="AAAAAAAAAAAAA")24 client.get_hosted_zone.assert_called_with(Id="AAAAAAAAAAAAA")25 assert response["HostedZone"]["Name"] == "aws.testrecord.com."26@patch("chaosaws.route53.probes.aws_client", autospec=True)27def test_get_hosted_zone_not_found(m_client):28 mock_response = ClientError(29 operation_name="get_hosted_zone",30 error_response={"Error": {"Message": "Test Error", "Code": "NoSuchHostedZone"}},31 )32 client = MagicMock()33 m_client.return_value = client34 client.get_hosted_zone.side_effect = mock_response35 with pytest.raises(FailedActivity) as e:36 get_hosted_zone(zone_id="BBBBBBBBBBBBB")37 assert "Hosted Zone BBBBBBBBBBBBB not found." in str(e)38@patch("chaosaws.route53.probes.aws_client", autospec=True)39def test_get_health_check_status(m_client):40 mock_response = read_in_data("get_health_check_status_1.json")41 client = MagicMock()42 m_client.return_value = client43 client.get_health_check_status.return_value = mock_response44 response = get_health_check_status(check_id="00000000-0000-0000-0000-000000000000")45 client.get_health_check_status.assert_called_with(46 HealthCheckId="00000000-0000-0000-0000-000000000000"47 )48 assert len(response["HealthCheckObservations"]) == 249@patch("chaosaws.route53.probes.aws_client", autospec=True)50def test_get_health_check_status_not_found(m_client):...

Full Screen

Full Screen

route_53.py

Source:route_53.py Github

copy

Full Screen

...12 return self.r53_client.create_hosted_zone(13 Name=dns_domain, CallerReference=caller_reference)14 def delete_hosted_zone_by_name(self, dns_domain):15 return self.r53_client.delete_hosted_zone(Id=self.get_hosted_zone_id(dns_domain))16 def get_hosted_zone(self, hosted_zone_id):17 return self.r53_client.get_hosted_zone(Id=hosted_zone_id)18 def get_hosted_zone_id(self, dns_domain):19 self._logger.debug('Looking up hosted zone ID for domain: %s', dns_domain)20 for hosted_zone in self.r53_client.list_hosted_zones().get('HostedZones'):21 # Hosted zones have trailing dots...22 if hosted_zone['Name'] == f'{dns_domain}':23 return hosted_zone['Id']24 self._logger.debug('No hosted zone found')25 def get_domain_ns_records(self, hosted_zone_id):26 hosted_zone = self.get_hosted_zone(hosted_zone_id)...

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