Code Monkey home page Code Monkey logo

ok_api_sdk_go's Introduction

ok_api_sdk_go

Golang SDK for OK OpenAPI platform

Get started

Install requirements

yum install -y git

Prepare Go SDK

Download go SDK from: https://golang.org/dl/

Decompress it into /usr/local/go

Run:

export PATH=$PATH:/usr/local/go/bin
export GOROOT="/usr/local/go/"

Prepare working dir

mkdir /opt/go
cd /opt/go
export GOPATH=`pwd`

Download this project:

cd $GOPATH
go get github.com/OpsKitchen/ok_api_sdk_go

Customize your demo data

cd src/github.com/OpsKitchen/ok_api_sdk_go/

Edit example.go, replace the demo data

Run

go run example.go

Demo output is like this:

[root@dev67 example]# go run example.go
[DEBUG]: Gateway url: http://api.OpsKitchen.com/gw/json
[DEBUG]: Request body: api=ops.meta.os.list&version=1.0&timestamp=1466961052&params=null
[DEBUG]: Request header: map[Oa-App-Market-Id:[678] Oa-App-Version:[1.0.1] Oa-Device-Id:[08:00:27:bf:d4:5e] Oa-Session-Id:[] Oa-Sign:[81129ce782af9d0ce1f8b5419d00ab0b] Content-Type:[application/x-www-form-urlencoded] Oa-App-Key:[101]]
[DEBUG]: Response body: {"success":true,"data":[{"id":"3","name":"centos","pms":"yum","repoUrlSample":"http:\/\/ok.com\/centos\/$releasever\/$basearch","fullName":"Community ENTerprise OS","description":"i386\/x86_64","homepage":"","rank":"3","enabled":"1"}]}
&{0xc82000baa0   [map[enabled:1 id:3 name:centos pms:yum fullName:Community ENTerprise OS repoUrlSample:http://ok.com/centos/$releasever/$basearch description:i386/x86_64 homepage: rank:3]]}
[DEBUG]: Gateway url: http://api.OpsKitchen.com/gw/json
[DEBUG]: Request body: api=ops.meta.osImage.listByOsReleaseId&version=1.0&timestamp=1466961052&params={"osReleaseId":"3022"}
[DEBUG]: Request header: map[Oa-Sign:[3b89f21740a52dc4b750af96aee05c7d] Content-Type:[application/x-www-form-urlencoded] Oa-App-Key:[101] Oa-App-Market-Id:[678] Oa-App-Version:[1.0.1] Oa-Device-Id:[08:00:27:bf:d4:5e] Oa-Session-Id:[]]
[DEBUG]: Response body: {"success":true,"data":[{"id":"302207","osReleaseId":"3022","fullVersion":"6.7","repoSnapshotId":"307"},{"id":"302206","osReleaseId":"3022","fullVersion":"6.6","repoSnapshotId":"306"},{"id":"302205","osReleaseId":"3022","fullVersion":"6.5","repoSnapshotId":"305"},{"id":"302204","osReleaseId":"3022","fullVersion":"6.4","repoSnapshotId":"304"},{"id":"302203","osReleaseId":"3022","fullVersion":"6.3","repoSnapshotId":"303"},{"id":"302202","osReleaseId":"3022","fullVersion":"6.2","repoSnapshotId":"302"},{"id":"302201","osReleaseId":"3022","fullVersion":"6.1","repoSnapshotId":"301"},{"id":"302200","osReleaseId":"3022","fullVersion":"6.0","repoSnapshotId":"300"}]}
&{0xc8200f01b0   [map[id:302207 osReleaseId:3022 fullVersion:6.7 repoSnapshotId:307] map[id:302206 osReleaseId:3022 fullVersion:6.6 repoSnapshotId:306] map[osReleaseId:3022 fullVersion:6.5 repoSnapshotId:305 id:302205] map[fullVersion:6.4 repoSnapshotId:304 id:302204 osReleaseId:3022] map[id:302203 osReleaseId:3022 fullVersion:6.3 repoSnapshotId:303] map[id:302202 osReleaseId:3022 fullVersion:6.2 repoSnapshotId:302] map[id:302201 osReleaseId:3022 fullVersion:6.1 repoSnapshotId:301] map[id:302200 osReleaseId:3022 fullVersion:6.0 repoSnapshotId:300]]}

ok_api_sdk_go's People

Contributors

qinjx avatar 402918014 avatar

Watchers

James Cloos 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.