|
27 | 27 | 'DSFResponsePool', 'DSFRuleset', 'DSFMonitorEndpoint', 'DSFMonitor',
|
28 | 28 | 'TrafficDirector']
|
29 | 29 |
|
| 30 | + |
30 | 31 | def get_all_dsf_services():
|
31 | 32 | """:return: A ``list`` of :class:`TrafficDirector` Services"""
|
32 | 33 | uri = '/DSF/'
|
@@ -3370,6 +3371,48 @@ def remove_orphans(self):
|
3370 | 3371 | api_args = {'remove_orphans': 'Y'}
|
3371 | 3372 | self._update(api_args)
|
3372 | 3373 |
|
| 3374 | + def replace_all_rulesets(self, rulesets): |
| 3375 | + """ |
| 3376 | + This request will replace all rulesets with a new list of rulesets. |
| 3377 | + :param rulesets: a list of rulesets :class:DSFRuleset to be published to the service |
| 3378 | + Warning! This call takes extra time as it is several api calls. |
| 3379 | + """ |
| 3380 | + if (type(rulesets) is list or type(rulesets) is tuple) and isinstance(rulesets[0], DSFRuleset): |
| 3381 | + old_rulesets = self.all_rulesets |
| 3382 | + for old_rule in old_rulesets: |
| 3383 | + old_rule.delete() |
| 3384 | + for new_rule in rulesets: |
| 3385 | + new_rule._dsf_ruleset_id = None |
| 3386 | + new_rule.create(self) |
| 3387 | + else: |
| 3388 | + raise Exception("rulesets parameter must be a list of DSFRuleset objects") |
| 3389 | + |
| 3390 | + def replace_one_ruleset(self, ruleset): |
| 3391 | + """ |
| 3392 | + This request will replace a single ruleset and maintain the order of the list. |
| 3393 | + :param ruleset: A single object of :class:DSFRuleset` |
| 3394 | + The replacement is keyed by the DSFRuleset label value |
| 3395 | + Warning! This call takes extra time as it is several api calls. |
| 3396 | + """ |
| 3397 | + if isinstance(ruleset, DSFRuleset): |
| 3398 | + old_rulesets = self.all_rulesets |
| 3399 | + old_rule = None |
| 3400 | + rule_index = 0 |
| 3401 | + for rule in old_rulesets: |
| 3402 | + if rule.label == ruleset.label: |
| 3403 | + old_rule = rule |
| 3404 | + rule_index += 1 |
| 3405 | + break |
| 3406 | + rule_index += 1 |
| 3407 | + if old_rule is not None: |
| 3408 | + old_rule.delete() |
| 3409 | + ruleset._dsf_ruleset_id = None |
| 3410 | + ruleset.create(self, index=rule_index) |
| 3411 | + else: |
| 3412 | + ruleset.create(self) |
| 3413 | + else: |
| 3414 | + raise Exception("rulesets parameter must be a single object of class DSFRuleset") |
| 3415 | + |
3373 | 3416 | @property
|
3374 | 3417 | def service_id(self):
|
3375 | 3418 | """The unique System id of this DSF Service"""
|
|
0 commit comments