Example #1
0
 def get(self):
     """
     Get information about all jobs.
     """
     auth_token = get_bearer_token()
     user_id = User.decode_auth_token(auth_token)
     return JobService.get_jobs_by_user_id(user_id)
Example #2
0
 def get(self):
     """
     Get all scripts.
     """
     auth_token = get_bearer_token()
     user_id = User.decode_auth_token(auth_token)
     return ScriptService.get_all_by_user(user_id)
Example #3
0
    def get(self, job_id: str):
        """
        Get information about the given job ID.
        """
        auth_token = get_bearer_token()
        user_id = User.decode_auth_token(auth_token)

        return JobService.get_job_by_id(job_id=job_id, user_id=user_id)
Example #4
0
 def post(self, script_name: str):
     """
     Execute a given script. Accepts an arbitrary JSON object
     """
     auth_token = get_bearer_token()
     user_id = User.decode_auth_token(auth_token)
     return ScriptService.execute(user_id,
                                  script_name,
                                  placeholder_dict=request.get_json())
Example #5
0
 def post(self):
     """
     Log yourself out.
     """
     auth_token = get_bearer_token()
     UserService.logout_user(auth_token)
     return {
         "message": "Successfully logged out",
         "auth_token": auth_token
     }, 200
Example #6
0
    def post(self):
        """
        Register a script with the backend.
        """
        auth_token = get_bearer_token()

        user_id = User.decode_auth_token(auth_token)
        script_obj = request.parsed_obj
        script_obj["user"] = user_id

        return ScriptService.create(script_obj)
Example #7
0
    def delete(self, script_name: str):
        """
        Delete the script.
        """
        version = request.args.get("version")
        delete_all = request.args.get("delete_all")
        if (version is not None) and (delete_all is not None):
            raise UserException(
                "Please specify only one of `version` or `delete_all`.", 400)

        auth_token = get_bearer_token()
        user_id = User.decode_auth_token(auth_token)
        return ScriptService.delete(user_id,
                                    script_name,
                                    version=version,
                                    delete_all=delete_all)
Example #8
0
 def get(self, script_name: str):
     auth_token = get_bearer_token()
     user_id = User.decode_auth_token(auth_token)
     return ScriptService.get_script_by_user_and_name(
         user_id, script_name, version=request.args.get("version"))