Skip to content

Commit

Permalink
minor url updates (#431)
Browse files Browse the repository at this point in the history
* minor url updates

Co-authored-by: Robert Ratliff <robert.ratliff@code42.com>
  • Loading branch information
tora-kozic and Robert Ratliff committed May 25, 2022
1 parent 6585324 commit b7dbea9
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/py42/clients/loginconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def get_for_user(self, username):
Returns:
:class:`py42.response.Py42Response`
"""
uri = f"{self._connection.host_address}/c42api/v3/LoginConfiguration"
uri = f"{self._connection.host_address}/api/v3/LoginConfiguration"
response = self._connection._session.get(uri, params={"username": username})
return Py42Response(response)
2 changes: 1 addition & 1 deletion src/py42/clients/settings/org_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, org_settings, t_settings):

@property
def packets(self):
"""The setting packets for any modifications to be posted to the /api/OrgSettings
"""The setting packets for any modifications to be posted to the /api/v1/OrgSettings
endpoint.
"""
return list(self._packets.values())
Expand Down
2 changes: 1 addition & 1 deletion src/py42/services/legalhold.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_events_page(
"pgNum": page_num,
"pgSize": page_size,
}
uri = "/api/LegalHoldEventReport"
uri = "/api/v1/LegalHoldEventReport"

return self._connection.get(uri, params=params)

Expand Down
4 changes: 2 additions & 2 deletions src/py42/services/orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def get_settings(self, org_id):
org_settings = self.get_by_id(
org_id, incSettings=True, incDeviceDefaults=True, incInheritedOrgInfo=True
)
uri = f"/api/OrgSetting/{org_id}"
uri = f"/api/v1/OrgSetting/{org_id}"
t_settings = self._connection.get(uri)
return OrgSettings(org_settings.data, t_settings.data)

Expand All @@ -212,7 +212,7 @@ def update_settings(self, org_settings):
org_settings_response = org_response = None

if org_settings.packets:
uri = f"/api/OrgSetting/{org_id}"
uri = f"/api/v1/OrgSetting/{org_id}"
payload = {"packets": org_settings.packets}
try:
org_settings_response = self._connection.put(uri, json=payload)
Expand Down
2 changes: 1 addition & 1 deletion src/py42/services/storage/_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_tmp_auth(self):
raise NotImplementedError()

def _get_auth_token(self, login_token):
uri = "api/AuthToken"
uri = "api/v1/AuthToken"
response = self._storage_connection.post(
uri, headers={"Authorization": f"login_token {login_token}"}
)
Expand Down
14 changes: 7 additions & 7 deletions src/py42/services/storage/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def search_paths(
show_deleted=None,
):
# session_id is a web restore session ID (see create_restore_session)
uri = "/api/WebRestoreSearch"
uri = "/api/v1/WebRestoreSearch"
params = {
"webRestoreSessionId": session_id,
"guid": device_guid,
Expand All @@ -31,7 +31,7 @@ def get_file_size(
show_deleted=None,
backup_set_id=None,
):
uri = "/api/WebRestoreFileSize"
uri = "/api/v1/WebRestoreFileSize"
params = {
"guid": device_guid,
"fileId": file_id,
Expand All @@ -48,7 +48,7 @@ def create_file_size_job(
timestamp=None,
show_deleted=None,
):
uri = "/api/WebRestoreFileSizePolling"
uri = "/api/v1/WebRestoreFileSizePolling"
json_dict = {
"guid": device_guid,
"fileId": file_id,
Expand All @@ -58,7 +58,7 @@ def create_file_size_job(
return self._connection.post(uri, json=json_dict)

def get_file_size_job(self, job_id, device_guid):
uri = "/api/WebRestoreFileSizePolling"
uri = "/api/v1/WebRestoreFileSizePolling"
params = {
"jobId": job_id,
"guid": device_guid,
Expand All @@ -78,7 +78,7 @@ def get_file_path_metadata(
include_os_metadata=None,
):
# session_id is a web restore session ID (see create_restore_session)
uri = "/api/WebRestoreTreeNode"
uri = "/api/v1/WebRestoreTreeNode"
params = {
"webRestoreSessionId": session_id,
"guid": device_guid,
Expand Down Expand Up @@ -122,11 +122,11 @@ def start_restore(
return self._connection.post(uri, json=json_dict)

def cancel_restore(self, job_id):
uri = "/api/WebRestoreJob"
uri = "/api/v1/WebRestoreJob"
json_dict = {"jobId": job_id}
return self._connection.delete(uri, json=json_dict)

def stream_restore_result(self, job_id):
uri = f"/api/WebRestoreJobResult/{job_id}"
uri = f"/api/v1/WebRestoreJobResult/{job_id}"
headers = {"Accept": "application/octet-stream"}
return self._connection.get(uri, stream=True, headers=headers)
4 changes: 2 additions & 2 deletions src/py42/services/storage/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_restore_session(
encryption_key=None,
):
"""Creates a web restore connection."""
uri = "/api/WebRestoreSession"
uri = "/api/v1/WebRestoreSession"
json_dict = {
"computerGuid": device_guid,
"dataKeyToken": data_key_token,
Expand All @@ -42,7 +42,7 @@ def create_restore_session(
raise

def get_restore_status(self, job_id):
uri = f"/api/WebRestoreJob/{job_id}"
uri = f"/api/v1/WebRestoreJob/{job_id}"
return self._connection.get(uri)


Expand Down
2 changes: 1 addition & 1 deletion tests/clients/test_loginconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_get_for_user_calls_session_get_with_expected_uri_and_params(
connection = Connection.from_host_address(HOST_ADDRESS, session=mock_session)
loginconfig = LoginConfigurationClient(connection)
loginconfig.get_for_user("test@example.com")
expected_uri = f"https://{HOST_ADDRESS}/c42api/v3/LoginConfiguration"
expected_uri = f"https://{HOST_ADDRESS}/api/v3/LoginConfiguration"
expected_params = {"username": "test@example.com"}
mock_session.get.assert_called_once_with(expected_uri, params=expected_params)

Expand Down
16 changes: 8 additions & 8 deletions tests/services/storage/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
ARGS_INDEX = 0
KWARGS_INDEX = 1

WEB_RESTORE_SESSION_URL = "/api/WebRestoreSession"
WEB_RESTORE_SESSION_URL = "/api/v1/WebRestoreSession"
START_WEB_RESTORE_JOB_URL = "/api/v9/restore/web"
WEB_RESTORE_JOB_URL = "/api/WebRestoreJob"
WEB_RESTORE_JOB_RESULT_URL = "/api/WebRestoreJobResult"
WEB_RESTORE_JOB_URL = "/api/v1/WebRestoreJob"
WEB_RESTORE_JOB_RESULT_URL = "/api/v1/WebRestoreJobResult"


FILE_PATH = "/directory/file.txt"
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_search_paths_calls_get_with_expected_params(self, connection):
"session_id", "device_id", "regex", 1000, "timestamp", True
)
connection.get.assert_called_once_with(
"/api/WebRestoreSearch",
"/api/v1/WebRestoreSearch",
params={
"webRestoreSessionId": "session_id",
"guid": "device_id",
Expand All @@ -83,7 +83,7 @@ def test_get_file_size_calls_get_with_expected_params(self, connection):
"device_guid", "file_id", "timestamp", True, "backupset_id"
)
connection.get.assert_called_once_with(
"/api/WebRestoreFileSize",
"/api/v1/WebRestoreFileSize",
params={
"guid": "device_guid",
"fileId": "file_id",
Expand All @@ -103,14 +103,14 @@ def test_create_file_size_job_calls_post_with_expected_params(self, connection):
"showDeleted": False,
}
connection.post.assert_called_once_with(
"/api/WebRestoreFileSizePolling", json=json_dict
"/api/v1/WebRestoreFileSizePolling", json=json_dict
)

def test_get_file_size_job_calls_get_with_expected_params(self, connection):
storage_archive_service = StorageArchiveService(connection)
storage_archive_service.get_file_size_job("job_id", "device_guid")
connection.get.assert_called_once_with(
"/api/WebRestoreFileSizePolling",
"/api/v1/WebRestoreFileSizePolling",
params={"jobId": "job_id", "guid": "device_guid"},
)

Expand All @@ -128,7 +128,7 @@ def test_get_file_path_metadata_calls_get_with_expected_params(self, connection)
include_os_metadata=True,
)
connection.get.assert_called_once_with(
"/api/WebRestoreTreeNode",
"/api/v1/WebRestoreTreeNode",
params={
"webRestoreSessionId": TEST_SESSION_ID,
"guid": TEST_DEVICE_GUID,
Expand Down
2 changes: 1 addition & 1 deletion tests/services/storage/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_call_calls_auth_apis_with_expected_urls(
}
mock_tmp_auth_conn.post.assert_called_once_with("/api/v1/LoginToken", json=data)
mock_storage_auth_token_conn.post.assert_called_once_with(
"api/AuthToken",
"api/v1/AuthToken",
headers={"Authorization": "login_token TEST_TMP_TOKEN_VALUE"},
)

Expand Down
2 changes: 1 addition & 1 deletion tests/services/test_legalhold.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_get_events_page_calls_get_with_expected_url_and_params(
service = LegalHoldService(mock_connection)
service.get_events_page("legalhold", None, None, 20, 200)
mock_connection.get.assert_called_once_with(
"/api/LegalHoldEventReport",
"/api/v1/LegalHoldEventReport",
params={
"legalHoldUid": "legalhold",
"minEventDate": None,
Expand Down

0 comments on commit b7dbea9

Please sign in to comment.