Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace sporadic use of private attributes with public properties #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions sdxlib/sdx_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
self._name = name
self._endpoints = endpoints
self._description = description
self._notifications = self._validate_notifications(notifications)
self._notifications = notifications
self._scheduling = scheduling
self._qos_metrics = qos_metrics
self._logger = logger or logging.getLogger(__name__)
Expand Down Expand Up @@ -482,33 +482,33 @@ def create_l2vpn(self) -> SDXResponse:
SDXException: If the L2VPN creation fails.
ValueError: If required attributes are missing.
"""
if not self._base_url or not self._name or not self._endpoints:
if not self.base_url or not self.name or not self.endpoints:
raise ValueError(
"Creating L2VPN requires the base URL, name, and endpoints at minumum."
)
if not isinstance(self._endpoints, list):
if not isinstance(self.endpoints, list):
raise TypeError("Endpoints must be a list.")
url = f"{self.base_url}/l2vpn/{self.VERSION}"
# print(url)

payload = {"name": self._name, "endpoints": self._endpoints}
payload = {"name": self.name, "endpoints": self.endpoints}

# Add optional attributes if provided.
if self._description:
payload["description"] = self._description
if self._notifications:
payload["notifications"] = self._notifications
if self._scheduling:
payload["scheduling"] = self._scheduling
if self._qos_metrics:
payload["qos_metrics"] = self._qos_metrics
if self.description:
payload["description"] = self.description
if self.notifications:
payload["notifications"] = self.notifications
if self.scheduling:
payload["scheduling"] = self.scheduling
if self.qos_metrics:
payload["qos_metrics"] = self.qos_metrics

self._logger.debug("Sending request to create L2VPN with payload: %s", payload)

# Check cache for existing request with same name and endpoints
cache_key = (
self._name,
tuple(endpoint["port_id"] for endpoint in self._endpoints),
self.name,
tuple(endpoint["port_id"] for endpoint in self.endpoints),
)
cached_data = self._request_cache.get(cache_key)

Expand Down Expand Up @@ -937,7 +937,7 @@ def get_available_ports(
Raises:
SDXException: If the API request fails or returns an error.
"""
topology_url = f"{self._base_url}/topology"
topology_url = f"{self.base_url}/topology"

try:
response = requests.get(topology_url, timeout=10)
Expand Down