{"openapi":"3.0.0","info":{"title":"AI_Protect","description":"Development of AI-based Network Security System","version":"1.0.0"},"servers":[{"description":"SwaggerHub API Auto Mocking","url":"https://virtserver.swaggerhub.com/pknu/A_P/1.0.0"},{"description":"SwaggerHub API Auto Mocking","url":"https://app.swaggerhub.com/apis/pknu/A_P/1.0.0"}],"paths":{"/":{"get":{"tags":["Root"],"summary":"Read Root","description":"System health check endpoint.","operationId":"read_root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"healthy"}}}}}}}}},"/auth/signup":{"post":{"tags":["Authentication"],"summary":"Signup","operationId":"signup_auth_signup_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCreate"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/login":{"post":{"tags":["Authentication"],"summary":"Login","operationId":"login_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserLogin"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/logout":{"post":{"tags":["Authentication"],"summary":"Logout","operationId":"logout_auth_logout_post","responses":{"204":{"description":"Successful Response"}}}},"/auth/mypage":{"get":{"tags":["Authentication"],"summary":"Get User Me","operationId":"get_user_me_auth_mypage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}}}}},"/auth/withdrawal":{"delete":{"tags":["Authentication"],"summary":"Withdraw User","operationId":"withdraw_user_auth_withdrawal_delete","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDelete"}}},"required":true},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/forgot-password":{"post":{"tags":["Authentication"],"summary":"Forgot Password","operationId":"forgot_password_auth_forgot_password_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordResetResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/reset-password":{"post":{"tags":["Authentication"],"summary":"Reset Password Confirm","operationId":"reset_password_confirm_auth_reset_password_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/change-password":{"put":{"tags":["Authentication"],"summary":"Change Password","operationId":"change_password_auth_change_password_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordChangeRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/verify-password":{"post":{"tags":["Authentication"],"summary":"Verify User Password","operationId":"verify_user_password_auth_verify_password_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordVerifyRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"valid":{"type":"boolean"},"message":{"type":"string"}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/users/me":{"get":{"tags":["Users"],"summary":"Get Current User Info","description":"Retrieves detailed information for the currently logged-in user.","operationId":"read_users_me_users_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}}}},"put":{"tags":["Users"],"summary":"Update Current User Info","description":"Updates information for the currently logged-in user. Checks for duplicates if email or employee number is changed.","operationId":"update_users_me_users_me_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserUpdate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/users/me/attacks":{"get":{"tags":["Users"],"summary":"Get Current User's Recent Attacks","description":"Retrieves recent attack data related to the currently logged-in user from Elasticsearch. Searches `attack_detections`, `winlogbeat-raw`, and `packetbeat-raw` indices based on `user_id`.","operationId":"get_my_recent_attacks_users_me_attacks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"attacks":{"type":"array","items":{"$ref":"#/components/schemas/AttackData"}},"total":{"type":"integer"}}}}}}}}},"/api/v1/agent/download":{"get":{"tags":["Agent Management"],"summary":"Download a personalized agent","description":"Creates and downloads a personalized agent installation package for the logged-in user.\n\n**Authentication Required:** This API requires a valid JWT token in the request header as a `Bearer` token.","operationId":"download_agent_package_api_v1_agent_download_get","responses":{"200":{"description":"Successful Response","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v1/agent/latest":{"get":{"tags":["Agent Management"],"summary":"Get Latest Agent Version Info","description":"Returns the latest version information and download URL for the agent.","operationId":"get_latest_agent_version_api_v1_agent_latest_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateInfo"}}}}}}},"/api/ingest/winlogbeat":{"post":{"tags":["Ingestion"],"summary":"Ingest Winlogbeat Log","description":"Receives Winlogbeat logs from an agent and sends them to a Kafka topic.","operationId":"ingest_winlogbeat_log_api_ingest_winlogbeat_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WinlogbeatIngest"}}},"required":true},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IngestionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/ingest/packetbeat":{"post":{"tags":["Ingestion"],"summary":"Ingest Packetbeat Traffic","description":"Receives Packetbeat traffic data from an agent and sends it to a Kafka topic.","operationId":"ingest_packetbeat_traffic_api_ingest_packetbeat_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PacketbeatIngest"}}},"required":true},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IngestionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/statistics/threat-summary":{"get":{"tags":["Statistics"],"summary":"Get Threat Statistics","operationId":"get_threat_statistics_api_statistics_threat_summary_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"total_threats":{"type":"integer"},"threats_by_type":{"type":"object","additionalProperties":{"type":"integer"}},"recent_threats":{"type":"array","items":{"$ref":"#/components/schemas/ThreatSummary"}}}}}}}}}},"/api/statistics/threats":{"get":{"tags":["Statistics"],"summary":"Get Realtime Threat Statistics","description":"Returns statistics on threats detected so far.","operationId":"get_realtime_threat_statistics_api_statistics_threats_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThreatStatResponse"}}}}}}},"/api/remediation/block-ip":{"post":{"tags":["Remediation"],"summary":"Block IP","operationId":"block_ip_api_remediation_block_ip_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemediationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/remediation/quarantine-host":{"post":{"tags":["Remediation"],"summary":"Quarantine Host","operationId":"quarantine_host_api_remediation_quarantine_host_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HostRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemediationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/remediation/block-port":{"post":{"tags":["Remediation"],"summary":"Block Port","operationId":"block_port_api_remediation_block_port_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemediationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/logs":{"post":{"tags":["Ingestion"],"summary":"Receive Log","operationId":"receive_log_api_logs_post","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"log_type":{"type":"string","enum":["winlogbeat","packetbeat","generic"]},"data":{"type":"object"},"timestamp":{"type":"string","format":"date-time"}},"required":["log_type","data"]}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IngestionResponse"}}}}}}},"/api/internal/alert":{"post":{"tags":["Internal Notifier"],"summary":"Trigger User Alert","description":"Receives an alert request from an internal monitoring system for a specific user, creates an incident report in the DB, and dispatches the notification.","operationId":"trigger_user_alert_api_internal_alert_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertPayload"}}},"required":true},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"accepted"},"message":{"type":"string","example":"Alert processed successfully"}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/analysis/ask":{"post":{"tags":["Analysis Q&A"],"summary":"Ask Question","description":"Routes a user's question, executes expert tools, and processes the final result.","operationId":"ask_question_api_analysis_ask_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuestionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"answer":{"type":"string"},"analysis_data":{"type":"object"},"timestamp":{"type":"string","format":"date-time"}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/dashboard/traffic/stats":{"get":{"tags":["Dashboard"],"summary":"Get Traffic Stats","operationId":"get_stats_api_dashboard_traffic_stats_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"total_connections":{"type":"integer"},"bytes_transferred":{"type":"integer"},"packets_count":{"type":"integer"},"active_connections":{"type":"integer"}}}}}}}}},"/api/dashboard/traffic/traffic-over-time":{"get":{"tags":["Dashboard"],"summary":"Get Traffic Chart","operationId":"get_traffic_chart_api_dashboard_traffic_traffic_over_time_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"timestamps":{"type":"array","items":{"type":"string","format":"date-time"}},"values":{"type":"array","items":{"type":"integer"}}}}}}}}}},"/api/dashboard/traffic/top-ports":{"get":{"tags":["Dashboard"],"summary":"Get Top Ports Chart","operationId":"get_top_ports_chart_api_dashboard_traffic_top_ports_get","parameters":[{"name":"minutes","in":"query","required":false,"schema":{"type":"integer","default":5,"title":"Minutes"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"ports":{"type":"array","items":{"type":"object","properties":{"port":{"type":"integer"},"count":{"type":"integer"},"percentage":{"type":"number","format":"float"}}}}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/dashboard/traffic/attacks":{"get":{"tags":["Dashboard"],"summary":"Get Attacks List","operationId":"get_attacks_list_api_dashboard_traffic_attacks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"attacks":{"type":"array","items":{"$ref":"#/components/schemas/AttackData"}},"total":{"type":"integer"}}}}}}}}},"/api/dashboard/logs/stats":{"get":{"tags":["Dashboard"],"summary":"Get Log Summary","description":"Returns total detected threats, most frequent threats, and distribution by threat type.","operationId":"get_log_summary_api_dashboard_logs_stats_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"total_threats":{"type":"integer"},"most_frequent_threats":{"type":"array","items":{"$ref":"#/components/schemas/ThreatSummary"}},"threat_distribution":{"type":"object","additionalProperties":{"type":"integer"}}}}}}}}}},"/api/dashboard/logs/count-24h":{"get":{"tags":["Dashboard"],"summary":"Get Log Count 24H","description":"Returns the number of logs collected in the last 24 hours.","operationId":"get_log_count_24h_api_dashboard_logs_count_24h_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer"},"period":{"type":"string","example":"24h"}}}}}}}}},"/api/dashboard/logs/list":{"get":{"tags":["Dashboard"],"summary":"Get Threats Log List","description":"Retrieves the latest threat logs with pagination.","operationId":"get_threats_log_list_api_dashboard_logs_list_get","parameters":[{"name":"skip","in":"query","required":false,"schema":{"type":"integer","default":0,"title":"Skip"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":100,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"logs":{"type":"array","items":{"$ref":"#/components/schemas/ThreatLog"}},"total":{"type":"integer"},"skip":{"type":"integer"},"limit":{"type":"integer"}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/{path}":{"options":{"summary":"Options Handler","operationId":"options_handler__path__options","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{"allowed_methods":{"type":"array","items":{"type":"string"}},"headers":{"type":"object"}}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AlertPayload":{"properties":{"user_id":{"type":"string","title":"User Id"},"attack_type":{"type":"string","title":"Attack Type"},"message":{"type":"string","title":"Message"},"source_ip":{"type":"string","nullable":true,"title":"Source Ip"},"attack_source_table":{"type":"string","title":"Attack Source Table"},"attack_record_id":{"type":"integer","title":"Attack Record Id"}},"type":"object","required":["user_id","attack_type","message","attack_source_table","attack_record_id"],"title":"AlertPayload"},"AttackData":{"type":"object","properties":{"attack_id":{"type":"string"},"attack_type":{"type":"string"},"source_ip":{"type":"string"},"target_ip":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"severity":{"type":"string","enum":["low","medium","high","critical"]},"status":{"type":"string","enum":["detected","analyzing","blocked","resolved"]}},"required":["attack_id","attack_type","timestamp","severity","status"]},"QuestionRequest":{"properties":{"question":{"type":"string","title":"Question"}},"type":"object","required":["question"],"title":"QuestionRequest"},"UpdateInfo":{"type":"object","required":["version","download_url"],"properties":{"version":{"type":"string","title":"Version"},"download_url":{"type":"string","title":"Download Url"}},"title":"UpdateInfo"},"ForgotPasswordRequest":{"properties":{"email":{"type":"string","format":"email","title":"Email"}},"type":"object","required":["email"],"title":"ForgotPasswordRequest"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"PasswordChangeRequest":{"properties":{"current_password":{"type":"string","title":"Current Password"},"new_password":{"type":"string","title":"New Password"},"confirm_password":{"type":"string","title":"Confirm Password"}},"type":"object","required":["current_password","new_password","confirm_password"],"title":"PasswordChangeRequest"},"PasswordResetResponse":{"properties":{"message":{"type":"string","title":"Message"},"detail":{"type":"string","nullable":true,"title":"Detail"}},"type":"object","required":["message"],"title":"PasswordResetResponse"},"PasswordVerifyRequest":{"properties":{"password":{"type":"string","title":"Password"}},"type":"object","required":["password"],"title":"PasswordVerifyRequest"},"RemediationResponse":{"properties":{"success":{"type":"boolean"},"message":{"type":"string"},"action_id":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}},"type":"object","required":["success","message"],"title":"RemediationResponse"},"ResetPasswordRequest":{"properties":{"token":{"type":"string","title":"Token"},"new_password":{"type":"string","title":"New Password"}},"type":"object","required":["token","new_password"],"title":"ResetPasswordRequest"},"ThreatLog":{"properties":{"log_id":{"type":"string"},"threat_type":{"type":"string"},"source_ip":{"type":"string"},"target_ip":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"severity":{"type":"string","enum":["low","medium","high","critical"]},"details":{"type":"object"}},"type":"object","required":["log_id","threat_type","timestamp","severity"],"title":"ThreatLog"},"ThreatSummary":{"properties":{"threat_type":{"type":"string"},"count":{"type":"integer"},"last_seen":{"type":"string","format":"date-time"},"severity":{"type":"string","enum":["low","medium","high","critical"]}},"type":"object","required":["threat_type","count","last_seen","severity"],"title":"ThreatSummary"},"Token":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"}},"type":"object","required":["access_token"],"title":"Token"},"UserCreate":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","title":"Password"},"name":{"type":"string","title":"Name"},"phone":{"type":"string","title":"Phone"},"empNumber":{"type":"string","title":"Empnumber"}},"type":"object","required":["email","password","name","phone","empNumber"],"title":"UserCreate"},"UserDelete":{"properties":{"password":{"type":"string","title":"Password"}},"type":"object","required":["password"],"title":"UserDelete"},"UserLogin":{"properties":{"emp_number":{"type":"string","title":"Emp Number"},"password":{"type":"string","title":"Password"}},"type":"object","required":["emp_number","password"],"title":"UserLogin"},"UserResponse":{"properties":{"user_id":{"type":"string","format":"uuid","title":"User Id"},"emp_number":{"type":"string","title":"Emp Number"},"email":{"type":"string","format":"email","title":"Email"},"name":{"type":"string","title":"Name"},"phone":{"type":"string","title":"Phone"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"is_deleted":{"type":"boolean","title":"Is Deleted"}},"type":"object","required":["user_id","emp_number","email","name","phone","created_at","is_deleted"],"title":"UserResponse"},"UserUpdate":{"properties":{"name":{"type":"string","nullable":true,"title":"Name"},"email":{"type":"string","format":"email","nullable":true,"title":"Email"},"password":{"type":"string","nullable":true,"title":"Password"},"phone":{"type":"string","nullable":true,"title":"Phone"},"emp_number":{"type":"string","nullable":true,"title":"Emp Number"}},"type":"object","title":"UserUpdate"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"HostRequest":{"properties":{"hostname":{"type":"string","title":"Hostname"}},"type":"object","required":["hostname"],"title":"HostRequest"},"IPRequest":{"properties":{"ip":{"type":"string","title":"Ip"}},"type":"object","required":["ip"],"title":"IPRequest"},"PortRequest":{"properties":{"port":{"type":"integer","title":"Port"}},"type":"object","required":["port"],"title":"PortRequest"},"IngestionResponse":{"properties":{"status":{"type":"string","title":"Status"},"message":{"type":"string","title":"Message"}},"type":"object","required":["status","message"],"title":"IngestionResponse"},"PacketbeatIngest":{"properties":{"agent_id":{"type":"string","title":"Agent Id","description":"The unique ID of the agent sending the log."}}}}}}