# ADPackageInstanceService
> 高防实例服务

---

## countADPackageInstances
> 计算实例数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/countADPackageInstances`
- RPC：`rpc countADPackageInstances(CountADPackageInstancesRequest) returns (RPCCountResponse);`

**请求对象 (`CountADPackageInstancesRequest`)**

```json
{
  "adNetworkId": "int64 // 可选，线路",
  "adPackageId": "int64 // 可选，如果不填则表示获取所有实例数量",
  "userId": "int64 // 可选，用户ID",
  "ip": "string // 可选，高防IP"
}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/countADPackageInstances" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countIdleADPackageInstances
> 计算可购的实例数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/countIdleADPackageInstances`
- RPC：`rpc countIdleADPackageInstances(CountIdleADPackageInstancesRequest) returns (RPCCountResponse);`

**请求对象 (`CountIdleADPackageInstancesRequest`)**

```json
{
  "adPackageId": "int64"
}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/countIdleADPackageInstances" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## createADPackageInstance
> 创建实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/createADPackageInstance`
- RPC：`rpc createADPackageInstance(CreateADPackageInstanceRequest) returns (CreateADPackageInstanceResponse);`

**请求对象 (`CreateADPackageInstanceRequest`)**

```json
{
  "adPackageId": "int64",
  "nodeClusterId": "int64 // 集群ID",
  "nodeIds": "[]int64",
  "ipAddresses": "[]string"
}
```

**响应对象 (`CreateADPackageInstanceResponse`)**

```json
{
  "adPackageInstanceId": "int64"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/createADPackageInstance" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## deleteADPackageInstance
> 删除实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/deleteADPackageInstance`
- RPC：`rpc deleteADPackageInstance(DeleteADPackageInstanceRequest) returns (RPCSuccess);`

**请求对象 (`DeleteADPackageInstanceRequest`)**

```json
{
  "adPackageInstanceId": "int64"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/deleteADPackageInstance" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findADPackageInstance
> 查找单个实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/findADPackageInstance`
- RPC：`rpc findADPackageInstance(FindADPackageInstanceRequest) returns (FindADPackageInstanceResponse);`

**请求对象 (`FindADPackageInstanceRequest`)**

```json
{
  "adPackageInstanceId": "int64"
}
```

**响应对象 (`FindADPackageInstanceResponse`)**

```json
{
  "adPackageInstance": "ADPackageInstance"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/findADPackageInstance" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findAllADPackageInstances
> 列出单个高防产品所有实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/findAllADPackageInstances`
- RPC：`rpc findAllADPackageInstances(FindAllADPackageInstancesRequest) returns (FindAllADPackageInstancesResponse);`

**请求对象 (`FindAllADPackageInstancesRequest`)**

```json
{
  "adPackageId": "int64"
}
```

**响应对象 (`FindAllADPackageInstancesResponse`)**

```json
{
  "adPackageInstances": "[]ADPackageInstance"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/findAllADPackageInstances" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## listADPackageInstances
> 列出单页实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/listADPackageInstances`
- RPC：`rpc listADPackageInstances(ListADPackageInstancesRequest) returns (ListADPackageInstancesResponse);`

**请求对象 (`ListADPackageInstancesRequest`)**

```json
{
  "adNetworkId": "int64 // 可选，线路",
  "adPackageId": "int64 // 可选，如果不填则表示获取所有实例数量",
  "userId": "int64 // 可选，用户ID",
  "ip": "string // 可选，高防IP",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

**响应对象 (`ListADPackageInstancesResponse`)**

```json
{
  "adPackageInstances": "[]ADPackageInstance"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/listADPackageInstances" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateADPackageInstance
> 修改实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ADPackageInstanceService/updateADPackageInstance`
- RPC：`rpc updateADPackageInstance(UpdateADPackageInstanceRequest) returns (RPCSuccess);`

**请求对象 (`UpdateADPackageInstanceRequest`)**

```json
{
  "adPackageInstanceId": "int64",
  "nodeClusterId": "int64 // 集群ID",
  "nodeIds": "[]int64",
  "ipAddresses": "[]string",
  "isOn": "bool // 是否启用"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ADPackageInstanceService/updateADPackageInstance" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
