Skip to content

Commit b9a0476

Browse files
authored
Merge pull request #42 from seymourtang/fix-doc
chore:Updated SDK configuration examples and format README.md
2 parents c35ae48 + 8f8568e commit b9a0476

File tree

2 files changed

+87
-62
lines changed

2 files changed

+87
-62
lines changed

README.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Agora REST Client for Go
2+
23
<p>
34
<img alt="GitHub License" src="https://img.shields.io/github/license/AgoraIO-Community/agora-rest-client-go">
45
<a href="https://pkg.go.dev/github.com/AgoraIO-Community/agora-rest-client-go"><img src="https://pkg.go.dev/badge/github.com/AgoraIO-Community/agora-rest-client-go.svg" alt="Go Reference"></a>
@@ -14,31 +15,38 @@ English | [简体中文](./README_ZH.md)
1415
`agora-rest-client-go` is an open-source project written in Go, specifically designed for the Agora REST API. It includes wrappers and internal implementations of the official Agora REST API interfaces, making it easier for developers to integrate the server-side Agora REST API.
1516

1617
> [!IMPORTANT]
17-
This SDK has undergone some testing to ensure its basic functionality works correctly. However, due to the complexity of software development, we cannot guarantee it is completely free of defects. We encourage community developers and users to actively participate and help improve this project.
18+
> This SDK has undergone some testing to ensure its basic functionality works correctly. However, due to the complexity of software development, we cannot guarantee it is completely free of defects. We encourage community developers and users to actively participate and help improve this project.
1819
1920
## Features
20-
* Encapsulates the request and response handling of the Agora REST API, simplifying the communication process with the Agora REST API.
21-
* Provides automatic switching to the best domain in case of DNS resolution failure, network errors, or request timeouts, ensuring the availability of the REST API service.
22-
* Offers easy-to-use APIs to easily implement common functions of the Agora REST API, such as starting and stopping cloud recording.
23-
* Based on Go language, it is efficient, concurrent, and scalable.
21+
22+
- Encapsulates the request and response handling of the Agora REST API, simplifying the communication process with the Agora REST API.
23+
- Provides automatic switching to the best domain in case of DNS resolution failure, network errors, or request timeouts, ensuring the availability of the REST API service.
24+
- Offers easy-to-use APIs to easily implement common functions of the Agora REST API, such as starting and stopping cloud recording.
25+
- Based on Go language, it is efficient, concurrent, and scalable.
2426

2527
## Supported Services
26-
* [Cloud Recording](./services/cloudrecording/README.md)
27-
* [Cloud Transcoder](./services/cloudtranscoder/README.md)
28-
* [Conversational AI Engine](./services/convoai/README.md)
28+
29+
- [Cloud Recording](./services/cloudrecording/README.md)
30+
- [Cloud Transcoder](./services/cloudtranscoder/README.md)
31+
- [Conversational AI Engine](./services/convoai/README.md)
2932

