コード例 #1
0
    def post():
        request_schema = api.GCGAPIOpts()

        # Extract Header Info
        AWS_ACCESS_KEY = request.headers['X-Api-Key']
        AWS_SECRET_KEY = request.headers['X-Api-Secret']
        USER_AGENT = request.headers['User-Agent']

        # Extracts URL params
        url_params = request.args

        return_type = url_params.get("return_type", "json")
        store_aws = bool(strtobool(url_params.get("store_aws", 'false')))
        template_type = url_params.get("template_type")
        name = url_params.get(
            "name",
            f'GCG_API_{str(datetime.now().strftime("%m_%d_%Y_%H_%M_%S"))}')
        lab_name = url_params.get(
            "lab_name", f'GCG_API_{str(datetime.now().strftime("%m_%d_%Y"))}')

        # Extracts JSON Body

        json_data = request.json

        # Generate Config
        try:
            result = controller_gcg_v2(
                data=json_data,
                store_aws=store_aws,
                store_local=False,
                template_type=template_type,
                lab_name=lab_name,
                name=name,
            )

            if isinstance(result, ControllerResult):
                if return_type == "text":
                    return make_text_response(data=result.data,
                                              msg="Success",
                                              status_code=http_status_codes.OK)
                else:
                    return make_json_response(data=result.data,
                                              msg="Success",
                                              status_code=http_status_codes.OK)
            else:
                return

        except GCGValidationError as err:
            return make_json_response(data={},
                                      msg=f"Validation Error: {str(err)}",
                                      status_code=http_status_codes.CONFLICT)
コード例 #2
0
def health_v2():
    return make_json_response(
        data={
            # "cpu_used_percent": psutil.cpu_percent(),
            # "ram_used_percent": psutil.virtual_memory().percent,
            # "ram_avail_percent": psutil.virtual_memory().available * 100 / psutil.virtual_memory().total,
        },
        msg="System is Healthy",
        status_code=http_status_codes.OK)
コード例 #3
0
def api_register():
    # TODO: Implement logic for registering users that will utilize the API.
    return make_json_response(data={},
                              msg="Not Implemented",
                              status=http_status_codes.NOT_IMPLEMENTED)
コード例 #4
0
def api_logout():
    # TODO: Implement logic for logging the requester out.
    return make_json_response(data={},
                              msg="Not Implemented",
                              status=http_status_codes.NOT_IMPLEMENTED)
コード例 #5
0
def api_login():
    # TODO: Implement login logic, return JWT token to requester.
    return make_json_response(data=jsonify({"token": None}),
                              msg="Not Implemented",
                              status=http_status_codes.NOT_IMPLEMENTED)