You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

getfunctionslogic.go 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package logic
  2. import (
  3. "PCM/common/tool"
  4. "context"
  5. "fmt"
  6. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
  7. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
  8. tscf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416"
  9. "PCM/adaptor/PCM-FC/PCM-SCF/internal/svc"
  10. "PCM/adaptor/PCM-FC/PCM-SCF/scf"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type GetFunctionsLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewGetFunctionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFunctionsLogic {
  19. return &GetFunctionsLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // GetFunctions 查询腾讯云云函数详情
  26. func (l *GetFunctionsLogic) GetFunctions(in *scf.GetFunctionsReq) (*scf.GetFunctionsResp, error) {
  27. resp := &scf.GetFunctionsResp{}
  28. // 实例化要请求产品的client对象,clientProfile是可选的k
  29. client, _ := tscf.NewClient(l.svcCtx.Credential, in.Region, l.svcCtx.Cpf)
  30. // 实例化一个请求对象,每个接口都会对应一个request对象
  31. request := tscf.NewGetFunctionRequest()
  32. request.FunctionName = common.StringPtr(in.FunctionName)
  33. // 返回的resp是一个GetFunctionResponse的实例,与请求对象对应
  34. response, err := client.GetFunction(request)
  35. if _, ok := err.(*errors.TencentCloudSDKError); ok {
  36. fmt.Printf("An API error has returned: %s", err)
  37. return nil, nil
  38. }
  39. if err != nil {
  40. panic(err)
  41. }
  42. tool.Convert(response.Response, &resp.Response)
  43. return resp, nil
  44. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.