23 lines
976 B
Python
23 lines
976 B
Python
from argparse import Namespace, _SubParsersAction
|
|
|
|
from mdrsclient.api import FolderApi
|
|
from mdrsclient.commands.base import BaseCommand
|
|
|
|
|
|
class MetadataCommand(BaseCommand):
|
|
@classmethod
|
|
def register(cls, parsers: _SubParsersAction) -> None:
|
|
command = cls()
|
|
metadata_parser = parsers.add_parser("metadata", help="get a folder metadata")
|
|
metadata_parser.add_argument("remote_path", help="remote folder path (remote:/lab/path/)")
|
|
metadata_parser.set_defaults(func=command.metadata)
|
|
|
|
def metadata(self, args: Namespace) -> None:
|
|
(remote, laboratory_name, r_path) = self._parse_remote_host_with_path(args.remote_path)
|
|
connection = self._create_connection(remote)
|
|
laboratory = self._find_laboratory(connection, laboratory_name)
|
|
folder = self._find_folder(connection, laboratory, r_path)
|
|
folder_api = FolderApi(connection)
|
|
metadata = folder_api.metadata(folder.id)
|
|
print(metadata)
|