# UserADInstanceService
> 用户高防实例服务

---

## buyUserADInstance
> 购买用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/buyUserADInstance`
- RPC：`rpc buyUserADInstance(BuyUserADInstanceRequest) returns (BuyUserADInstanceResponse);`

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

```json
{
  "userId": "int64 // 用户ID",
  "adPackageId": "int64",
  "adPackagePeriodId": "int64",
  "count": "int32 // 数量"
}
```

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

```json
{
  "userADInstanceIds": "[]int64"
}
```

**调用示例**

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

---

## countUserADInstances
> 计算用户高防实例数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/countUserADInstances`
- RPC：`rpc countUserADInstances(CountUserADInstancesRequest) returns (RPCCountResponse);`

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

```json
{
  "adNetworkId": "int64 // 线路ID",
  "userId": "int64 // 用户ID",
  "adPackagePeriodId": "int64",
  "expiresDay": "string",
  "availableOnly": "bool // 是否只查询有效的高防实例"
}
```

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

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

**调用示例**

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

---

## createUserADInstance
> 创建用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/createUserADInstance`
- RPC：`rpc createUserADInstance(CreateUserADInstanceRequest) returns (CreateUserADInstanceResponse);`

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

```json
{
  "userId": "int64 // 用户ID",
  "adPackageId": "int64",
  "adPackagePeriodId": "int64",
  "count": "int32 // 数量"
}
```

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

```json
{
  "userADInstanceIds": "[]int64"
}
```

**调用示例**

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

---

## deleteUserADInstance
> 删除用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/deleteUserADInstance`
- RPC：`rpc deleteUserADInstance(DeleteUserADInstanceRequest) returns (RPCSuccess);`

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

```json
{
  "userADInstanceId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## findUserADInstance
> 查找单个用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/findUserADInstance`
- RPC：`rpc findUserADInstance(FindUserADInstanceRequest) returns (FindUserADInstanceResponse);`

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

```json
{
  "userADInstanceId": "int64"
}
```

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

```json
{
  "userADInstance": "UserADInstance"
}
```

**调用示例**

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

---

## listUserADInstances
> 列出单页用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/listUserADInstances`
- RPC：`rpc listUserADInstances(ListUserADInstancesRequest) returns (ListUserADInstancesResponse);`

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

```json
{
  "adNetworkId": "int64 // 线路ID",
  "userId": "int64 // 用户ID",
  "adPackagePeriodId": "int64",
  "expiresDay": "string",
  "availableOnly": "bool // 是否只查询有效的高防实例",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

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

```json
{
  "userADInstances": "[]UserADInstance"
}
```

**调用示例**

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

---

## renewUserADInstance
> 续期用户高防实例

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/renewUserADInstance`
- RPC：`rpc renewUserADInstance(RenewUserADInstanceRequest) returns (RPCSuccess);`

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

```json
{
  "userADInstanceId": "int64",
  "adPackagePeriodId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUserADInstanceObjects
> 修改实例防护对象

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserADInstanceService/updateUserADInstanceObjects`
- RPC：`rpc updateUserADInstanceObjects(UpdateUserADInstanceObjectsRequest) returns (RPCSuccess);`

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

```json
{
  "userADInstanceId": "int64",
  "objectCodes": "[]string"
}
```

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

```json
{}
```

**调用示例**

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

---
