def cmd_handler_application_key(args) -> int: """prints path of private key file Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() keypath = api.application_getprivatekey(args.application_id) logging.info(keypath) return 0
def cmd_handler_application_composefile(args) -> int: """Returns docker compose file for a specific application configuration Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() composefile = api.application_getdocker_composefile( args.application_id, args.configuration) logging.info(composefile) return 0
def cmd_handler_application_stop(args) -> int: """Stops the container for a specific configuration of the app on a selected device Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() container = api.application_stop(args.application_id, args.configuration, args.device_id) return 0
def cmd_handler_application_reseal(args) -> int: """removes keys and ids from configuration Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() api.application_reseal(args.application_id) logging.warning( "Application has been resealed. It should not be used for any further operation, otherwise keys will be regenerated." ) return 0
def cmd_handler_load(args) -> int: """Loads an existing application configuration Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() # the api requires absolute paths path = os.path.abspath(args.path) application = api.applications_load(path) logging.info("%s", application.id) return 0
def cmd_handler_application_build(args) -> int: """Build the container for a specific configuration of the app Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) logging.info("Building application, this may take a few minutes...") api.application_build(args.application_id, args.configuration, progress_id=progress_id) logging.info("Application %s successfully built.", args.application_id) return 0
def cmd_handler_application_info(args) -> int: """dumps application info Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() application = api.application_get(args.application_id) logging.info( tabulate.tabulate( generate_prop_list(application), headers=["Property", "Value"], tablefmt="plain", )) return 0
def cmd_handler_application_updatesdk(args) -> int: """Updates an application SDK Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) logging.info("Updating SDK, this may require a few minutes...") api.application_updatesdk(args.application_id, args.configuration, progress_id=progress_id) logging.info("SDK for application %s successfully updated.", args.application_id) return 0
def cmd_handler_create(args) -> int: """Creates a new application Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() # the api requires absolute paths path = os.path.abspath(args.path) application = api.applications_create(args.platform_id, path, username=args.username) logging.info("%s", application.id) return 0
def cmd_handler_application_run(args) -> int: """Run the container for a specific configuration of the app on a selected device Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) logging.info("Starting application...") container = api.application_run(args.application_id, args.configuration, args.device_id, progress_id=progress_id) logging.info("Started container %s", container.id) return 0
def cmd_handler_application_deploy(args) -> int: """Deploy the container for a specific configuration of the app to a selected device Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) logging.info("Deploying application, this may take a few minutes...") api.application_deploy(args.application_id, args.configuration, args.device_id, progress_id=progress_id) logging.info("Application %s successfully deployed.", args.application_id) return 0
def cmd_handler_application_push(args) -> int: """Pushes the required container to a docker registry Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) composefile = api.application_push_to_registry( args.application_id, args.configuration, args.username, args.password, progress_id=progress_id, ) logging.info(composefile) return 0
def cmd_handler_application_sync(args) -> int: """transfer files into the application container Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) api.application_syncfolders( args.application_id, args.source_folder, args.configuration, args.device_id, args.destination_folder, source_is_sdk=args.source_is_sdk, progress_id=progress_id, ) return 0
def cmd_handler_application_runsdk(args) -> int: """Runs the SDK container for an application Arguments: args {[type]} -- command line arguments Returns: int -- 0 for success """ api = moses_client.ApplicationsApi() progress_id = handle_progress(args) sdkaddress = api.application_runsdk(args.application_id, args.configuration, progress_id=progress_id) logging.info( tabulate.tabulate( generate_prop_list(sdkaddress), headers=["Property", "Value"], tablefmt="plain", )) return 0