Files

class zos_files.zowe.zos_files_for_zowe_sdk.Files(connection)

Class used to represent the base z/OSMF Files API.

connection

connection object

copy_dataset_or_member(from_dataset_name, to_dataset_name, from_member_name=None, volser=None, alias=None, to_member_name=None, enq=None, replace=False)

Copy a dataset or member to another dataset or member. :param from_dataset_name: Name of the dataset to copy from :type from_dataset_name: str :param to_dataset_name: Name of the dataset to copy to :type to_dataset_name: str :param from_member_name: Name of the member to copy from :type from_member_name: str :param volser: Volume serial number of the dataset to copy from :type volser: str :param alias: Alias of the dataset to copy from :type alias: bool :param to_member_name: Name of the member to copy to :type to_member_name: str :param enq: Enqueue type for the dataset to copy from :type enq: str :param replace: If true, members in the target data set are replaced. :type replace: bool

Returns:

A JSON containing the result of the operation

Return type:

json

copy_uss_to_dataset(from_filename, to_dataset_name, to_member_name=None, type=FileType.TEXT, replace=False)

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 (str) – Name of the member to copy to.

  • type (FileType, optional) – Type of the file to copy from. Default is FileType.TEXT.

  • replace (bool, optional) – If true, members in the target dataset are replaced.

Returns:

A JSON containing the result of the operation.

Return type:

json

create_data_set(dataset_name, options={})

Create a sequential or partitioned dataset. :param dataset_name:

Return type:

json

create_default_data_set(dataset_name: str, default_type: str)

Create a dataset with default options set. Default options depend on the requested type.

Parameters:
  • dataset_name (str) –

  • default_type (str) – “partitioned”, “sequential”, “classic”, “c” or “binary”

Return type:

json - A JSON containing the result of the operation

create_uss(file_path, type, mode=None)

Add a file or directory :param file_path of the file to add: :param type = “file” or “dir”: :param mode Ex: :type mode Ex: - rwxr-xr-x

create_zFS_file_system(file_system_name, options={})

Create a z/OS UNIX zFS Filesystem.

Parameter

file_system_name: str - the name for the file system

rtype:

json - A JSON containing the result of the operation

delete_data_set(dataset_name, volume=None, member_name=None)

Deletes a sequential or partitioned data.

delete_migrated_data_set(dataset_name: str, purge=False, wait=False)

Deletes 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.

Return type:

json - A JSON containing the result of the operation

delete_uss(filepath_name, recursive=False)

Delete a file or directory

Parameters:
  • deleted (filepath of the file to be) –

  • recursive – If specified as True, all the files and sub-directories will be deleted.

Returns:

HTTP Response for No Content

Return type:

204

delete_zFS_file_system(file_system_name)

Deletes a zFS Filesystem

download_binary_dsn(dataset_name, output_file, with_prefixes=False)

Retrieve the contents of a binary dataset and saves it to a given file.

Parameters:
  • dataset_name (str - Name of the dataset to download) –

  • output_file (str - Name of the local file to create) –

  • with_prefixes (boolean - If true, include a four big endian bytes record length prefix.) – The default is False

download_dsn(dataset_name, output_file)

Retrieve the contents of a dataset and saves it to a given file.

download_uss(file_path, output_file, binary=False)

Retrieve the contents of a USS file and saves it to a local file.

get_dsn_binary_content(dataset_name, with_prefixes=False)

Retrieve the contents of a given dataset as a binary bytes object.

Parameters:
  • dataset_name (str - Name of the dataset to retrieve) –

  • with_prefixes (boolean - if True include a 4 byte big endian record len prefix) – default: False

Returns:

A response object from the requests library

Return type:

response

get_dsn_binary_content_streamed(dataset_name, with_prefixes=False)

Retrieve the contents of a given dataset as a binary bytes object streamed.

Parameters:
  • dataset_name (str - Name of the dataset to retrieve) –

  • with_prefixes (boolean - if True include a 4 byte big endian record len prefix) – default: False

Returns:

A response object from the requests library

Return type:

response

get_dsn_content(dataset_name)

Retrieve the contents of a given dataset.

Returns:

A JSON with the contents of a given dataset

Return type:

json

get_dsn_content_streamed(dataset_name)

Retrieve the contents of a given dataset streamed.

Returns:

A response object from the requests library

Return type:

response

get_file_content(filepath_name)

Retrieve the content of a filename. The complete path must be specified.

Returns:

A JSON with the contents of the specified USS file

Return type:

json

get_file_content_streamed(file_path, binary=False)

Retrieve the contents of a given USS file streamed.

Returns:

A response object from the requests library

Return type:

response

list_dsn(name_pattern, return_attributes=False)

Retrieve a list of datasets based on a given pattern.

Parameters:
  • name_pattern (str) – The pattern to match dataset names.

  • return_attributes (bool, optional) – Whether to return dataset attributes along with the names. Defaults to False.

Returns:

  • list of dict

  • A JSON with a list of dataset names (and attributes if specified) matching the given pattern.

list_dsn_members(dataset_name, member_pattern=None, member_start=None, limit=1000, attributes='member')

Retrieve the list of members on a given PDS/PDSE.

Returns:

A JSON with a list of members from a given PDS/PDSE

Return type:

json

list_files(path)

Retrieve a list of USS files based on a given pattern.

Returns:

A JSON with a list of dataset names matching the given pattern

Return type:

json

list_unix_file_systems(file_path_name=None, file_system_name=None)

list all mounted filesystems, or the specific filesystem mounted at a given path, or the filesystem with a given Filesystem name.

Parameter

file_path: str - the UNIX directory that contains the files and directories to be listed. file_system_name: str - the name for the file system to be listed

rtype:

json - A JSON containing the result of the operation

migrate_data_set(dataset_name: str, wait=False)

Migrates 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.

Return type:

json - A JSON containing the result of the operation

mount_file_system(file_system_name, mount_point, options={}, encoding='utf-8')

Mounts a z/OS UNIX file system on a specified directory. Parameter ——— file_system_name: str - the name for the file system mount_point: str - mount point to be used for mounting the UNIX file system options: dict - A JSON of request body options

Return type:

json - A JSON containing the result of the operation

recall_migrated_dataset(dataset_name: str, wait=False)

Recalls 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

Return type:

json - A JSON containing the result of the operation

rename_dataset(before_dataset_name: str, after_dataset_name: str)

Renames the data set.

Parameters:
  • before_dataset_name (str) – The source data set name.

  • after_dataset_name (str) – New name for the source data set.

Return type:

json - A JSON containing the result of the operation

rename_dataset_member(dataset_name: str, before_member_name: str, after_member_name: str, enq='')

Renames 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.

Return type:

json - A JSON containing the result of the operation

unmount_file_system(file_system_name, options={}, encoding='utf-8')

Unmounts a z/OS UNIX file system on a specified directory.

Parameter

file_system_name: str - the name for the file system options: dict - A JSON of request body options

rtype:

json - A JSON containing the result of the operation

upload_file_to_dsn(input_file, dataset_name, encoding='utf-8')

Upload contents of a given file and uploads it to a dataset.

upload_file_to_uss(input_file, filepath_name, encoding='utf-8')

Upload contents of a given file and uploads it to UNIX file

write_to_dsn(dataset_name, data, encoding='utf-8')

Write content to an existing dataset.

Returns:

A JSON containing the result of the operation

Return type:

json

write_to_uss(filepath_name, data, encoding='utf-8')

Write content to an existing UNIX file. :returns: A JSON containing the result of the operation :rtype: json