# OriginService
> 源站管理服务

---

## createOrigin
> 创建源站

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/OriginService/createOrigin`
- RPC：`rpc createOrigin (CreateOriginRequest) returns (CreateOriginResponse);`

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

```json
{
  "name": "string // 名称，为可选项",
  "addr": "NetworkAddress // 源站网络地址",
  "ossJSON": "bytes // OSS配置信息，源站网络地址中protocol为oss:开头时需要设置此项",
  "description": "string // 描述，为可选项",
  "weight": "int32 // 权重，不小于0，一般设置为10",
  "isOn": "bool // 是否启用，一般为true",
  "connTimeoutJSON": "bytes // 可选项，连接超时时间",
  "readTimeoutJSON": "bytes // 可选项，读取超时时间",
  "idleTimeoutJSON": "bytes // 可选项，空闲超时时间",
  "maxConns": "int32 // 可选项，最大连接数",
  "maxIdleConns": "int32 // 可选项，最大空闲连接数",
  "domains": "[]string // 可选项，专属域名列表",
  "certRefJSON": "bytes // 可选项，证书设置",
  "host": "string // 可选项，回源主机名",
  "followPort": "bool // 可选项，是否跟随端口",
  "http2Enabled": "bool // 可选项，是否支持HTTP/2，只在HTTPS源站时生效"
}
```

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

```json
{
  "originId": "int64 // 创建的源站ID"
}
```

**调用示例**

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

---

## findEnabledOrigin
> 查找单个源站信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/OriginService/findEnabledOrigin`
- RPC：`rpc findEnabledOrigin (FindEnabledOriginRequest) returns (FindEnabledOriginResponse);`

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

```json
{
  "originId": "int64 // 源站ID"
}
```

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

```json
{
  "Origin": "Origin // 源站信息"
}
```

**调用示例**

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

---

## findEnabledOriginConfig
> 查找源站配置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/OriginService/findEnabledOriginConfig`
- RPC：`rpc findEnabledOriginConfig (FindEnabledOriginConfigRequest) returns (FindEnabledOriginConfigResponse);`

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

```json
{
  "originId": "int64 // 源站ID"
}
```

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

```json
{
  "originJSON": "bytes // 源站信息"
}
```

**调用示例**

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

---

## updateOrigin
> 修改源站

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/OriginService/updateOrigin`
- RPC：`rpc updateOrigin (UpdateOriginRequest) returns (RPCSuccess);`

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

```json
{
  "originId": "int64 // 源站ID",
  "name": "string // 可选项",
  "addr": "NetworkAddress // 源站网络地址",
  "ossJSON": "bytes // OSS配置信息，源站网络地址中protocol为oss:开头时需要设置此项",
  "description": "string // 可选项",
  "weight": "int32 // 权重，不小于0，一般设置为10",
  "isOn": "bool // 是否启用",
  "connTimeoutJSON": "bytes // 可选项",
  "readTimeoutJSON": "bytes // 可选项",
  "idleTimeoutJSON": "bytes // 可选项",
  "maxConns": "int32 // 可选项",
  "maxIdleConns": "int32 // 可选项",
  "domains": "[]string // 可选项",
  "certRefJSON": "bytes // 可选项",
  "host": "string // 可选项",
  "followPort": "bool // 可选项",
  "http2Enabled": "bool // 可选项，是否支持HTTP/2，只在HTTPS源站时生效"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateOriginIsOn
> 设置源站是否启用

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/OriginService/updateOriginIsOn`
- RPC：`rpc updateOriginIsOn(UpdateOriginIsOnRequest) returns (RPCSuccess);`

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

```json
{
  "originId": "int64 // 源站ID",
  "isOn": "bool // 是否启用"
}
```

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

```json
{}
```

**调用示例**

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

---
