Files
be.ems/src/modules/ne/fetch_link/udm.go
TsMask 45e226ce1a Refactor API tags in swagger.yaml to use shortened prefixes
- Updated tags from 'network_data' to 'ne_data' for consistency and brevity.
- Changed 'network_element' to 'ne' across various endpoints for improved readability.
- Adjusted related descriptions in the tags section to reflect the new naming conventions.
2025-08-21 14:30:09 +08:00

40 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 网元UDM服务可能是8080、33030端口服务
// 融合的UDM网元视情况调整。
package fetchlink
import (
"encoding/json"
"fmt"
"strings"
"be.ems/src/framework/logger"
"be.ems/src/framework/utils/fetch"
)
// UDMImportAuth UDM导入鉴权数据
//
// data参数 {path:"服务器文件路径", k4:"可选k4为空时Ki不加密。"}
func UDMImportAuth(udmIP string, data map[string]any) (string, error) {
// 网元参数配置新增array
neUrl := fmt.Sprintf("http://%s:8080/ue-manage/v1/import-auth", udmIP)
resBytes, err := fetch.PostJSON(neUrl, data, nil)
var resData map[string]string
if err != nil {
errStr := err.Error()
logger.Warnf("UDMImportAuth Post \"%s\"", neUrl)
logger.Errorf("UDMImportAuth %s", errStr)
return "", fmt.Errorf("NeService UDM API Error")
}
// 序列化结果
if err = json.Unmarshal(resBytes, &resData); err != nil {
logger.Errorf("UDMImportAuth Unmarshal %s", err.Error())
return "", err
}
if v, ok := resData["code"]; ok && v == "00000" {
return strings.TrimSpace(strings.ToLower(resData["message"])), nil
}
return "", fmt.Errorf("%s", resData["message"])
}