Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

open-gitlab.going-link.com/operation-sre/volc-sdk

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-gitlab.going-link.com/operation-sre/volc-sdk

  • v0.0.0-20220628092354-e07ce7fc1d08
  • Go
  • Socket score

Version published
Created
Source

火山引擎SDK for Go

欢迎使用火山引擎SDK for Go,本文档为您介绍如何获取及调用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"
  }

1. 使用案例

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

Package last updated on 28 Jun 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc