# ACMETaskService
> ACME任务相关服务

---

## countAllEnabledACMETasks
> 计算所有任务数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/countAllEnabledACMETasks`
- RPC：`rpc countAllEnabledACMETasks (CountAllEnabledACMETasksRequest) returns (RPCCountResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "userId": "int64 // 用户ID",
  "isAvailable": "bool",
  "isExpired": "bool",
  "expiringDays": "int32",
  "keyword": "string // 关键词",
  "userOnly": "bool // 可选项，是否只列出用户上传的证书"
}
```

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

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

**调用示例**

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

---

## countAllEnabledACMETasksWithACMEUserId
> 计算某个ACME用户相关的任务数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/countAllEnabledACMETasksWithACMEUserId`
- RPC：`rpc countAllEnabledACMETasksWithACMEUserId (CountAllEnabledACMETasksWithACMEUserIdRequest) returns (RPCCountResponse);`

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

```json
{
  "acmeUserId": "int64"
}
```

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

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

**调用示例**

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

---

## countEnabledACMETasksWithDNSProviderId
> 计算跟某个DNS服务商相关的任务数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/countEnabledACMETasksWithDNSProviderId`
- RPC：`rpc countEnabledACMETasksWithDNSProviderId (CountEnabledACMETasksWithDNSProviderIdRequest) returns (RPCCountResponse);`

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

```json
{
  "dnsProviderId": "int64"
}
```

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

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

**调用示例**

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

---

## createACMETask
> 创建任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/createACMETask`
- RPC：`rpc createACMETask (CreateACMETaskRequest) returns (CreateACMETaskResponse);`

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

```json
{
  "userId": "int64 // 平台用户ID，只有管理员才有权限指定",
  "acmeUserId": "int64",
  "dnsProviderId": "int64",
  "dnsDomain": "string",
  "domains": "[]string",
  "autoRenew": "bool",
  "authType": "string",
  "authURL": "string",
  "async": "bool"
}
```

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

```json
{
  "acmeTaskId": "int64"
}
```

**调用示例**

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

---

## deleteACMETask
> 删除任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/deleteACMETask`
- RPC：`rpc deleteACMETask (DeleteACMETaskRequest) returns (RPCSuccess);`

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

```json
{
  "acmeTaskId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## findACMETaskUser
> 查找任务所属用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/findACMETaskUser`
- RPC：`rpc findACMETaskUser(FindACMETaskUserRequest) returns (FindACMETaskUserResponse);`

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

```json
{
  "acmeTaskId": "int64 // 任务ID"
}
```

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

```json
{
  "user": "User // 用户信息，只包含几个基本的信息"
}
```

**调用示例**

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

---

## findEnabledACMETask
> 查找单个任务信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/findEnabledACMETask`
- RPC：`rpc findEnabledACMETask (FindEnabledACMETaskRequest) returns (FindEnabledACMETaskResponse);`

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

```json
{
  "acmeTaskId": "int64"
}
```

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

```json
{
  "acmeTask": "ACMETask"
}
```

**调用示例**

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

---

## listEnabledACMETasks
> 列出单页任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/listEnabledACMETasks`
- RPC：`rpc listEnabledACMETasks (ListEnabledACMETasksRequest) returns (ListEnabledACMETasksResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "userId": "int64 // 用户ID",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0",
  "isAvailable": "bool",
  "isExpired": "bool",
  "expiringDays": "int32",
  "keyword": "string // 关键词",
  "userOnly": "bool // 可选项，是否只列出用户上传的证书"
}
```

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

```json
{
  "acmeTasks": "[]ACMETask"
}
```

**调用示例**

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

---

## runACMETask
> 运行某个任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/runACMETask`
- RPC：`rpc runACMETask (RunACMETaskRequest) returns (RunACMETaskResponse);`

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

```json
{
  "acmeTaskId": "int64"
}
```

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

```json
{
  "isOk": "bool",
  "error": "string",
  "sslCertId": "int64"
}
```

**调用示例**

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

---

## updateACMETask
> 修改任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ACMETaskService/updateACMETask`
- RPC：`rpc updateACMETask (UpdateACMETaskRequest) returns (RPCSuccess);`

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

```json
{
  "acmeTaskId": "int64",
  "acmeUserId": "int64",
  "dnsProviderId": "int64",
  "dnsDomain": "string",
  "domains": "[]string",
  "autoRenew": "bool",
  "authURL": "string"
}
```

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

```json
{}
```

**调用示例**

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

---
