# Folders

## Список папок

`GET /folders`

```json
{
  "tags": [
    "Folders"
  ],
  "summary": "Список папок",
  "description": "Уникальные непустые теги папок среди постоянных профилей.",
  "responses": {
    "200": {
      "description": "Названия папок.",
      "content": {
        "application/json": {
          "schema": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "work",
              "scrapers"
            ]
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```

## Переименовать папку

`PATCH /folders/{folder}`

```json
{
  "tags": [
    "Folders"
  ],
  "summary": "Переименовать папку",
  "description": "Перевешивает тег на всех профилях в папке. Возвращает количество затронутых профилей.",
  "parameters": [
    {
      "name": "folder",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string",
              "description": "Новое название папки."
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Переименована.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "renamed_to": {
                "type": "string"
              },
              "profiles": {
                "type": "integer",
                "description": "Количество перетегированных профилей."
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```

## Удалить папку

`DELETE /folders/{folder}`

```json
{
  "tags": [
    "Folders"
  ],
  "summary": "Удалить папку",
  "description": "Удаляет тег папки. При `delete_profiles=true` профили внутри тоже\nудаляются; иначе они переходят в «Все» (тег снимается).\n",
  "parameters": [
    {
      "name": "folder",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "delete_profiles",
      "in": "query",
      "required": false,
      "description": "Удалить профили из папки (по умолчанию false = снять тег).",
      "schema": {
        "type": "boolean",
        "default": false
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Удалена.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "deleted_folder": {
                "type": "string"
              },
              "delete_profiles": {
                "type": "boolean"
              },
              "profiles": {
                "type": "integer",
                "description": "Количество затронутых профилей."
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```

## Создать профиль в папке

`POST /folders/{folder}/profiles`

```json
{
  "tags": [
    "Folders"
  ],
  "summary": "Создать профиль в папке",
  "description": "То же, что `POST /profiles`, но папка берётся из пути\n(переопределяет `folder` в теле запроса).\n",
  "parameters": [
    {
      "name": "folder",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/CreateProfileRequest"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Метаданные созданного профиля.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ProfileMeta"
          }
        }
      }
    },
    "400": {
      "description": "Отсутствует или не является объектом `fingerprint`, либо неразбираемая строка прокси.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```
