Python wrapper to SAP HDLFS API
Project description
PyHDLFS
PythonAPI for SAP HDLFS using the RestAPI
Status: In Progress, unsupported
by Thorsten Hapke, thorsten.hapke@sap.com
Table of Contents
__init__
hdlfs
get_path_content
def get_path_content(response: dict) -> list
Extracts the path items from response of LISTSTATUS API
Arguments:
response
: Response from LISTSTATUS
Returns:
List of path items (folders and files)
get_recursive_path_content
def get_recursive_path_content(response: dict) -> list
Extracts the path items from response of LISTSTATUS_RECURSIVE API
Arguments:
response
: Response from LISTSTATUS_RECURSIVE
Returns:
List of path items (folders and files)
hdlfs_api
def hdlfs_api(method: str, operation: str) -> dict
DECORATOR for all API-calls
Arguments:
method
: HTTP-method [get, put, ..]operation
: RESTAPI name
Returns:
response of Rest API
upload
@hdlfs_api(method='put', operation='CREATE')
def upload(endpoint: str,
certificate: str,
password: str,
destination='',
data="",
noredirect=False,
headers={},
verify=True) -> dict
Upload file to HDFS using CREATE-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystoredestination
: destination path of filedata
: file contentnoredirect
: API parameterheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
rename
@hdlfs_api(method='put', operation='RENAME')
def rename(endpoint: str,
certificate: str,
password: str,
path='',
destination='',
headers={},
verify=True) -> dict
Rename/Move file in HDFS with RENAME-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source filedestination
: destination of fileheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
copy
@hdlfs_api(method='put', operation='COPY')
def copy(endpoint,
certificate,
password,
path='',
destination='',
a_sync=False,
headers={},
verify=True)
Copy file in HDFS with Copy-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source filedestination
: destination of filea_sync
: API parameterheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
delete
@hdlfs_api(method='del', operation='DELETE')
def delete(endpoint: str,
certificate: str,
password: str,
path='',
headers={},
verify=True) -> dict
Delete file in HDFS with DELETE-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source fileheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
file_status
@hdlfs_api(method='get', operation='GETFILESTATUS')
def file_status(endpoint: str,
certificate: str,
password: str,
path='',
headers={},
verify=True)
Get file status
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source fileheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
list_path
@hdlfs_api(method='get', operation='LISTSTATUS')
def list_path(endpoint: str,
certificate: str,
password: str,
path='',
headers={},
verify=True)
Get all items of folder by using LISTSTATUS-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source fileheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
list_path_recursive
@hdlfs_api(method='get', operation='LISTSTATUS_RECURSIVE')
def list_path_recursive(endpoint: str,
certificate: str,
password: str,
path='',
start_after=None,
headers={},
verify=True) -> dict
Get all items of folder and sub-folders by using LISTSTATUS_RECURSIVE-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystorepath
: path to source filestart_after
: API parameter for paging resultheaders
: Passing optional parameter to APIverify
: Enables/ disables server verification
Returns:
response
whoami
@hdlfs_api(method='get', operation='WHOAMI')
def whoami(endpoint: str, certificate: str, password: str, verify=True)
Get user information by WHOAMI-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystoreverify
: Enables/ disables server verification
Returns:
response
get_operations_status
@hdlfs_api(method='get', operation='GETOPERATIONSTATUS')
def get_operations_status(endpoint: str,
certificate: str,
password: str,
token='',
verify=True) -> dict
Get operation status by GETOPERATIONSTATUS-API
Arguments:
endpoint
: endpoint urlcertificate
: filename with path to certificate or pkcs12-keystorepassword
: filename with path to key or passphrase for keystoreverify
: Enables/ disables server verification
Returns:
response
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.