Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bbf42b3
Support responseTimeout profile property for z/OSMF operations
aadityasinha-dotcom Jun 19, 2025
9412974
Merge branch 'main' into response_timeout
aadityasinha-dotcom Jul 8, 2025
f3285e6
Update src/core/zowe/core_for_zowe_sdk/sdk_api.py
aadityasinha-dotcom Jul 21, 2025
2aa377b
moved the response_timeout in zosmf package and added unit test
aadityasinha-dotcom Jul 21, 2025
ebd612a
Merge branch 'main' into response_timeout
zFernand0 Aug 11, 2025
1da40ae
Merge branch 'main' into response_timeout
aadityasinha-dotcom Oct 27, 2025
e46f89e
Merge branch 'main' into response_timeout
aadityasinha-dotcom Oct 30, 2025
fc70e08
same funcitonality in the files.py
aadityasinha-dotcom Oct 31, 2025
683d5e6
added test for file.py
aadityasinha-dotcom Nov 7, 2025
1f95621
fixes
aadityasinha-dotcom Nov 7, 2025
433a077
moved to zos_files_constants
aadityasinha-dotcom Nov 16, 2025
6d8fe6a
Merge branch 'main' into response_timeout
aadityasinha-dotcom Nov 19, 2025
cc4db15
fixed lint errors
aadityasinha-dotcom Nov 19, 2025
c4e88f1
Merge branch 'main' into response_timeout
aadityasinha-dotcom Dec 6, 2025
f77ff42
added changes to remove header from zosmf
aadityasinha-dotcom Dec 12, 2025
345347b
Merge branch 'main' into response_timeout
aadityasinha-dotcom Dec 12, 2025
a417f0c
Refactor zos_files_for_zowe_sdk to use BaseFilesApi
t1m0thyj Dec 19, 2025
021c0ea
Add docs string to new api class
t1m0thyj Dec 26, 2025
c362795
remove asyncThreshold check and updated changelog
aadityasinha-dotcom Dec 26, 2025
de1d45f
fixed changes
aadityasinha-dotcom Dec 26, 2025
8b3ab97
removed else block
aadityasinha-dotcom Dec 26, 2025
86cd785
Merge branch 'main' into response_timeout
aadityasinha-dotcom Jan 15, 2026
1b24743
fixed unit test
aadityasinha-dotcom Jan 15, 2026
76e45ac
Merge branch 'response_timeout' of github.com:aadityasinha-dotcom/zow…
aadityasinha-dotcom Jan 15, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

## Recent Changes

