# huaweicloud-dwr-sdk-demo-action-go **Repository Path**: HuaweiCloudDeveloper/huaweicloud-dwr-sdk-demo-action-go ## Basic Information - **Project Name**: huaweicloud-dwr-sdk-demo-action-go - **Description**: 数据工坊(Data Workroom,DWR)是一款近数据处理服务,通过易用的数据处理工作流编排和开放生态的数据处理算子,能够在云上实现图像、视频、文档、图片等数据处理业务。本仓库演示了如何调用dwr-go-sdk来发布三方算子并提交审核 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master-dev - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-11-24 - **Last Updated**: 2025-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # huaweicloud-dwr-sdk-demo-acion-go ## 1.介绍 本示例介绍了如何使用华为云DWR服务的Go SDK创建三方算子,并上传算子相关文件。 ## 2.版本说明 本示例配套的SDK版本为v0.1.12 ## 3.准备工作 1. 参考华为云DWR开发工具包(SDK) 引入 DWR Go SDK 2. 要使用华为云DWR Go SDK,您需要拥有华为云账号以及该账号对应的 Access Key(AK)和 Secret Access Key(SK)。 3. 获取您期望使用的目标终端节点(参考[华为云DWR endpoint列表](https://developer.huaweicloud.com/endpoint)) 4. 准备好算子包(打包的可运行代码,参考[FuncionGraph创建程序包](https://support.huaweicloud.com/usermanual-functiongraph/functiongraph_01_0152.html))以及其它算子相关文件 5. 华为云 DWR Go SDK 需要运行在 Go 1.14 及以上版本。 ## 4.示例代码 1. 创建Client ``` client := dwr.NewDwrClient( dwr.DwrClientBuilder(). WithEndpoint(endpoint). WithCredential( basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build()). WithHttpConfig(config.DefaultHttpConfig(). WithIgnoreSSLVerification(true). WithHttpHandler(httphandler.NewHttpHandler().AddResponseHandler(func(response http.Response) { fmt.Println(response.Header) }))). Build()) ``` 2. 创建三方算子 ``` res, err := client.CreateMyActionTemplate(&model.CreateMyActionTemplateRequest{ TemplateName: templateName, Body: actionTemplateBody, }) if err != nil || res.HttpStatusCode != http.StatusCreated { fmt.Printf("failed to create my action template: %v, res: %v", err, res) return } ``` 3. 上传算子材料 ``` pkgMap := map[string]string{ *res.FuncPkgPath: funcPkgPath, res.FuncHelpPath["en-us"]: funcHelpPathEn, res.FuncHelpPath["zh-cn"]: funcHelpPathCn, res.FuncLogoPath["en-us"]: funcLogoPathEn, res.FuncLogoPath["zh-cn"]: funcLogoPathCn, res.FuncSlaPath["en-us"]: funcSlaPathEn, res.FuncSlaPath["zh-cn"]: funcSlaPathCn, res.FuncTestReportPath["en-us"]: funcTestReportPathEn, res.FuncTestReportPath["zh-cn"]: funcTestReportPathCn, res.FuncOpensourceNoticePath["en-us"]: funcOpensourceNoticePathEn, res.FuncOpensourceNoticePath["zh-cn"]: funcOpensourceNoticePathCn, } if err = uploadAllFuncPkg(pkgMap); err != nil { fmt.Printf("failed to upload func packages: %s", err.Error()) } ``` 4、查询算子详情 ``` info, err := client.ShowThirdTemplateInfo(&model.ShowThirdTemplateInfoRequest{ TemplateName: templateName, }) ``` ## 5.备注 本示例中创建的算子如需发布,请到DWR控制台页面提交审核,审核通过后,算子将发布到[算子市场](https://support.huaweicloud.com/usermanual-dwr/dwr_03_0001.html)中。 ## 6.参考 更多信息请参考[DWR数据工坊](https://support.huaweicloud.com/dwr/index.html) ## 7.修订记录 | 发布日期 | 文档版本 | 修订说明| |-|-|-| | 2022-11-25 | 1.0 | 文档首次发布 |