3033
## Environment Setup
31-
* [Go 1.18 or later](https://go.dev/)
32-
* App ID and App Certificate obtained from the [Agora Console](https://console.agora.io/v2)
33-
* Basic Auth credentials from the [Agora Console](https://console.agora.io/v2)
34-
* Enable the relevant service capabilities on the [Agora Console](https://console.agora.io/v2)
34+
35+
- [Go 1.18 or later](https://go.dev/)
36+
- App ID and App Certificate obtained from the [Agora Console](https://console.agora.io/v2)
37+
- Basic Auth credentials from the [Agora Console](https://console.agora.io/v2)
38+
- Enable the relevant service capabilities on the [Agora Console](https://console.agora.io/v2)
3539

3640
## Installation
41+
3742
Install the dependency from GitHub using the following command:
43+
3844
```shell
3945
go get -u github.com/AgoraIO-Community/agora-rest-client-go
4046
```
47+
4148
## Usage Example
49+
4250
Here is an example of calling the cloud recording service:
4351

4452
```go
@@ -49,13 +57,12 @@ import (
4957
"log"
5058
"time"
5159

52-
"github.com/AgoraIO-Community/agora-rest-client-go/agora"
5360
"github.com/AgoraIO-Community/agora-rest-client-go/agora/auth"
5461
"github.com/AgoraIO-Community/agora-rest-client-go/agora/domain"
5562
agoraLogger "github.com/AgoraIO-Community/agora-rest-client-go/agora/log"
5663
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording"
5764
cloudRecordingAPI "github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/api"
58-
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/scenario/mixrecording"
65+
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/req"
5966
)
6067

6168
const (
@@ -79,8 +86,8 @@ var storageConfig = &cloudRecordingAPI.StorageConfig{
7986
}
8087

8188
func main() {
82-
// Initialize Agora Config
83-
config := &agora.Config{
89+
// Initialize Cloud Recording Config
90+
config := &cloudrecording.Config{
8491
AppID: appId,
8592
Credential: auth.NewBasicAuthCredential(username, password),
8693
// Specify the region where the server is located. Options include CN, EU, AP, US.
@@ -99,8 +106,8 @@ func main() {
99106

100107
// Call the Acquire API of the cloud recording service client
101108
acquireResp, err := cloudRecordingClient.MixRecording().
102-
Acquire(context.TODO(), cname, uid, &mixrecording.AcquireMixRecodingClientRequest{})
103-
// Handle non-business errors
109+
Acquire(context.TODO(), cname, uid, &req.AcquireMixRecodingClientRequest{})
110+
// Handle non-business errors
104111
if err != nil {
105112
log.Fatal(err)
106113
}
@@ -115,7 +122,7 @@ func main() {
115122
// Call the Start API of the cloud recording service client
116123
resourceId := acquireResp.SuccessRes.ResourceId
117124
startResp, err := cloudRecordingClient.MixRecording().
118-
Start(context.TODO(), resourceId, cname, uid, &mixrecording.StartMixRecordingClientRequest{
125+
Start(context.TODO(), resourceId, cname, uid, &req.StartMixRecordingClientRequest{
119126
Token: token,
120127
RecordingConfig: &cloudRecordingAPI.RecordingConfig{
121128
ChannelType: 1,
@@ -145,7 +152,7 @@ func main() {
145152
},
146153
StorageConfig: storageConfig,
147154
})
148-
// Handle non-business errors
155+
// Handle non-business errors
149156
if err != nil {
150157
log.Fatal(err)
151158
}
@@ -162,7 +169,7 @@ func main() {
162169
for i := 0; i < 6; i++ {
163170
queryResp, err := cloudRecordingClient.MixRecording().
164171
QueryHLSAndMP4(context.TODO(), resourceId, sid)
165-
// Handle non-business errors
172+
// Handle non-business errors
166173
if err != nil {
167174
log.Fatal(err)
168175
}
@@ -179,7 +186,7 @@ func main() {
179186
// Call the Stop API of the cloud recording service client
180187
stopResp, err := cloudRecordingClient.MixRecording().
181188
Stop(context.TODO(), resourceId, sid, cname, uid, true)
182-
// Handle non-business errors
189+
// Handle non-business errors
183190
if err != nil {
184191
log.Fatal(err)
185192
}
@@ -192,7 +199,9 @@ func main() {
192199
}
193200
}
194201

202+
195203
```
204+
196205
For more examples, see [Example](./examples).
197206

198207
## Contribution
@@ -203,13 +212,15 @@ This project welcomes and accepts contributions. If you encounter any issues or
203212

204213
This project uses Semantic Versioning (SemVer) to manage versions. The format is MAJOR.MINOR.PATCH.
205214

206-
* MAJOR version indicates incompatible changes.
207-
* MINOR version indicates backward-compatible new features or enhancements.
208-
* PATCH version indicates backward-compatible bug fixes and maintenance.
209-
For more details, please refer to the [Semantic Versioning](https://semver.org) specification.
215+
- MAJOR version indicates incompatible changes.
216+
- MINOR version indicates backward-compatible new features or enhancements.
217+
- PATCH version indicates backward-compatible bug fixes and maintenance.
218+
For more details, please refer to the [Semantic Versioning](https://semver.org) specification.
210219

211220
## References
212-
* [Agora API Documentation](https://docs.agora.io/en/)
221+
222+
- [Agora API Documentation](https://docs.agora.io/en/)
213223

214224
## License
215-
This project is licensed under the MIT License. For more details, please refer to the LICENSE file.
225+
226+
This project is licensed under the MIT License. For more details, please refer to the LICENSE file.

README_ZH.md

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Agora REST Client for Go
2+
23
<p>
34
<img alt="GitHub License" src="https://img.shields.io/github/license/AgoraIO-Community/agora-rest-client-go">
45
<a href="https://pkg.go.dev/github.com/AgoraIO-Community/agora-rest-client-go"><img src="https://pkg.go.dev/badge/github.com/AgoraIO-Community/agora-rest-client-go.svg" alt="Go Reference"></a>
@@ -9,36 +10,43 @@
910
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues-pr/AgoraIO-Community/agora-rest-client-go">
1011
</p>
1112

12-
[English](./README.md) | 简体中文
13+
[English](./README.md) | 简体中文
1314

14-
`agora-rest-client-go`是用Go语言编写的一个开源项目,专门为 Agora REST API设计。它包含了 Agora 官方提供的REST API接口的包装和内部实现,可以帮助开发者更加方便的集成服务端Agora REST API。
15+
`agora-rest-client-go`是用 Go 语言编写的一个开源项目,专门为 Agora REST API 设计。它包含了 Agora 官方提供的 REST API 接口的包装和内部实现,可以帮助开发者更加方便的集成服务端 Agora REST API。
1516

1617
> [!IMPORTANT]
17-
该SDK经过一些测试以确保其基本功能正常运作。然而,由于软件开发的复杂性,我们无法保证它是完全没有缺陷的,我们鼓励社区的开发者和用户积极参与,共同改进这个项目。
18+
> 该 SDK 经过一些测试以确保其基本功能正常运作。然而,由于软件开发的复杂性,我们无法保证它是完全没有缺陷的,我们鼓励社区的开发者和用户积极参与,共同改进这个项目。
1819
1920
## 特性
20-
* 封装了Agora REST API的请求和响应处理,简化与Agora REST API 的通信流程
21-
* 当遇到 DNS 解析失败、网络错误或者请求超时等问题的时候,提供了自动切换最佳域名的能力,以保障请求 REST API 服务的可用性
22-
* 提供了易于使用的API,可轻松地实现调用 Agora REST API 的常见功能,如开启云录制、停止云录制等
23-
* 基于Go语言,具有高效性、并发性和可扩展性
21+
22+
- 封装了 Agora REST API 的请求和响应处理,简化与 Agora REST API 的通信流程
23+
- 当遇到 DNS 解析失败、网络错误或者请求超时等问题的时候,提供了自动切换最佳域名的能力,以保障请求 REST API 服务的可用性
24+
- 提供了易于使用的 API,可轻松地实现调用 Agora REST API 的常见功能,如开启云录制、停止云录制等
25+
- 基于 Go 语言,具有高效性、并发性和可扩展性
2426

2527
## 支持的服务
26-
* [云端录制 Cloud Recording](./services/cloudrecording/README.md)
27-
* [云端转码 Cloud Transcoder](./services/cloudtranscoder/README.md)
28-
* [对话式 AI 引擎 Conversational AI Engine](./services/convoai/README_ZH.md)
28+
29+
- [云端录制 Cloud Recording](./services/cloudrecording/README.md)
30+
- [云端转码 Cloud Transcoder](./services/cloudtranscoder/README.md)
31+
- [对话式 AI 引擎 Conversational AI Engine](./services/convoai/README_ZH.md)
2932

3033
## 环境准备
31-
* [Go 1.18 或以上版本](https://go.dev/)
32-
* 在声网 [Console 平台](https://console.shengwang.cn/)申请的 App ID 和 App Certificate
33-
* 在声网 [Console 平台](https://console.shengwang.cn/)的 Basic Auth 认证信息
34-
* 在声网 [Console 平台](https://console.shengwang.cn/)开启相关的服务能力
34+
35+
- [Go 1.18 或以上版本](https://go.dev/)
36+
- 在声网 [Console 平台](https://console.shengwang.cn/)申请的 App ID 和 App Certificate
37+
- 在声网 [Console 平台](https://console.shengwang.cn/)的 Basic Auth 认证信息
38+
- 在声网 [Console 平台](https://console.shengwang.cn/)开启相关的服务能力
3539

3640
## 安装
41+
3742
使用以下命令从 GitHub 安装依赖:
43+
3844
```shell
3945
go get -u github.com/AgoraIO-Community/agora-rest-client-go
4046
```
47+
4148
## 使用示例
49+
4250
以调用云录制服务为例:
4351

4452
```go
@@ -49,13 +57,12 @@ import (
4957
"log"
5058
"time"
5159

52-
"github.com/AgoraIO-Community/agora-rest-client-go/agora"
5360
"github.com/AgoraIO-Community/agora-rest-client-go/agora/auth"
5461
"github.com/AgoraIO-Community/agora-rest-client-go/agora/domain"
5562
agoraLogger "github.com/AgoraIO-Community/agora-rest-client-go/agora/log"
5663
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording"
5764
cloudRecordingAPI "github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/api"
58-
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/scenario/mixrecording"
65+
"github.com/AgoraIO-Community/agora-rest-client-go/services/cloudrecording/req"
5966
)
6067

6168
const (
@@ -79,8 +86,8 @@ var storageConfig = &cloudRecordingAPI.StorageConfig{
7986
}
8087

8188
func main() {
82-
// Initialize Agora Config
83-
config := &agora.Config{
89+
// Initialize Cloud Recording Config
90+
config := &cloudrecording.Config{
8491
AppID: appId,
8592
Credential: auth.NewBasicAuthCredential(username, password),
8693
// Specify the region where the server is located. Options include CN, EU, AP, US.
@@ -99,8 +106,8 @@ func main() {
99106

100107
// Call the Acquire API of the cloud recording service client
101108
acquireResp, err := cloudRecordingClient.MixRecording().
102-
Acquire(context.TODO(), cname, uid, &mixrecording.AcquireMixRecodingClientRequest{})
103-
// Handle non-business errors
109+
Acquire(context.TODO(), cname, uid, &req.AcquireMixRecodingClientRequest{})
110+
// Handle non-business errors
104111
if err != nil {
105112
log.Fatal(err)
106113
}
@@ -115,7 +122,7 @@ func main() {
115122
// Call the Start API of the cloud recording service client
116123
resourceId := acquireResp.SuccessRes.ResourceId
117124
startResp, err := cloudRecordingClient.MixRecording().
118-
Start(context.TODO(), resourceId, cname, uid, &mixrecording.StartMixRecordingClientRequest{
125+
Start(context.TODO(), resourceId, cname, uid, &req.StartMixRecordingClientRequest{
119126
Token: token,
120127
RecordingConfig: &cloudRecordingAPI.RecordingConfig{
121128
ChannelType: 1,
@@ -145,7 +152,7 @@ func main() {
145152
},
146153
StorageConfig: storageConfig,
147154
})
148-
// Handle non-business errors
155+
// Handle non-business errors
149156
if err != nil {
150157
log.Fatal(err)
151158
}
@@ -162,7 +169,7 @@ func main() {
162169
for i := 0; i < 6; i++ {
163170
queryResp, err := cloudRecordingClient.MixRecording().
164171
QueryHLSAndMP4(context.TODO(), resourceId, sid)
165-
// Handle non-business errors
172+
// Handle non-business errors
166173
if err != nil {
167174
log.Fatal(err)
168175
}
@@ -179,7 +186,7 @@ func main() {
179186
// Call the Stop API of the cloud recording service client
180187
stopResp, err := cloudRecordingClient.MixRecording().
181188
Stop(context.TODO(), resourceId, sid, cname, uid, true)
182-
// Handle non-business errors
189+
// Handle non-business errors
183190
if err != nil {
184191
log.Fatal(err)
185192
}
@@ -192,33 +199,40 @@ func main() {
192199
}
193200
}
194201

202+
195203
```
204+
196205
更多的示例可在[Example](./examples) 查看
197206

198207
## 集成遇到困难,该如何联系声网获取协助
199208

200-
> 方案1:如果您已经在使用声网服务或者在对接中,可以直接联系对接的销售或服务
209+
> 方案 1:如果您已经在使用声网服务或者在对接中,可以直接联系对接的销售或服务
201210
>
202-
> 方案2:发送邮件给 [[email protected]](mailto:[email protected]) 咨询
211+
> 方案 2:发送邮件给 [[email protected]](mailto:[email protected]) 咨询
203212
>
204-
> 方案3:扫码加入我们的微信交流群提问
213+
> 方案 3:扫码加入我们的微信交流群提问
205214
>
206215
> <img src="https://download.agora.io/demo/release/SDHY_QA.jpg" width="360" height="360">
216+
207217
---
208218

209219
## 贡献
210-
本项目欢迎并接受贡献。如果您在使用中遇到问题或有改进建议,请提出issue或向我们提交Pull Request。
220+
221+
本项目欢迎并接受贡献。如果您在使用中遇到问题或有改进建议,请提出 issue 或向我们提交 Pull Request。
211222

212223
# SemVer 版本规范
224+
213225
本项目使用语义化版本号规范 (SemVer) 来管理版本。格式为 MAJOR.MINOR.PATCH。
214226

215-
* MAJOR 版本号表示不向后兼容的重大更改。
216-
* MINOR 版本号表示向后兼容的新功能或增强。
217-
* PATCH 版本号表示向后兼容的错误修复和维护。
218-
有关详细信息,请参阅 [语义化版本](https://semver.org/lang/zh-CN/) 规范。
227+
- MAJOR 版本号表示不向后兼容的重大更改。
228+
- MINOR 版本号表示向后兼容的新功能或增强。
229+
- PATCH 版本号表示向后兼容的错误修复和维护。
230+
有关详细信息,请参阅 [语义化版本](https://semver.org/lang/zh-CN/) 规范。
219231

220232
## 参考
221-
* [声网 API 文档](https://doc.shengwang.cn/)
233+
234+
- [声网 API 文档](https://doc.shengwang.cn/)
222235

223236
## 许可证
224-
该项目使用MIT许可证,详细信息请参阅LICENSE文件。
237+
238+
该项目使用 MIT 许可证,详细信息请参阅 LICENSE 文件。

0 commit comments

Comments
 (0)