Code Monkey home page Code Monkey logo

kirk's Introduction

简介

本 SDK 基于 Golang 语言, 用于与 QINIU KIRK 通用计算服务(容器云)开放 API 的编程交互,提供了在开发者业务服务器(服务端或客户端)管理七牛容器云资源的能力。

Qiniu Logo

branch usage status
master (default) stable version Build Status GoDoc
develop develop version Build Status

安装

本 SDK 需要 go 1.7 以上版本

使用 go get 安装

$ go get -u qiniupkg.com/kirk/kirksdk

使用 glide 安装

  • 安装 glide 包管理工具
  • 在项目有中添加一个 import “qiniupkg.com/kirk/kirksdk” 的 .go 源文件,并执行如下命令。glide会自动扫描代码并下载需要的包
$ cd your_project_dir
$ glide init
$ glide install

示例

创建 App

import "qiniupkg.com/kirk/kirksdk"

...

cfg := kirksdk.AccountConfig{
	AccessKey: ACCESS_KEY,
	SecretKey: SECRET_KEY,
	Host:      kirksdk.DefaultAccountHost,
}

accountClient := kirksdk.NewAccountClient(cfg)

createdApp, err := accountClient.CreateApp(context.TODO(), "myapp", kirksdk.CreateAppArgs{
	Title:  "title",
	Region: "nq",
})

if err != nil {
// 错误处理
}

fmt.Println(createdApp.URI)

在 App 下创建 Service

import "qiniupkg.com/kirk/kirksdk"

...

qcosClient, err := accountClient.GetQcosClient(context.TODO(), createdApp.URI)
if err != nil {
// 错误处理
}

err = qcosClient.CreateService(context.TODO(), "mystack", kirksdk.CreateServiceArgs{
	Name: "myservice",
})
if err != nil {
// 错误处理
}

列出账号下所有镜像仓库

import "qiniupkg.com/kirk/kirksdk"

...

accountInfo, err := accountClient.GetAccountInfo(context.TODO())
if err != nil {
// 错误处理
}

indexClient, err := accountClient.GetIndexClient(context.TODO())
if err != nil {
// 错误处理
}

repos, err := indexClient.ListRepo(context.TODO(), accountInfo.Name)
if err != nil {
// 错误处理
}

for _, repo := range repos {
	fmt.Println(repo.Name)
}

参考

kirk's People

Contributors

nowenl avatar xiaoq08 avatar uoryon avatar wzjgo-zz avatar u2takey avatar randmonkey avatar maxim28 avatar kaijun avatar xushiwei avatar

Watchers

Li Xueli avatar  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.