- Support responseTimeout profile property for z/OSMF operations. [#369](https://github.com/zowe/zowe-client-python-sdk/pull/369)

### Enhancements

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from . import constants, exceptions
from .api import BaseFilesApi
from .datasets import DatasetOption, Datasets
from .file_system import FileSystems
from .files import Files
Expand Down
56 changes: 56 additions & 0 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Zowe Client Python SDK.

This program and the accompanying materials are made available under the terms of the
Eclipse Public License v2.0 which accompanies this distribution, and is available at

https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
"""

from typing import Any

from zowe.core_for_zowe_sdk import SdkApi
from zowe.zos_files_for_zowe_sdk.constants import zos_file_constants

_MIN_TIMEOUT = zos_file_constants["min_timeout"]
_MAX_TIMEOUT = zos_file_constants["max_timeout"]


class BaseFilesApi(SdkApi):
"""
Extends the SdkApi class to support headers specific to z/OSMF Files APIs.

Parameters
----------
profile : dict[str, Any]
Profile information in json (dict) format
log : bool
Flag to disable logger
"""

def __init__(self, profile: dict[str, Any], log: bool = True):
super().__init__(profile, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
self._set_response_timeout(profile)

def _set_response_timeout(self, profile: dict[str, Any]):
if profile.get("X-IBM-Async-Threshold") is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the test failing, please review it ☺️

return

resp_to = profile.get("responseTimeout")
if resp_to is not None:
try:
resp_to_int = int(resp_to)
clamped = max(_MIN_TIMEOUT, min(_MAX_TIMEOUT, resp_to_int))
if clamped != resp_to_int and hasattr(self, "logger"):
self.logger.warning(
f"responseTimeout {resp_to_int} out of range; clamped to {clamped} "
f"(allowed {_MIN_TIMEOUT}-{_MAX_TIMEOUT})"
)
self._default_headers["X-IBM-Response-Timeout"] = str(clamped)
except (TypeError, ValueError):
if hasattr(self, "logger"):
self.logger.warning("responseTimeout must be an integer between 5 and 600; header not set")
2 changes: 2 additions & 0 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
zos_file_constants = {
"MaxAllocationQuantity": 16777215,
"ZoweFilesDefaultEncoding": "utf-8",
"min_timeout": 5,
"max_timeout": 600,
}
from enum import Enum

Expand Down
8 changes: 3 additions & 5 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from requests import Response

from zowe.core_for_zowe_sdk import SdkApi
from zowe.core_for_zowe_sdk.exceptions import FileNotFound
from zowe.zos_files_for_zowe_sdk.api import BaseFilesApi
from zowe.zos_files_for_zowe_sdk.constants import FileType, zos_file_constants
from zowe.zos_files_for_zowe_sdk.response import DatasetListResponse, MemberListResponse

Expand Down Expand Up @@ -292,7 +292,7 @@ def to_dict(self) -> dict[str, Any]:
return {key.replace("_DatasetOption__", ""): value for key, value in self.__dict__.items() if value is not None}


class Datasets(SdkApi): # type: ignore[misc]
class Datasets(BaseFilesApi): # type: ignore[misc]
"""
Class used to represent the base z/OSMF Datasets API.

Expand All @@ -307,9 +307,7 @@ class Datasets(SdkApi): # type: ignore[misc]
"""

def __init__(self, connection: dict[str, Any], log: bool = True) -> None:

super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
super().__init__(connection, log=log)

def list(self, name_pattern: str, return_attributes: bool = False) -> DatasetListResponse:
"""
Expand Down
7 changes: 3 additions & 4 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

from typing import Optional, Any

from zowe.core_for_zowe_sdk import SdkApi
from zowe.zos_files_for_zowe_sdk import constants
from zowe.zos_files_for_zowe_sdk.api import BaseFilesApi

from .exceptions import InvalidPermsOption, MaxAllocationQuantityExceeded
from .response import FileSystemListResponse

_ZOWE_FILES_DEFAULT_ENCODING = constants.zos_file_constants["ZoweFilesDefaultEncoding"]


class FileSystems(SdkApi): # type: ignore
class FileSystems(BaseFilesApi): # type: ignore
"""
Class used to represent the base z/OSMF FileSystems API.

Expand All @@ -36,8 +36,7 @@ class FileSystems(SdkApi): # type: ignore
"""

def __init__(self, connection: dict[str, Any], log: bool = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
super().__init__(connection, log=log)

def create(self, file_system_name: str, options: dict[str, Any] = {}) -> None:
"""
Expand Down
8 changes: 4 additions & 4 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class Files(SdkApi): # type: ignore

def __init__(self, connection: dict[str, Any], log: bool = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
self.ds = Datasets(connection)
self.uss = USSFiles(connection)
self.fs = FileSystems(connection)

self.ds = Datasets(connection, log)
self.uss = USSFiles(connection, log)
self.fs = FileSystems(connection, log)

def list_files(self, path: str) -> Any:
"""Use uss.list() instead of this deprecated function."""
Expand Down
7 changes: 3 additions & 4 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
from typing import Any, Optional, Union

import requests
from zowe.core_for_zowe_sdk import SdkApi
from zowe.core_for_zowe_sdk.exceptions import FileNotFound
from zowe.zos_files_for_zowe_sdk.api import BaseFilesApi
from zowe.zos_files_for_zowe_sdk.constants import zos_file_constants

from .response import USSListResponse

_ZOWE_FILES_DEFAULT_ENCODING = zos_file_constants["ZoweFilesDefaultEncoding"]


class USSFiles(SdkApi): # type: ignore
class USSFiles(BaseFilesApi): # type: ignore
"""
Class used to represent the base z/OSMF USSFiles API.

Expand All @@ -38,8 +38,7 @@ class USSFiles(SdkApi): # type: ignore
"""

def __init__(self, connection: dict[str, Any], log: bool = True):
super().__init__(connection, "/zosmf/restfiles/", logger_name=__name__, log=log)
self._default_headers["Accept-Encoding"] = "gzip"
super().__init__(connection, log=log)

def list(self, path: str) -> USSListResponse:
"""
Expand Down
1 change: 1 addition & 0 deletions src/zosmf/zowe/zosmf_for_zowe_sdk/zosmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ def list_systems(self) -> ZosmfResponse:
custom_args["url"] = "{}/systems".format(self._request_endpoint)
response_json = self.request_handler.perform_request("GET", custom_args, expected_code=[200])
return ZosmfResponse(response_json)

2 changes: 1 addition & 1 deletion tests/unit/files/datasets/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from zowe.zos_files_for_zowe_sdk import Files


class TestCreateClass(TestCase):
class TestCopyClass(TestCase):
"""File class unit tests."""

def setUp(self):
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/files/datasets/test_create.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import DatasetOption, Files, exceptions
from zowe.zos_files_for_zowe_sdk import DatasetOption, Files


class TestCreateClass(TestCase):
Expand Down Expand Up @@ -123,7 +122,7 @@ def test_create_data_set_parameterized(self):

if test_case[1]:
files_test_profile.create_data_set("DSN", test_case[0])
custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = test_case[0].to_dict()
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format("DSN")
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down Expand Up @@ -209,7 +208,7 @@ def test_create_default_data_set_parameterized(self):

if test_case[1]:
files_test_profile.create_default_data_set(*test_case[0])
custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = options.get(test_case[0][1])
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format(test_case[0][0])
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/files/datasets/test_delete.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Datasets, Files, exceptions
from zowe.zos_files_for_zowe_sdk import Files


class TestDeleteClass(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/files/datasets/test_get.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets
from zowe.zos_files_for_zowe_sdk import Files


class TestGetClass(TestCase):
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/files/datasets/test_list.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Unit tests for the Zowe Python SDK z/OS Files package."""

import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Datasets, Files, exceptions
from zowe.zos_files_for_zowe_sdk import Files


class TestFilesClass(TestCase):
class TestListClass(TestCase):
"""File class unit tests."""

def setUp(self):
Expand Down
11 changes: 5 additions & 6 deletions tests/unit/files/datasets/test_migrate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Datasets, Files, exceptions
from zowe.zos_files_for_zowe_sdk import Files


class TestCreateClass(TestCase):
class TestMigrateClass(TestCase):
"""File class unit tests."""

def setUp(self):
Expand Down Expand Up @@ -43,7 +42,7 @@ def test_recall_migrated_data_set_parameterized(self):
data = {"request": "hrecall", "wait": test_case[1]}

files_test_profile.recall_migrated_data_set(test_case[0], test_case[1])
custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = data
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format(test_case[0])
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down Expand Up @@ -82,7 +81,7 @@ def test_delete_migrated_data_set_parameterized(self):
}

files_test_profile.delete_migrated_data_set(test_case[0], test_case[1], test_case[2])
custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = data
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format(test_case[0])
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down Expand Up @@ -119,7 +118,7 @@ def test_migrate_data_set_parameterized(self):

files_test_profile.migrate_data_set(test_case[0], test_case[1])

custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = data
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format(test_case[0])
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/files/datasets/test_rename.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Datasets, Files, exceptions
from zowe.zos_files_for_zowe_sdk import Files


class TestCreateClass(TestCase):
class TestRenameClass(TestCase):
"""File class unit tests."""

def setUp(self):
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_rename_data_set_parameterized(self):

files_test_profile.rename_data_set(test_case[0][0], test_case[0][1])

custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = data
custom_args["url"] = "https://mock-url.com:443/zosmf/restfiles/ds/{}".format(test_case[0][1])
files_test_profile.ds.request_handler.perform_request.assert_called_once_with(
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_rename_data_set_member_parameterized(self):
data["enq"] = test_case[0][3].strip()
if test_case[1]:
files_test_profile.rename_data_set_member(*test_case[0])
custom_args = files_test_profile._create_custom_request_arguments()
custom_args = files_test_profile.ds._create_custom_request_arguments()
custom_args["json"] = data
ds_path = "{}({})".format(test_case[0][0], test_case[0][2])
ds_path_adjusted = files_test_profile._encode_uri_component(ds_path)
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/files/datasets/test_write.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets
from zowe.zos_files_for_zowe_sdk import Files


class TestWriteClass(TestCase):
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/files/file_systems/test_file_systems.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Unit tests for the Zowe Python SDK z/OS Files package."""

import re
from unittest import TestCase, mock

from zowe.zos_files_for_zowe_sdk import Datasets, Files, exceptions
from zowe.zos_files_for_zowe_sdk import Files, exceptions


class TestFilesClass(TestCase):
class TestFileSystemsClass(TestCase):
"""File class unit tests."""

def setUp(self):
Expand Down
Loading