|
- package logic
-
- import (
- "PCM/common/tool"
- "context"
- "fmt"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
- tscf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416"
-
- "PCM/adaptor/PCM-FC/PCM-SCF/internal/svc"
- "PCM/adaptor/PCM-FC/PCM-SCF/scf"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type GetFunctionsLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
-
- func NewGetFunctionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFunctionsLogic {
- return &GetFunctionsLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
-
- // GetFunctions 查询腾讯云云函数详情
- func (l *GetFunctionsLogic) GetFunctions(in *scf.GetFunctionsReq) (*scf.GetFunctionsResp, error) {
- resp := &scf.GetFunctionsResp{}
- // 实例化要请求产品的client对象,clientProfile是可选的k
- client, _ := tscf.NewClient(l.svcCtx.Credential, in.Region, l.svcCtx.Cpf)
- // 实例化一个请求对象,每个接口都会对应一个request对象
- request := tscf.NewGetFunctionRequest()
-
- request.FunctionName = common.StringPtr(in.FunctionName)
-
- // 返回的resp是一个GetFunctionResponse的实例,与请求对象对应
- response, err := client.GetFunction(request)
- if _, ok := err.(*errors.TencentCloudSDKError); ok {
- fmt.Printf("An API error has returned: %s", err)
- return nil, nil
- }
- if err != nil {
- panic(err)
- }
- tool.Convert(response.Response, &resp.Response)
- return resp, nil
- }
|