def script_catalog(): # noqa: E501 """Retrieve the script catalog Retrieve the script catalog # noqa: E501 :rtype: Response """ if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() return Response(status=200, body=driver.getScriptsCatalog())
def get_script(name=None): # noqa: E501 """Retrieve the contents of a script Retrieve the contents of a script # noqa: E501 :param name: The script name. :type name: str :rtype: Response """ if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() return Response(status=200, body=driver.readScript(name))
def driver_status(name): # noqa: E501 """Retrieve the status of a loaded driver Retrieve the status of a loaded driver # noqa: E501 :param name: Get status of a driver with this name :type name: str :rtype: Response """ if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() body = {"name": str(driver.__class__.__name__)} body.update(driver.serialize()) return Response(status=200, body=body)
def delete_script(delete=None): # noqa: E501 """Delete a script Delete a script # noqa: E501 :param delete: The data needed to delete this script :type delete: dict | bytes :rtype: Response """ if connexion.request.is_json: delete = Delete.from_dict(connexion.request.get_json()) # noqa: E501 if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() driver.deleteScript(delete.script.name) return Response(status=200, body={})
def create_script(create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param Scripts: The data needed to create this script :type Scripts: dict | bytes :rtype: Response """ if connexion.request.is_json: create = Create.from_dict(connexion.request.get_json()) # noqa: E501 if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() driver.saveScript(create.script.name, create.script.content) return Response(status=200, body={'file-name': create.script.name})
def rename_script(rename=None): # noqa: E501 """Rename a script Rename a script # noqa: E501 :param rename: The data needed to save this script :type rename: dict | bytes :rtype: Response """ if connexion.request.is_json: rename = Rename.from_dict(connexion.request.get_json()) # noqa: E501 if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() if (not driver.renameScript(rename.original.name, rename.new.name)): return ErrorResponse(status=500, message='Cannot rename to an existing file.') return Response(status=200, body={'file-name': rename.new.name})
def endpoint_catalog(catalog=None): # noqa: E501 """Retrieve the endpoint catalog Retrieve the endpoint catalog # noqa: E501 :param catalog: The data needed to get a catalog :type catalog: dict | bytes :rtype: Response """ if connexion.request.is_json: catalog = UserAuth.from_dict( connexion.request.get_json()) # noqa: E501 if (not hasAccess()): return redirectUnauthorized() driver = LoadedDrivers.getDefaultDriver() auth = None if (catalog): auth = catalog return Response(status=200, body=driver.getCatalog(auth))