# Datacenter & ISP Proxies

Операції для датацентрових та ISP проксі

## Отримати активні проксі на замовлення

`GET /user/api/proxies/active`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Отримати активні проксі на замовлення",
  "parameters": [
    {
      "in": "query",
      "name": "order_id",
      "required": true,
      "schema": {
        "type": "integer"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Список проксі",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ActiveProxyItem"
                }
              },
              "order_tag": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "success",
              "data"
            ]
          }
        }
      }
    },
    "403": {
      "description": "Метод недоступний для цього замовлення",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ApiError"
          }
        }
      }
    }
  }
}
```

## Налаштувати видалення для кожного IP (del-np)

`POST /user/api/orders/{order_id}/del-np/set`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Налаштувати видалення для кожного IP (del-np)",
  "description": "Лише для проксі-серверів центрів обробки даних і провайдерів. Після оновлення замовлення `quantity` та `price_paid` перераховуються.",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "ip": {
                    "type": "string"
                  },
                  "value": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "ip",
                  "value"
                ]
              }
            }
          },
          "required": [
            "items"
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Успіх",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "400": {
      "description": "Помилка перевірки / не DC-ISP / keep=0",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ApiError"
          }
        }
      }
    }
  }
}
```

## Установити відбиток ОС для IP

`POST /user/api/orders/{order_id}/signature/set`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Установити відбиток ОС для IP",
  "description": "Встановлює підпис відбитка ОС для однієї або кількох IP-адрес проксі.  \nДля замовлення потрібен активний додаток `p0f_slots`.\n\nКожна IP-адреса з підписом постійно займає один слот. Зміна ОС для IP-адреси, яка вже має підпис, не потребує додаткового слота.\n\n**Доступні значення підпису:**\n\n| Значення | ОС |\n|-------|----|\n| `ios` | iOS |\n| `macos` | macOS |\n| `android` | Android |\n| `linux` | Linux |\n| `win10` | Windows 10 |\n| `win11` | Windows 11 |",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "items"
          ],
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "ip",
                  "signature"
                ],
                "properties": {
                  "ip": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string",
                    "description": "Ідентифікатор ОС для підробки.",
                    "enum": [
                      "ios",
                      "macos",
                      "android",
                      "linux",
                      "win10",
                      "win11"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Успіх",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              },
              "updated": {
                "type": "integer",
                "description": "Кількість оновлених IP-адрес"
              }
            }
          }
        }
      }
    },
    "400": {
      "description": "Помилка перевірки або недостатньо слотів",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ApiError"
          }
        }
      }
    }
  }
}
```

## Розрахувати додаткову вартість

`GET /user/api/orders/{order_id}/addons/calculate`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Розрахувати додаткову вартість",
  "description": "Повертає попередній перегляд ціни для придбання додаткових одиниць певного доповнення для активного замовлення центру обробки даних/провайдера. Наразі єдиним підтримуваним ключем додатка є `p0f_slots`; Слоти для підпису відбитків пальців ОС.",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "description": "ID замовлення",
      "schema": {
        "type": "integer"
      }
    },
    {
      "in": "query",
      "name": "addon_key",
      "required": true,
      "description": "Ідентифікатор доповнення (наприклад, `p0f_slots`)",
      "schema": {
        "type": "string"
      }
    },
    {
      "in": "query",
      "name": "add_qty",
      "required": true,
      "description": "Кількість одиниць для додавання",
      "schema": {
        "type": "integer",
        "minimum": 1
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Попередній перегляд ціни",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "addon_key": {
                "type": "string"
              },
              "catalog_id": {
                "type": "integer"
              },
              "price_per_unit": {
                "type": "integer",
                "description": "Ціна за одиницю в центах"
              },
              "current_qty": {
                "type": "integer"
              },
              "add_qty": {
                "type": "integer"
              },
              "new_qty": {
                "type": "integer"
              },
              "add_total": {
                "type": "integer",
                "description": "Загальна вартість цієї покупки в центах"
              }
            }
          }
        }
      }
    }
  }
}
```

## Купити додатковий компонент

`POST /user/api/orders/{order_id}/addons/purchase`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Купити додатковий компонент",
  "description": "Миттєво заряджає гаманець і додає необхідну кількість додаткових одиниць до замовлення. Замовлення має бути **active**. Єдиний наразі доступний ключ доповнення - `p0f_slots`.",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "description": "ID замовлення",
      "schema": {
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "addon_key",
            "add_qty"
          ],
          "properties": {
            "addon_key": {
              "type": "string"
            },
            "add_qty": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Придбано додаток",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              },
              "addons_price_paid": {
                "type": "integer",
                "description": "Сукупна додаткова вартість для цього замовлення (центи)"
              },
              "addons": {
                "type": "array",
                "description": "Оновлений список додатків зберігається в замовленні",
                "items": {
                  "$ref": "#/components/schemas/AddonLine"
                }
              }
            }
          }
        }
      }
    }
  }
}
```

## Запланувати пониження додаткового компонента

`POST /user/api/orders/{order_id}/addons/schedule`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Запланувати пониження додаткового компонента",
  "description": "Планує, щоб **downgrade** доповнення набуло чинності в наступному циклі оновлення. Нова кількість має бути меншою за поточну. Зміни зберігаються як маркер `pending` і застосовуються автоматично під час оновлення замовлення.",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "description": "ID замовлення",
      "schema": {
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "addon_key",
            "action",
            "next_qty"
          ],
          "properties": {
            "addon_key": {
              "type": "string"
            },
            "action": {
              "type": "string",
              "enum": [
                "downgrade"
              ]
            },
            "next_qty": {
              "type": "integer",
              "description": "Цільова кількість після оновлення. Має бути менше поточної кількості.",
              "minimum": 1
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Заплановано пониження",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              },
              "addons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AddonLine"
                }
              }
            }
          }
        }
      }
    }
  }
}
```

## Скасувати заплановане зниження

`POST /user/api/orders/{order_id}/addons/schedule/cancel`

```json
{
  "tags": [
    "Datacenter & ISP Proxies"
  ],
  "summary": "Скасувати заплановане зниження",
  "description": "Видаляє очікування повернення, яке було встановлено через кінцеву точку розкладу.",
  "parameters": [
    {
      "in": "path",
      "name": "order_id",
      "required": true,
      "description": "ID замовлення",
      "schema": {
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "addon_key"
          ],
          "properties": {
            "addon_key": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Очікування повернення видалено",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "message": {
                "type": "string"
              },
              "addons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AddonLine"
                }
              }
            }
          }
        }
      }
    }
  }
}
```
