Git Product home page Git Product logo

ksc-sdk-go's Introduction

KSC SDK for Go

概述

  1. 金山云Go语言SDK
  2. Go语言版本1.5+ 推荐是用1.12+ 这样方便使用govendor
  3. service目录下的文件请不要修改,都是由代码生成器自动生成 代码生成器暂时不开源
  4. 如果使用vendor 请确保所有ksc-sdk-go 在GOPATH下面/src/github.com/KscSDK目录下 ($GOPATH/src/github.com/KscSDK)
vendor

使用vendor(Go 1.5+)做依赖的话可以直接使用本sdk工具

Go 1.5

需要去AWS-SDK-GO 下载后,拷贝aws-sdk-go到在GOPATH下面/src/github.com/aws目录下 ($GOPATH/src/github.com/aws)目录下 或者使用 go get github.com/aws/aws-sdk-go

代码示例

UseInternal:true 代表使用金山云内网域名

代码示例在example目录下

ak := "用户AK"
sk := "用户SK"
region := "cn-beijing-6"
svc := vpc.SdkNew(ksc.NewClient(ak, sk), &ksc.Config{Region: &region}, &utils.UrlInfo{
		UseSSL: true,
		UseInternal:true,
	})

//创建入参 参考 https://docs.ksyun.com/
m_vpc := make(map[string]interface{})
m_vpc["VpcId.1"] = "VPCID"

//查询VPC信息
resp, err := svc.DescribeVpcs(&m_vpc)
if err != nil {
	fmt.Println("there was an error listing instances in", err.Error())
}
if resp != nil {
	l := (*resp)["VpcSet"].([]interface{})
	for i := 0; i < len(l); i++ {
		item := l[i].(map[string]interface{})
		fmt.Printf("%+v:%+v\n", item["VpcId"], item["VpcName"])
	}
}
//创建入参 参考 https://docs.ksyun.com/
m_vnet := make(map[string]interface{})

//查询子网信息
resp1, err1 := svc.DescribeSubnets(&m_vnet)
if err1 != nil {
	fmt.Println("there was an error listing instances in", err1.Error())
}
if resp1 != nil {
	l := (*resp1)["SubnetSet"].([]interface{})
	for i := 0; i < len(l); i++ {
		item := l[i].(map[string]interface{})
		fmt.Printf("%+v:%+v\n", item["SubnetId"], item["SubnetName"])
	}
}

ksc-sdk-go's People

Contributors

xuyaming0800 avatar xuyaming-ksc avatar jwp001 avatar codesdk123 avatar 282857484 avatar nanyawang avatar sunxingbao avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.