Datasets
- class zos_files.zowe.zos_files_for_zowe_sdk.datasets.Datasets(connection: dict[str, Any], log: bool = True)
Class used to represent the base z/OSMF Datasets API.
It includes all operations related to datasets.
- Parameters:
connection (dict[str, Any]) – A profile for connection in dict (json) format
log (bool) – Flag to disable logger
- copy_data_set_or_member(from_dataset_name: str, to_dataset_name: str, from_member_name: str | None = None, volser: str | None = None, alias: bool | None = None, to_member_name: str | None = None, enq: str | None = None, replace: bool = False) None
Copy a dataset or member to another dataset or member.
- Parameters:
from_dataset_name (str) – Name of the dataset to copy from
to_dataset_name (str) – Name of the dataset to copy to
from_member_name (Optional[str]) – Name of the member to copy from
volser (Optional[str]) – Volume serial number of the dataset to copy from
alias (Optional[bool]) – Alias of the dataset to copy from
to_member_name (Optional[str]) – Name of the member to copy to
enq (Optional[str]) – Enqueue type for the dataset to copy from
replace (bool) – If true, members in the target data set are replaced
- Raises:
ValueError – Thrown when enq has an invalid value
- copy_uss_to_data_set(from_filename: str, to_dataset_name: str, to_member_name: str | None = None, type: FileType = FileType.TEXT, replace: bool = False) None
Copy a USS file to dataset.
- Parameters:
from_filename (str) – Name of the file to copy from.
to_dataset_name (str) – Name of the dataset to copy to.
to_member_name (Optional[str]) – Name of the member to copy to.
type (FileType) – Type of the file to copy from. Default is FileType.TEXT.
replace (bool) – If true, members in the target dataset are replaced.
- create(dataset_name: str, options: DatasetOption | None = None) None
Create a sequential or partitioned dataset.
- Parameters:
dataset_name (str) – Name of the dataset to be created
options (Optional[DatasetOption]) – A DatasetOption class with property options of the dataset
- Raises:
ValueError – Thrown when a parameter has an invalid value
- create_default(dataset_name: str, default_type: str) None
Create a dataset with default options set.
Default options depend on the requested type.
- Parameters:
dataset_name (str) – The name of the dataset
default_type (str) – The type of the dataset: “partitioned”, “sequential”, “classic”, “c” or “binary”
- Raises:
ValueError – Thrown when a parameter is invalid
- delete(dataset_name: str, volume: str | None = None, member_name: str | None = None) None
Delete a sequential or partitioned data.
- Parameters:
dataset_name (str) – The name of the dataset
volume (Optional[str]) – The optional volume serial number
member_name (Optional[str]) – The name of the member to be deleted
- delete_migrated(dataset_name: str, purge: bool = False, wait: bool = False) None
Delete migrated data set.
- Parameters:
dataset_name (str) – Name of the data set
purge (bool) – If true, the function uses the PURGE=YES on ARCHDEL request, otherwise it uses the PURGE=NO.
wait (bool) – If true, the function waits for completion of the request, otherwise the request is queued.
- download(dataset_name: str, output_file: str) None
Use perform_download(content_type=ContenType.TEXT) instead of this deprecated function.
- download_binary(dataset_name: str, output_file: str, with_prefixes: bool = False) None
Use perform_download() instead of this deprecated function.
- get_binary_content(dataset_name: str, stream: bool = False, with_prefixes: bool = False) bytes | Response
Use retrieve_content(content_type=ContentType.BINARY) instead of this deprecated function.
- get_content(dataset_name: str, stream: bool = False) str | None | Response
Use retrieve_content() instead of this deprecated function.
- list(name_pattern: str, return_attributes: bool = False) DatasetListResponse
Retrieve a list of datasets based on a given pattern.
- Parameters:
name_pattern (str) – The pattern to match dataset names.
return_attributes (bool) – Whether to return dataset attributes along with the names. Defaults to False.
- Returns:
A JSON with a list of dataset names (and attributes if specified) matching the given pattern.
- Return type:
DatasetListResponse
- list_members(dataset_name: str, member_pattern: str | None = None, member_start: str | None = None, limit: int = 1000, attributes: str = 'member') MemberListResponse
Retrieve the list of members on a given PDS/PDSE.
- Parameters:
dataset_name (str) – Name of the dataset
member_pattern (Optional[str]) – Filters members by name pattern
member_start (Optional[str]) – The starting point for listing members
limit (int) – The maximum number of members returned
attributes (str) – The member attributes to retrieve
- Returns:
A JSON with a list of members from a given PDS/PDSE
- Return type:
MemberListResponse
- migrate(dataset_name: str, wait: bool = False) None
Migrate the data set.
- Parameters:
dataset_name (str) – Name of the data set
wait (bool) – If true, the function waits for completion of the request, otherwise the request is queued.
- perform_download(dataset_name: str, local_file_path: str, content_type: ContentType = ContentType.TEXT) None
Retrieve the contents of a data set and save it to a local file.
- Parameters:
dataset_name (str) – Name of the dataset to be downloaded
local_file_path (str) – Name of the file to be saved locally
content_type (ContentType, optional) – The content type to receive (“text”, “binary” or “record” (include a 4 byte big endian record len prefix), “text” by default)
- Raises:
TypeError – Thrown when the retrieve_content request does not return a valid Response object.
- perform_upload(local_file_path: str, dataset_name: str, content_type: ContentType = ContentType.TEXT, upload_in_encoding: str = 'utf-8') None
Upload contents of a local file to a data set.
- Parameters:
local_file_path (str) – Name of the file to be uploaded
dataset_name (str) – Name of the dataset to be created
content_type (ContentType, optional) – The content type to receive (“text”, “binary” or “record” (include a 4 byte big endian record len prefix), “text” by default)
upload_in_encoding (str, optional) – Specifies the encoding to upload the content in (e.g. IBM-1047, “utf-8” by default)
- Raises:
FileNotFound – Thrown when a file is not found at provided location
- recall_migrated(dataset_name: str, wait: bool = False) None
Recall a migrated data set.
- Parameters:
dataset_name (str) – Name of the data set
wait (bool) – If true, the function waits for completion of the request, otherwise the request is queued
- rename(before_dataset_name: str, after_dataset_name: str) None
Rename the data set.
- Parameters:
before_dataset_name (str) – The source data set name.
after_dataset_name (str) – New name for the source data set.
- rename_member(dataset_name: str, before_member_name: str, after_member_name: str, enq: str = '') None
Rename the data set member.
- Parameters:
dataset_name (str) – Name of the data set.
before_member_name (str) – The source member name.
after_member_name (str) – New name for the source member.
enq (str) – Values can be SHRW or EXCLU. SHRW is the default for PDS members, EXCLU otherwise.
- Raises:
ValueError – Thrown when a parameter is invalid
- retrieve_content(dataset_name: str, content_type: ContentType = ContentType.TEXT, as_stream: bool = False) str | None | Response
Retrieve the contents of a given dataset.
- Parameters:
dataset_name (str) – The name of the dataset
content_type (ContentType, optional) – The content type to receive (“text”, “binary” or “record” (include a 4 byte big endian record len prefix), “text” by default)
as_stream (bool, optional) – Specifies whether the response is streamed. Default: False
- Returns:
Contents of a given dataset in string, or None if the dataset is empty, or a Response object with content of the file if as_stream == True
- Return type:
Union[str, None, Response]
- upload_file(input_file: str, dataset_name: str, encoding: str = 'utf-8', binary: bool = False) None
Use perform_upload() instead of this deprecated function.
- write(dataset_name: str, data: str | bytes, encoding: str = 'utf-8') None
Write content to an existing dataset.
- Parameters:
dataset_name (str) – Name of the dataset to retrieve
data (Union[str, bytes]) – Content to be written
encoding (str) – Specifies encoding name (e.g. IBM-1047) for text data
- Raises:
ValueError – Data must be either a string or bytes.