Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
open-gitlab.going-link.com/operation-sre/volc-sdk
请确保您已开通了您需要访问的服务。您可前往火山引擎控制台,在左侧菜单中选择或在顶部搜索栏中搜索您需要使用的服务,进入服务控制台内完成开通流程。
Access Key(访问密钥)是访问火山引擎服务的安全凭证,包含Access Key ID(简称为AK)和Secret Access Key(简称为SK)两部分。您可登录火山引擎控制台,前往“访问控制”的“访问密钥”中创建及管理您的Access Key。更多信息可参考访问密钥帮助文档。
Go版本需要不低于1.13.1。
go get -u open-gitlab.going-link.com/operation-sre/volc-sdk
火山引擎SDK for Go支持以下几种方式进行凭证管理:
注意:代码中Your AK及Your SK需要分别替换为您的AK及SK。
方式一:在Client中设置AK/SK (推荐)
iam.DefaultInstance.Client.SetAccessKey(Your AK)
iam.DefaultInstance.Client.SetSecretKey(Your SK)
方式二:从环境变量加载AK/SK
VOLC_ACCESSKEY="Your AK"
VOLC_SECRETKEY="Your SK"
方式三:从HOME文件加载AK/SK
在本地的~/.volc/config中添加如下内容:
{
"ak": "Your AK",
"sk": "Your SK"
}
var (
AK = "ak"
SK = "sk"
)
func main() {
iam.DefaultInstance.Client.SetAccessKey(AK)
iam.DefaultInstance.Client.SetSecretKey(SK)
// 新增用户
addUserQuery := url.Values{}
addUserQuery.Add("UserName", "test.test")
addUserQuery.Add("DisplayName", "测试")
addUserQuery.Add("MobilePhone", "13341638813")
addUserQuery.Add("Email", "test@going-link.com")
addUserResp, statusCode, err := iam.DefaultInstance.CreateUser(addUserQuery)
if err != nil {
return
}
fmt.Println(statusCode)
fmt.Println(addUserResp.Result.User)
// 设置登录密码
query := url.Values{}
query.Add("UserName", "test.test")
query.Add("Password", "WWww#123")
query.Add("LoginAllowed", "true")
p, status, err := iam.DefaultInstance.CreateLoginProfile(query)
fmt.Println(p, status, err)
// 查询
//p, status, err := iam.DefaultInstance.GetLoginProfile(query)
//fmt.Println(p, status, err)
// 删除用户
delUserQuery := url.Values{}
delUserQuery.Add("UserName", "test.ttt")
resp, statusCode, err := iam.DefaultInstance.DeleteUser(delUserQuery)
if err != nil {
return
}
fmt.Println(statusCode)
fmt.Println(resp)
// 查询所有用户
list, status, err := iam.DefaultInstance.ListUsers(nil)
fmt.Println(status, err)
b, _ := json.Marshal(list)
fmt.Println(string(b))
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.