{
  "openapi": "3.1.0",
  "info": {
    "title": "Amethyst Cloud Storage API",
    "summary": "Yüksek Performanslı Kurumsal Bulut Depolama & WebDAV Ağ Geçidi",
    "description": "Amethyst Cloud Storage; Apache OpenDAL, Java 21 Sanal İş Parçacıkları (Virtual Threads), Keycloak IAM ve SeaweedFS/S3 nesne depolama motoru üzerine inşa edilmiş modern, güvenli ve yüksek hızlı bir bulut depolama platformudur.\n\n## 🔐 Kimlik Doğrulama (Authentication)\n- **Bearer JWT:** `Authorization: Bearer <token>` başlığı ile.\n- **HttpOnly Cookie:** Web oturumları için `amethyst_token` çerezi ile.\n- **Basic Auth:** Standart WebDAV istemcileri (Finder, Windows Explorer, Cyberduck) için `Authorization: Basic <base64>`.\n\n## 📡 Canlı Olay Akışı (SSE)\n`/api/events/stream` uç noktası üzerinden Server-Sent Events (SSE) ile gerçek zamanlı dosya hareketleri, sohbet mesajları ve bildirimler yayınlanır.",
    "version": "1.0.0",
    "contact": {
      "name": "Amethyst Cloud Engineering",
      "url": "https://github.com/example/opendal-webdav-share"
    },
    "license": {
      "name": "Apache-2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "Mevcut Sunucu Ağ Geçidi"
    },
    {
      "url": "http://localhost:8080",
      "description": "Yerel Geliştirme Ortamı"
    }
  ],
  "tags": [
    { "name": "Auth", "description": "Kimlik doğrulama, oturum ve kullanıcı durumu" },
    { "name": "Files & Storage", "description": "Dosya listeleme, içerik okuma, klasör oluşturma, taşıma ve versiyonlama" },
    { "name": "Archive Inspector", "description": "Sıfır RAM/Disk ile HTTP Range Request ZIP/JAR arşiv inceleme" },
    { "name": "Chat & Events", "description": "Depo bazlı canlı sohbet ve Server-Sent Events (SSE) yayınları" },
    { "name": "Notifications", "description": "Kullanıcı bildirimleri ve dosya sahiplik uyarıları" },
    { "name": "Support Tickets", "description": "Kullanıcı ve yönetici destek talebi yönetimi" },
    { "name": "Admin Management", "description": "Yöneticiye özel kullanıcı, depo, log ve arşiv rotasyonu" },
    { "name": "WebDAV Protocol", "description": "RFC 4918 uyumlu WebDAV dosya sistemi protokol metodları" }
  ],
  "paths": {
    "/api/login": {
      "post": {
        "tags": ["Auth"],
        "summary": "Kullanıcı Girişi",
        "description": "Kullanıcı adı ve şifre ile Keycloak üzerinden kimlik doğrulaması yapar, JWT token ve HttpOnly Secure çerez üretir.",
        "operationId": "login",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/LoginRequest" },
              "examples": {
                "admin": {
                  "summary": "Yönetici Girişi",
                  "value": { "username": "admin", "password": "securepassword123" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Giriş başarılı",
            "headers": {
              "Set-Cookie": {
                "description": "HttpOnly, SameSite=Lax, Secure amethyst_token çerezi",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/LoginResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": {
            "description": "Hesap Brute-force koruması nedeniyle kilitlendi",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/logout": {
      "post": {
        "tags": ["Auth"],
        "summary": "Kullanıcı Çıkışı",
        "description": "Aktif oturumu sonlandırır, Keycloak oturumlarını kapatır ve tarayıcı çerezini temizler.",
        "operationId": "logout",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Başarıyla çıkış yapıldı",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/auth/status": {
      "get": {
        "tags": ["Auth"],
        "summary": "Oturum ve Yetki Durumu",
        "description": "Aktif istemcinin oturum açıp açmadığını ve kullanıcı rolünü (ADMIN/USER) döner. 401 fırlatmaz, anonim durumda `authenticated: false` döner.",
        "operationId": "getAuthStatus",
        "responses": {
          "200": {
            "description": "Oturum durumu",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuthStatusResponse" }
              }
            }
          }
        }
      }
    },
    "/api/storages": {
      "get": {
        "tags": ["Files & Storage"],
        "summary": "Erişilebilir Depoları Listele",
        "description": "Oturum açmış kullanıcının erişim hakkına sahip olduğu sanal depolama alanlarını listeler.",
        "operationId": "getUserStorages",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Depo listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/StorageInfo" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/files": {
      "get": {
        "tags": ["Files & Storage"],
        "summary": "Dizin ve Dosyaları Listele",
        "description": "Belirtilen dizin altındaki dosyaları, klasörleri, dosya boyutlarını ve versiyon durumlarını sanal iş parçacıklarıyla asenkron ve paralel olarak döner.",
        "operationId": "getFiles",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          {
            "name": "dir",
            "in": "query",
            "description": "Listelenecek dizin yolu (örn: `documents/reports`)",
            "required": false,
            "schema": { "type": "string", "default": "" }
          },
          {
            "name": "storageId",
            "in": "query",
            "description": "Hedef depolama alanı kimliği (`default`, `backup` vb.)",
            "required": false,
            "schema": { "type": "string", "default": "default" }
          }
        ],
        "responses": {
          "200": {
            "description": "Dosya listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/FileItem" }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/files/content": {
      "get": {
        "tags": ["Files & Storage"],
        "summary": "Metin/Kod Dosyası İçeriğini Oku",
        "description": "Düzenlenebilir metin, kod, konfigürasyon veya markdown dosyalarının UTF-8 içeriğini döner.",
        "operationId": "getFileContent",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "Okunacak dosyanın göreceli yolu",
            "schema": { "type": "string" }
          },
          {
            "name": "storageId",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "default": "default" }
          }
        ],
        "responses": {
          "200": {
            "description": "Dosya içeriği",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "content": { "type": "string", "example": "# Proje Dokümanı\nİçerik buradadır." }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/mkdir": {
      "post": {
        "tags": ["Files & Storage"],
        "summary": "Yeni Klasör Oluştur",
        "description": "Hedef dizin altında yeni bir alt klasör oluşturur ve SSE ile tüm istemcilere bildirir.",
        "operationId": "createFolder",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["folderName"],
                "properties": {
                  "dir": { "type": "string", "example": "projeler/" },
                  "folderName": { "type": "string", "example": "yeni_klasor" },
                  "storageId": { "type": "string", "example": "default" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "$ref": "#/components/responses/Created" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "409": { "$ref": "#/components/responses/Conflict" }
        }
      }
    },
    "/api/rename": {
      "post": {
        "tags": ["Files & Storage"],
        "summary": "Dosya/Klasör Yeniden Adlandır",
        "description": "Mevcut dosya veya dizini yeni isim veya konuma taşır.",
        "operationId": "renameFile",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["oldPath", "newPath"],
                "properties": {
                  "oldPath": { "type": "string", "example": "rapor_eski.pdf" },
                  "newPath": { "type": "string", "example": "rapor_2026.pdf" },
                  "storageId": { "type": "string", "example": "default" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dosya adı başarıyla değiştirildi",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          },
          "400": {
            "description": "Eski veya yeni dosya adı geçersiz ya da JSON formatı hatalı",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiResponse" },
                "example": { "status": "error", "message": "Eski veya yeni dosya adı geçersiz!" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": {
            "description": "Bu depoya erişim yetkiniz yok veya sistem dosyaları korumalı",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiResponse" },
                "example": { "status": "error", "message": "Bu depoya erişim yetkiniz bulunmamaktadır." }
              }
            }
          },
          "404": {
            "description": "Yeniden adlandırılacak kaynak dosya bulunamadı",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiResponse" },
                "example": { "status": "error", "message": "Yeniden adlandırılacak kaynak dosya bulunamadı: rapor_eski.pdf" }
              }
            }
          },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/batch-move": {
      "post": {
        "tags": ["Files & Storage"],
        "summary": "Toplu Dosya & Depolar Arası Taşıma",
        "description": "Birden çok dosyayı aynı depo veya farklı depolama alanları arasında topluca taşır.",
        "operationId": "batchMove",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["files", "targetDir"],
                "properties": {
                  "files": {
                    "type": "array",
                    "items": { "type": "string" },
                    "example": ["doc1.pdf", "resim.png", "klasor/"]
                  },
                  "targetDir": { "type": "string", "example": "arsiv/" },
                  "sourceStorageId": { "type": "string", "example": "default" },
                  "targetStorageId": { "type": "string", "example": "backup" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Taşıma işlemi tamamlandı (Tam başarı veya kısmi başarı)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/BatchMoveResponse" },
                "examples": {
                  "success": {
                    "summary": "Tüm Dosyalar Başarıyla Taşındı",
                    "value": {
                      "status": "success",
                      "message": "3 adet öğe başarıyla taşındı."
                    }
                  },
                  "partial": {
                    "summary": "Kısmi Başarı (Bazı Dosyalar Taşınamadı)",
                    "value": {
                      "status": "partial_success",
                      "message": "2 adet öğe taşındı, 1 adet öğe taşınamadı.",
                      "movedCount": 2,
                      "failedCount": 1,
                      "failedFiles": ["sistem_korumali.log (Sistem Korumalı)"]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Geçersiz parametreler veya hiçbir dosya taşınamadı",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiResponse" },
                "example": {
                  "status": "error",
                  "message": "Hiçbir dosya taşınamadı! Hatalı dosyalar: bulunamayan_dosya.pdf (Kaynak dosya bulunamadı)"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/diff": {
      "get": {
        "tags": ["Files & Storage"],
        "summary": "Dosya Sürüm Karşılaştırması (Diff)",
        "description": "Dosyanın mevcut sürümü ile önceki versiyonunun farkını (oldContent vs newContent) döner.",
        "operationId": "getFileDiff",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "path", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "storageId", "in": "query", "schema": { "type": "string", "default": "default" } }
        ],
        "responses": {
          "200": {
            "description": "Fark raporu",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "oldContent": { "type": "string" },
                    "newContent": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": {
            "description": "Karşılaştırılacak dosya veya önceki sürümü bulunamadı",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          }
        }
      }
    },
    "/api/restore-version": {
      "post": {
        "tags": ["Files & Storage"],
        "summary": "Önceki Sürümü Geri Yükle",
        "description": "Dosyanın bir önceki versiyonunu aktif dosya olarak geri yükler ve mevcut dosyayı da versiyon havuzuna ekler.",
        "operationId": "restoreVersion",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["path"],
                "properties": {
                  "path": { "type": "string", "example": "config.yml" },
                  "storageId": { "type": "string", "example": "default" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Dosya başarıyla önceki sürüme döndürüldü", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": {
            "description": "Geri yüklenecek versiyon veya dosya bulunamadı",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/archive-inspect": {
      "get": {
        "tags": ["Archive Inspector"],
        "summary": "Sıfır RAM/Disk Arşiv İnceleme",
        "description": "Sunucuya indirmeden ve açmadan, S3 HTTP Range Request (EOCD) ile ZIP/JAR/WAR merkezi fihristini okuyarak içindeki dosya hiyerarşisini listeler.",
        "operationId": "inspectArchive",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "path", "in": "query", "required": true, "description": "Arşiv dosyasının yolu (.zip/.jar/.war)", "schema": { "type": "string" } },
          { "name": "storageId", "in": "query", "schema": { "type": "string", "default": "default" } }
        ],
        "responses": {
          "200": {
            "description": "Arşiv dosya listesi ve metadata",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ArchiveReport" }
              }
            }
          },
          "400": {
            "description": "Desteklenmeyen arşiv formatı veya bozuk arşiv başlığı",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "500": {
            "description": "Arşiv fihristi okunurken S3 HTTP Range Request hatası oluştu",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
          }
        }
      }
    },
    "/api/events/stream": {
      "get": {
        "tags": ["Chat & Events"],
        "summary": "Gerçek Zamanlı SSE Olay Akışı",
        "description": "Server-Sent Events (SSE) bağlantısı açarak dosya değişiklikleri (`MUTATION`), yeni sohbet mesajları (`CHAT`) ve sistem bildirimlerini canlı dinler.",
        "operationId": "getEventStream",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Canlı event akışı",
            "content": {
              "text/event-stream": {
                "schema": { "type": "string", "example": "event: MUTATION\ndata: {\"action\":\"UPLOAD\",\"path\":\"dokuman.pdf\",\"username\":\"admin\"}\n\n" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/chat/messages": {
      "get": {
        "tags": ["Chat & Events"],
        "summary": "Sohbet Mesajlarını Getir",
        "description": "Seçili depolama alanına özel son sohbet mesajlarını listeler.",
        "operationId": "getChatMessages",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "storageId", "in": "query", "schema": { "type": "string", "default": "default" } }
        ],
        "responses": {
          "200": {
            "description": "Mesaj listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/ChatMessage" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      },
      "post": {
        "tags": ["Chat & Events"],
        "summary": "Sohbet Mesajı Gönder (RESTful)",
        "description": "Depolama alanına yeni mesaj gönderir ve SSE ile bağlı tüm istemcilere anlık iletir.",
        "operationId": "sendMessageRestful",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["content"],
                "properties": {
                  "content": { "type": "string", "example": "Yeni sürüm raporları yüklendi." },
                  "storageId": { "type": "string", "example": "default" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Mesaj iletildi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      },
      "delete": {
        "tags": ["Chat & Events"],
        "summary": "Sohbet Geçmişini Temizle (RESTful)",
        "description": "Depolama alanındaki tüm sohbet mesajlarını temizler (Yalnızca Yönetici).",
        "operationId": "clearChatRestful",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "storageId", "in": "query", "schema": { "type": "string", "default": "default" } }
        ],
        "responses": {
          "200": { "description": "Sohbet temizlendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/chat/message": {
      "post": {
        "tags": ["Chat & Events"],
        "summary": "Sohbet Mesajı Gönder (Legacy Alias)",
        "description": "Depolama alanına yeni mesaj gönderir.",
        "operationId": "sendMessage",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["message"],
                "properties": {
                  "message": { "type": "string", "example": "Yeni sürüm raporları yüklendi." },
                  "storageId": { "type": "string", "example": "default" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Mesaj iletildi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/chat/clear": {
      "post": {
        "tags": ["Chat & Events"],
        "summary": "Sohbet Geçmişini Temizle (Legacy Alias)",
        "description": "Depolama alanındaki tüm sohbet mesajlarını temizler.",
        "operationId": "clearChat",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "storageId", "in": "query", "schema": { "type": "string", "default": "default" } }
        ],
        "responses": {
          "200": { "description": "Sohbet temizlendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/notifications": {
      "get": {
        "tags": ["Notifications"],
        "summary": "Kullanıcı Bildirimleri",
        "description": "Oturum açmış kullanıcının sahip olduğu dosyalar üzerindeki değişiklik uyarılarını ve sistem bildirimlerini döner.",
        "operationId": "getNotifications",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Bildirim listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/NotificationItem" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "delete": {
        "tags": ["Notifications"],
        "summary": "Bildirimleri Temizle (RESTful)",
        "description": "Kullanıcının tüm okunmamış bildirimlerini temizler.",
        "operationId": "clearNotificationsRestful",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": { "description": "Bildirimler temizlendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/notifications/clear": {
      "post": {
        "tags": ["Notifications"],
        "summary": "Bildirimleri Temizle (Legacy Alias)",
        "description": "Kullanıcının tüm okunmamış bildirimlerini temizler.",
        "operationId": "clearNotifications",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": { "description": "Bildirimler temizlendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/support/tickets": {
      "get": {
        "tags": ["Support Tickets"],
        "summary": "Destek Taleplerini Listele",
        "description": "Kullanıcı ise kendi taleplerini, ADMIN ise sistemdeki tüm destek biletlerini listeler.",
        "operationId": "getSupportTickets",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Destek talepleri",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/SupportTicket" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "post": {
        "tags": ["Support Tickets"],
        "summary": "Yeni Destek Talebi Aç (RESTful)",
        "description": "Kullanıcının sistem yöneticisine ileteceği yeni bir destek bileti oluşturur.",
        "operationId": "createSupportTicketRestful",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["subject", "message"],
                "properties": {
                  "category": { "type": "string", "example": "GENEL" },
                  "subject": { "type": "string", "example": "Depolama Kotası Artırımı" },
                  "message": { "type": "string", "example": "Yedek depolama alanımızın kotasının yükseltilmesini talep ediyorum." },
                  "priority": { "type": "string", "enum": ["LOW", "MEDIUM", "HIGH"], "default": "MEDIUM" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "$ref": "#/components/responses/Created" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/support/ticket": {
      "post": {
        "tags": ["Support Tickets"],
        "summary": "Yeni Destek Talebi Aç",
        "description": "Kullanıcının sistem yöneticisine ileteceği yeni bir destek bileti oluşturur.",
        "operationId": "createSupportTicket",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["subject", "message"],
                "properties": {
                  "subject": { "type": "string", "example": "Depolama Kotası Artırımı" },
                  "message": { "type": "string", "example": "Yedek depolama alanımızın kotasının yükseltilmesini talep ediyorum." },
                  "priority": { "type": "string", "enum": ["LOW", "MEDIUM", "HIGH"], "default": "MEDIUM" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Talep oluşturuldu", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/support/ticket/reply": {
      "post": {
        "tags": ["Support Tickets"],
        "summary": "Destek Talebine Yanıt Ver",
        "description": "Açılmış olan destek biletine kullanıcı veya yönetici yanıtı ekler.",
        "operationId": "replySupportTicket",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["ticketId", "message"],
                "properties": {
                  "ticketId": { "type": "string", "example": "TCK-4891" },
                  "message": { "type": "string", "example": "Kotanız 50 GB olarak güncellenmiştir." }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Yanıt eklendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/support/ticket/status": {
      "post": {
        "tags": ["Support Tickets"],
        "summary": "Destek Talebi Durumunu Güncelle",
        "description": "Destek biletinin durumunu değiştirir (OPEN, IN_PROGRESS, RESOLVED, CLOSED).",
        "operationId": "updateTicketStatus",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["ticketId", "status"],
                "properties": {
                  "ticketId": { "type": "string", "example": "TCK-4891" },
                  "status": { "type": "string", "enum": ["OPEN", "IN_PROGRESS", "RESOLVED", "CLOSED"], "example": "RESOLVED" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Durum güncellendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/system-metrics": {
      "get": {
        "tags": ["Admin Management"],
        "summary": "Sistem Kaynak Metrikleri (Yalnızca ADMIN)",
        "description": "CPU kullanımı, JVM Bellek (Heap / Non-Heap), Disk doluluğu ve aktif iş parçacığı istatistiklerini döner.",
        "operationId": "getSystemMetrics",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Sistem metrikleri",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SystemMetrics" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/audit/logs": {
      "get": {
        "tags": ["Admin Management"],
        "summary": "Denetim Günlükleri (Audit Logs)",
        "description": "USER yalnızca kendi oturumundaki işlemlerini; ADMIN sistemdeki tüm hareketleri listeler.",
        "operationId": "getAuditLogs",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Denetim günlükleri",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/AuditLogItem" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/admin/users": {
      "get": {
        "tags": ["Admin Management"],
        "summary": "Kullanıcıları Listele (ADMIN)",
        "description": "Keycloak üzerindeki tüm kayıtlı kullanıcıları ve rollerini döner.",
        "operationId": "listUsers",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Kullanıcı listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/User" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      },
      "post": {
        "tags": ["Admin Management"],
        "summary": "Yeni Kullanıcı Oluştur (ADMIN)",
        "description": "Keycloak IAM üzerinde yeni kullanıcı hesabı tanımlar ve rolünü atar.",
        "operationId": "createUser",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["username", "password"],
                "properties": {
                  "username": { "type": "string", "example": "mehmet" },
                  "password": { "type": "string", "example": "GucluSifre2026!" },
                  "role": { "type": "string", "enum": ["USER", "ADMIN"], "default": "USER" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "$ref": "#/components/responses/Created" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "409": { "$ref": "#/components/responses/Conflict" }
        }
      },
      "delete": {
        "tags": ["Admin Management"],
        "summary": "Kullanıcı Sil (ADMIN)",
        "description": "Kullanıcıyı Keycloak ve yerel yetki tablosundan siler.",
        "operationId": "deleteUser",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "username", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Kullanıcı silindi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/admin/storages": {
      "get": {
        "tags": ["Admin Management"],
        "summary": "Tüm Depoları Listele (ADMIN)",
        "description": "Sistemdeki tüm sanal ve fiziksel depolama alanlarını listeler.",
        "operationId": "getAllStorages",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "responses": {
          "200": {
            "description": "Depo listesi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/StorageInfo" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      },
      "post": {
        "tags": ["Admin Management"],
        "summary": "Yeni Depo Oluştur (ADMIN)",
        "description": "Sistemde yeni bir S3/OpenDAL depolama alanı tanımlar.",
        "operationId": "createStorage",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["id", "name"],
                "properties": {
                  "id": { "type": "string", "example": "finance_pool" },
                  "name": { "type": "string", "example": "Finans Departmanı Deposu" },
                  "description": { "type": "string", "example": "Finans belgeleri için izole depolama" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "$ref": "#/components/responses/Created" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "409": { "$ref": "#/components/responses/Conflict" }
        }
      },
      "delete": {
        "tags": ["Admin Management"],
        "summary": "Depo Sil (ADMIN)",
        "description": "Depolama alanını sistemden kaldırır.",
        "operationId": "deleteStorage",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "parameters": [
          { "name": "id", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Depo silindi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/admin/storages/assign": {
      "post": {
        "tags": ["Admin Management"],
        "summary": "Depoya Kullanıcı Ata / Yetkilendir (ADMIN)",
        "description": "Belirli bir depolama alanına kullanıcı erişim yetkisi verir veya kaldırır.",
        "operationId": "assignStorageUser",
        "security": [{ "bearerAuth": [] }, { "cookieAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["storageId", "username"],
                "properties": {
                  "storageId": { "type": "string", "example": "finance_pool" },
                  "username": { "type": "string", "example": "ahmet" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Yetkilendirme güncellendi", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "`/api/login` üzerinden alınan 256-bit imzalı JWT erişim belirteci."
      },
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "amethyst_token",
        "description": "Tarayıcı oturumlarında kullanılan HttpOnly, SameSite=Lax, Secure çerez."
      },
      "basicAuth": {
        "type": "http",
        "scheme": "basic",
        "description": "Standart WebDAV istemcileri (Cyberduck, Windows Explorer, macOS Finder) için temel kimlik doğrulama."
      }
    },
    "schemas": {
      "ApiResponse": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": { "type": "string", "example": "success" },
          "message": { "type": "string", "example": "İşlem başarıyla tamamlandı." }
        }
      },
      "BatchMoveResponse": {
        "type": "object",
        "required": ["status", "message"],
        "properties": {
          "status": { "type": "string", "enum": ["success", "partial_success", "error"], "example": "partial_success" },
          "message": { "type": "string", "example": "2 adet öğe taşındı, 1 adet öğe taşınamadı." },
          "movedCount": { "type": "integer", "example": 2 },
          "failedCount": { "type": "integer", "example": 1 },
          "failedFiles": {
            "type": "array",
            "items": { "type": "string" },
            "example": ["gizli_dosya.log (Sistem Korumalı)"]
          }
        }
      },
      "LoginRequest": {
        "type": "object",
        "required": ["username", "password"],
        "properties": {
          "username": { "type": "string", "example": "admin" },
          "password": { "type": "string", "format": "password", "example": "password123" }
        }
      },
      "LoginResponse": {
        "type": "object",
        "required": ["status", "token", "username", "role"],
        "properties": {
          "status": { "type": "string", "example": "success" },
          "token": { "type": "string", "description": "JWT Bearer Token" },
          "username": { "type": "string", "example": "admin" },
          "role": { "type": "string", "enum": ["ADMIN", "USER"], "example": "ADMIN" }
        }
      },
      "AuthStatusResponse": {
        "type": "object",
        "required": ["authenticated"],
        "properties": {
          "authenticated": { "type": "boolean", "example": true },
          "username": { "type": "string", "example": "admin" },
          "role": { "type": "string", "example": "ADMIN" }
        }
      },
      "StorageInfo": {
        "type": "object",
        "required": ["id", "name"],
        "properties": {
          "id": { "type": "string", "example": "default" },
          "name": { "type": "string", "example": "Ana Depo" },
          "description": { "type": "string", "example": "Varsayılan kurumsal depolama havuzu" },
          "assignedUsers": { "type": "array", "items": { "type": "string" } }
        }
      },
      "FileItem": {
        "type": "object",
        "required": ["name", "displayName", "size", "isDir"],
        "properties": {
          "name": { "type": "string", "example": "documents/rapor.pdf" },
          "displayName": { "type": "string", "example": "rapor.pdf" },
          "size": { "type": "integer", "format": "int64", "example": 2048576 },
          "owner": { "type": "string", "example": "admin" },
          "lastModified": { "type": "string", "example": "2026-08-21 14:30:00" },
          "isDir": { "type": "boolean", "example": false },
          "hasVersion": { "type": "boolean", "example": true },
          "isArchive": { "type": "boolean", "example": false },
          "isMedia": { "type": "boolean", "example": false },
          "isEditable": { "type": "boolean", "example": false }
        }
      },
      "ArchiveReport": {
        "type": "object",
        "required": ["success", "archiveName", "totalFiles", "entries"],
        "properties": {
          "success": { "type": "boolean", "example": true },
          "archiveName": { "type": "string", "example": "proje_yedek.zip" },
          "totalFiles": { "type": "integer", "example": 42 },
          "uncompressedSize": { "type": "integer", "format": "int64", "example": 104857600 },
          "compressedSize": { "type": "integer", "format": "int64", "example": 45000000 },
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string", "example": "src/Main.java" },
                "size": { "type": "integer", "example": 3450 },
                "compressedSize": { "type": "integer", "example": 1200 },
                "isDir": { "type": "boolean", "example": false }
              }
            }
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "required": ["id", "username", "message", "timestamp"],
        "properties": {
          "id": { "type": "string", "example": "msg_8f12a3bc" },
          "username": { "type": "string", "example": "ahmet" },
          "message": { "type": "string", "example": "Yeni tasarım dosyalarını yükledim." },
          "timestamp": { "type": "string", "example": "15:20:00" }
        }
      },
      "NotificationItem": {
        "type": "object",
        "required": ["id", "message", "time"],
        "properties": {
          "id": { "type": "string", "example": "notif_102" },
          "message": { "type": "string", "example": "rapor.docx dosyası admin tarafından güncellendi." },
          "time": { "type": "string", "example": "14:45" },
          "action": { "type": "string", "example": "EDIT" }
        }
      },
      "SupportTicket": {
        "type": "object",
        "required": ["id", "subject", "creator", "status", "createdAt"],
        "properties": {
          "id": { "type": "string", "example": "TCK-4891" },
          "subject": { "type": "string", "example": "WebDAV Bağlantı Sorunu" },
          "creator": { "type": "string", "example": "user1" },
          "status": { "type": "string", "enum": ["OPEN", "IN_PROGRESS", "RESOLVED", "CLOSED"], "example": "OPEN" },
          "priority": { "type": "string", "enum": ["LOW", "MEDIUM", "HIGH"], "example": "MEDIUM" },
          "createdAt": { "type": "string", "example": "2026-08-21 11:30" }
        }
      },
      "AuditLogItem": {
        "type": "object",
        "required": ["id", "username", "action", "details", "clientIp", "timestamp"],
        "properties": {
          "id": { "type": "string", "example": "log_550e8400" },
          "username": { "type": "string", "example": "admin" },
          "action": { "type": "string", "example": "YUKLEME" },
          "details": { "type": "string", "example": "dosya.pdf yüklendi" },
          "clientIp": { "type": "string", "example": "127.0.0.1" },
          "timestamp": { "type": "string", "example": "2026-08-21 15:30:00" }
        }
      },
      "SystemMetrics": {
        "type": "object",
        "required": ["cpuUsage", "jvmMemoryUsedMb", "jvmMemoryMaxMb"],
        "properties": {
          "cpuUsage": { "type": "number", "format": "double", "example": 4.2 },
          "jvmMemoryUsedMb": { "type": "integer", "example": 185 },
          "jvmMemoryMaxMb": { "type": "integer", "example": 2048 },
          "totalDiskSpaceGb": { "type": "number", "example": 250.0 },
          "freeDiskSpaceGb": { "type": "number", "example": 182.4 },
          "activeVirtualThreads": { "type": "integer", "example": 12 }
        }
      },
      "User": {
        "type": "object",
        "required": ["username", "role"],
        "properties": {
          "username": { "type": "string", "example": "ahmet" },
          "role": { "type": "string", "enum": ["USER", "ADMIN"], "example": "USER" }
        }
      }
    },
    "responses": {
      "Created": {
        "description": "Kaynak başarıyla oluşturuldu (201 Created)",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "Conflict": {
        "description": "Aynı isim, kullanıcı adı veya ID ile kaynak zaten mevcut (409 Conflict)",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "BadRequest": {
        "description": "Geçersiz istek parametreleri veya hatalı JSON gövdesi",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "Unauthorized": {
        "description": "Kimlik doğrulama başarısız veya token geçersiz / süresi dolmuş",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "Forbidden": {
        "description": "Bu işlem, depolama alanı veya sistem dosyası için yetkiniz bulunmamaktadır",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "NotFound": {
        "description": "İstenen kaynak (dosya, kullanıcı, depo, bilet) bulunamadı",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "InternalServerError": {
        "description": "S3 nesne depolama, I/O veya sunucu içi işlem hatası",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      },
      "RateLimited": {
        "description": "İstek sınırı (Rate Limit) aşıldı",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } }
      }
    }
  }
}
