Skip to content

Latest commit

 

History

History
135 lines (99 loc) · 4.3 KB

File metadata and controls

135 lines (99 loc) · 4.3 KB

Etpclient

==========

License Documentation Status Python CI Python version PyPI Status codecov

Installation :

Poetry is required to use the client. Poetry documentation

poetry update
poetry install

Connection to a server :

You must fill a configuration file (see. config/sample.yml):

url: wss://XXX
port: 80
username: XXX
password: XXX
additional-headers:
  - data-partition-id: osdu

token-url: https://XXX
token-grant-type: client_credentials
token-scope: openid profile email
token-refresh_token: XXX

Then you must set an environment variable to refer it : INI_FILE_PATH. Or you can fill a .env file :

INI_FILE_PATH=config/sample.yml
CLIENT_ID=XXX
CLIENT_SECRET=XXX

Sample commands :

Interactive client :

poetry run client

Run a specific script (here download_xmls that downloads all xml from a server) :

poetry run script download_xmls

Run a pre-written script :

poetry run file_script .\script_sample.txt

Example of a script file :

getresources eml:///

# a commented line, a line starting with a '#' will not be executed

getdataspaces

quit

ETP supported commands :

When the interactive client is connected you can send your request (this commands are the same for the script files).

This is the help menu :

[XXX] : replace XXX with your value
[XXX=Y] : replace XXX with your value, default is Y
[[XXX]] : optional parameter

[URI] for dataspaces can sometimes be set as "eml:///dataspace('DATASPACE_NAME')" but also with only the DATASPACE_NAME.

    Help : show this menu

    Quit : hard quit (no CloseSession sent)
    CloseSession : close this session

    Authorize             [ [TOKEN] | ( [USERNAME] [PASSWORD]) ]
    RequestSession

    GetDataArrayMetadata  [URI] [PATH_IN_RESOURCE]
    GetDataArray          [URI] [PATH_IN_RESOURCE]
    GetDataSubArray       [URI] [PATH_IN_RESOURCE] [START] [COUNT]
    PutDataArray          [DATASPACE_NAME] [EPC_FILE_PATH] [H5_FILE_PATH] [[UUIDS]]*
    PutDataArray_filter   [DATASPACE_NAME] [EPC_FILE_PATH] [H5_FILE_PATH] [[REGEX_TYPE_FILTER]]

    GetDataObject         [URI_1] [...] [URI_N]
    DeleteDataObjects     [URI_1] [...] [URI_N]
    PutDataObject         [FILE_PATH] [[DATASPACE_NAME]] [[UUIDS]]*

    GetResources          [[uri=eml:/// or notUri=DataspaceName]] [[depth=1]] [[SCOPE]]
    GetDeletedResources   [[uri=eml:/// or notUri=DataspaceName]] [[DELETE_TIME_FILTER]] [[DATA_OBJECT_TYPES]]*

    GetDataspaces
    PutDataspace          [NAME]
    DeleteDataspace       [NAME]*

    Download              [OUTPUT_FILE_PATH] [DATASPACE_NAME]
    DownloadObject        [OUTPUT_FOLDER_PATH] [URI]

    GetSupportedTypes     [URI] [[COUNT=True]] [[RETURN_EMPTY_TYPES=True]] [[SCOPE=Self]]

Configuration

It is possible to change the "capabilities" of your client in the prefilled RequestSession object in etpclient/etp/requester.py

To add/remove supported protocols and request, modify the file etpclient/etp/serverprotocols.py. Do not forget to decorate your protocols to allow the class ETPConnection to use your protocol. Example :

@ETPConnection.on(CommunicationProtocol.CORE)
class myCoreProtocol(CoreHandler):
    ...