def create_page_rule(self, targets=None, url_matches=None, actions=(), priority=1, status='active'): """ Create a PageRule. Either the targets can be explicitly spelled out (the JSON dictionary in the CF API), or the convenience parameter url_matches can be used to generate the targets parameter. The other parameters map directly to the CF API. """ if url_matches: if targets: raise ValueError( 'Only one of targets and url_matches can be specified') targets = [{ 'target': 'url', 'constraint': { 'operator': 'matches', 'value': url_matches, }, }] data = { 'targets': targets, 'actions': actions, 'priority': priority, 'status': status, } page_rule = self._service.create_page_rule(self.id, data) clear_property_cache(self, 'page_rules') return PageRule(self, page_rule)
def create_record(self, name, record_type, content=None, ttl=1, proxied=False, **kwargs): data = { 'name': name, 'type': record_type, 'ttl': ttl, 'proxied': proxied, } if content: data['content'] = content if record_type == 'MX': data['priority'] = kwargs['priority'] elif record_type == 'SRV': data['data'] = { 'name': name, 'service': kwargs['service'], 'proto': kwargs['protocol'], 'priority': kwargs['priority'], 'weight': kwargs['weight'], 'port': kwargs['port'], 'target': kwargs['target'], } record = self._service.create_dns_record(self.id, data) clear_property_cache(self, 'records') return Record(self, record)
def save(self): if self._updates: result = self.service.update_dns_record(self.zone.id, self.id, self._updates) self._data.update(result) if 'name' in self._updates: clear_property_cache(self.zone, 'records') self._updates = {}
def create_record(self, name, type, content, ttl=1, proxied=False, priority=10): data = { 'name': name, 'type': type, 'content': content, 'ttl': ttl, 'proxied': proxied, } if type == 'MX': data['priority'] = priority record = self.service.create_dns_record(self.id, data) clear_property_cache(self, 'records') return Record(self, record)
def delete(self): self.service.delete_zone(self.id) clear_property_cache(self.user, 'zones')
def delete(self): self.service.delete_dns_record(self.zone.id, self.id) clear_property_cache(self.zone, 'records')
def delete(self): self._service.delete_page_rule(self.zone.id, self.id) clear_property_cache(self.zone, 'page_rules')
def _save(self): result = self._service.update_page_rule(self.zone.id, self.id, self._data) if result['priority'] != self._saved_data['priority']: clear_property_cache(self.zone, 'page_rules') return result
def delete(self): self._service.delete_dns_record(self.zone.id, self.id) clear_property_cache(self.zone, 'records')
def _save(self): result = self._service.update_dns_record(self.zone.id, self.id, self._data) if result['name'] != self._saved_data['name']: clear_property_cache(self.zone, 'records') return result
def delete(self): self._service.delete_zone(self.id) clear_property_cache(self.user, 'zones')
def test_does_not_affect_other_cached_properties_on_the_object(self): self.assertEqual(self.test_obj.method, 1) self.assertEqual(self.test_obj.method2, 1) clear_property_cache(self.test_obj, 'method') self.assertEqual(self.test_obj.method, 2) self.assertEqual(self.test_obj.method2, 1)
def test_clears_the_calculated_value(self): self.assertEqual(self.test_obj.method, 1) clear_property_cache(self.test_obj, 'method') self.assertEqual(self.test_obj.method, 2)