Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

fix admintech, generate endpoints md for new release #18

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**THIS FILE WAS AUTO-GENERATED DO NOT EDIT**

Generated for: catalystwan-0.33.0
Generated for: catalystwan-0.33.2

All URIs are relative to */dataservice*
HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode
Expand Down Expand Up @@ -570,8 +570,8 @@ PUT /settings/configuration/claimDevice||[**ConfigurationSettings.edit_claim_dev
PUT /settings/configuration/walkme||[**ConfigurationSettings.edit_walkme**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L653)|[**WalkMe**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L275)|DataSequence[[**WalkMe**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L275)]|
PUT /settings/configuration/smartLicensing||[**ConfigurationSettings.edit_smart_licensing_settings**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L657)|[**SmartLicensingSetting**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L281)|DataSequence[[**SmartLicensingSetting**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_settings.py#L281)]|PROVIDER, SINGLE_TENANT
GET /app/json/application_protocol.json||[**MiscellaneousEndpoints.get_application_protocols**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/misc.py#L14)||DataSequence[[**ApplicationProtocolMap**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/misc/application_protocols.py#L28)]|
GET /device/tier||[**MonitoringDeviceDetails.get_tiers**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L185)||DataSequence[[**Tier**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L17)]|
GET /device||[**MonitoringDeviceDetails.list_all_devices**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L209)||DataSequence[[**DeviceData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L46)]|
GET /device/tier||[**MonitoringDeviceDetails.get_tiers**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L191)||DataSequence[[**Tier**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L17)]|
GET /device||[**MonitoringDeviceDetails.list_all_devices**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L215)||DataSequence[[**DeviceData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_device_details.py#L52)]|
GET /statistics/settings/disable/devicelist/{indexName}||[**MonitoringStatus.get_disabled_device_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L58)||[**DisabledDeviceListResponse**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L45)|
PUT /statistics/settings/disable/devicelist/{indexName}||[**MonitoringStatus.update_statistics_device_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L62)|[**DisabledDeviceList**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L41)|[**UpdateIndexResponse**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L49)|
GET /statistics/settings/status||[**MonitoringStatus.get_statistics_settings**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L66)||DataSequence[[**Status**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring_status.py#L23)]|
Expand Down
14 changes: 6 additions & 8 deletions catalystwan/api/admin_tech_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
from pathlib import Path
from typing import TYPE_CHECKING, List, Optional

from requests import Response # type: ignore
from requests.exceptions import HTTPError # type: ignore

from catalystwan.dataclasses import AdminTech, DeviceAdminTech
from catalystwan.exceptions import CatalystwanException
from catalystwan.exceptions import CatalystwanException, ManagerHTTPError
from catalystwan.response import ManagerResponse
from catalystwan.utils.creation_tools import create_dataclass

if TYPE_CHECKING:
Expand Down Expand Up @@ -117,7 +115,7 @@ def generate(
json=body,
timeout=request_timeout,
)
except HTTPError as http_error:
except ManagerHTTPError as http_error:
response = http_error.response # type: ignore
if response.status_code == 200:
return response.json()["fileName"]
Expand All @@ -131,7 +129,7 @@ def generate(
polling_timer -= polling_interval
raise GenerateAdminTechLogError(f"It is not possible to generate admintech log for {device_id}")

def _get_token_id(self, filename: str, timeout: int = 3600, interval: int = 30) -> str:
def _get_token_id(self, filename: str, timeout: int, interval: int) -> str:
# Wait for the file to be ready and obtain the token_id
end_time = time.time() + timeout
while time.time() < end_time:
Expand All @@ -144,15 +142,15 @@ def _get_token_id(self, filename: str, timeout: int = 3600, interval: int = 30)
f"requestTokenId of admin tech generation request not found for file name: {filename}"
)

def delete(self, filename: str) -> Response:
def delete(self, filename: str, timeout: int = 3600, interval: int = 30) -> ManagerResponse:
"""Deletes admin tech logs for a device.
Args:
filename: name of admin_tech file
Returns:
response: http response for delete operation
"""

token_id = self._get_token_id(filename)
token_id = self._get_token_id(filename, timeout, interval)
response = self.session.delete(f"/dataservice/device/tools/admintech/{token_id}")
if response.status_code == 200:
logger.info(f"Deleted AdminTech file {filename} on remote")
Expand Down
20 changes: 10 additions & 10 deletions catalystwan/tests/test_admin_tech_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setUp(self):
self.download_file = io.BytesIO(self.download_file_content.encode())

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_get(self, mock_session, mock_response):
# Arrange
mock_session.post.return_value = mock_response
Expand All @@ -78,7 +78,7 @@ def test_get(self, mock_session, mock_response):
self.assertIsInstance(admintechs[0], DeviceAdminTech)

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_get_all(self, mock_session, mock_response):
# Arrange
mock_session.get.return_value = mock_response
Expand All @@ -90,7 +90,7 @@ def test_get_all(self, mock_session, mock_response):
self.assertEqual(len(admintechs), len(self.admin_tech_infos["data"]))

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_generate(self, mock_session, mock_response):
# Arrange
mock_session.post.return_value = mock_response
Expand All @@ -106,7 +106,7 @@ def test_generate(self, mock_session, mock_response):
self.assertEqual(filename, self.admin_tech_generate_response["fileName"])

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_generate_in_progress_error_retry(self, mock_session, mock_response):
# Arrange
mock_session.post.return_value = mock_response
Expand All @@ -124,7 +124,7 @@ def test_generate_in_progress_error_retry(self, mock_session, mock_response):
self.assertEqual(mock_session.post.call_count, count)

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_generate_error(self, mock_session, mock_response):
# Arrange
mock_session.post.return_value = mock_response
Expand All @@ -142,7 +142,7 @@ def test_generate_error(self, mock_session, mock_response):
mock_session.post.assert_called_once()

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_delete(self, mock_session, mock_response):
# Arrange
filename = self.admin_tech_generate_response["fileName"]
Expand All @@ -155,17 +155,17 @@ def test_delete(self, mock_session, mock_response):
mock_session.delete.assert_called_once_with(f"/dataservice/device/tools/admintech/{token_id}")

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_delete_token_not_found(self, mock_session, mock_response):
# Arrange
mock_session.get.return_value = mock_response
mock_response.json.return_value = self.admin_tech_infos
# Act/Assert
with self.assertRaises(RequestTokenIdNotFound):
AdminTechAPI(mock_session).delete("fake-filename.tar.gz")
AdminTechAPI(mock_session).delete("fake-filename.tar.gz", timeout=0.01, interval=0.01)

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_download(self, mock_session, mock_response):
# Arrange
filename = self.admin_tech_generate_response["fileName"]
Expand All @@ -180,7 +180,7 @@ def test_download(self, mock_session, mock_response):
self.assertEqual(download_path, Path(tmpdir) / filename)

@patch("catalystwan.session.ManagerSession")
@patch("requests.Response")
@patch("catalystwan.response.ManagerResponse")
def test_download_error(self, mock_session, mock_response):
# Arrange
mock_session.get.return_value = mock_response
Expand Down