Camphor Networks Platform API
camphor_bgpTester_manager.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 ##
4 # Copyright (C) Camphor Networks, Inc - All Rights Reserved
5 # Unauthorized copying of this file via any medium is strictly prohibited
6 # Proprietary and confidential
7 # Written by Ananth Suryanarayana <ananth@camphornetworks.com>, July 2022
8 # https://camphornetworks.com/camphor-networks-platform-terms-of-use-and-privacy-policy/
9 # mailto:info@camphornetworks.com?subject=copyright
10 #
11 
12 from __future__ import annotations
13 
15 
16 
18  def __init__(self, schema: CamphorProjectSchema):
19  self.schemaschema = schema
20  if not self.schemaschema.bgpTesters:
21  self.schemaschema.bgpTesters = BgpTesters(item=[], attributes=BgpTesterAttributesDefinition())
22 
23  def getBgpTesterCommonAttributes(self) -> BgpTesterAttributesDefinition:
24  return self.schemaschema.bgpTesters.attributes
25 
26  def setBgpTesterCommonAttributes(self, attributes: BgpTesterAttributesDefinition) -> None:
27  self.schemaschema.bgpTesters.attributes = attributes
28 
29  def createBgpTester(self, name: str, attributes: Optional[BgpTesterAttributesDefinition] = None) -> BgpTestersItem:
30  bgpTester = BgpTestersItem(name=name, attributes=attributes)
31  self.schemaschema.bgpTesters.item.append(bgpTester)
32  return bgpTester
33 
34  def getBgpTester(self) -> List[BgpTestersItem]:
35  return self.schemaschema.bgpTesters.item
36 
37  def findBgpTesterPosition(self, name: str) -> int:
38  bgpTesters = self.getBgpTestergetBgpTester()
39  for i in range(len(bgpTesters)):
40  if bgpTesters[i].name == name:
41  return i
42  return -1
43 
44  def findBgpTester(self, name: str) -> BgpTestersItem:
45  position = self.findBgpTesterPositionfindBgpTesterPosition(name=name)
46  return self.getBgpTestergetBgpTester()[position] if position >= 0 else None
47 
48  def deleteBgpTester(self, name: str) -> None:
49  position = self.findBgpTesterPositionfindBgpTesterPosition(name=name)
50  if position >= 0:
51  del self.getBgpTestergetBgpTester()[position]
None setBgpTesterCommonAttributes(self, BgpTesterAttributesDefinition attributes)
BgpTestersItem createBgpTester(self, str name, Optional[BgpTesterAttributesDefinition] attributes=None)