dongpo5239 2017-03-14 17:45
浏览 106

如何在Golang中编写客户端代码以调用createSnapshot软层API

Being new to Golang (in fact started learning it just a couple of days back) I have a very basic question on creating a client code for consuming the SL APIs.

So my requirement is to call a createsnapshot SL API using Golang which will take snapshot of my endurance volume, provided that volume id is a input parameter to it. Can you please help me with a sample code for writing this client ?

I know how to do it in python, here is how I did it python, but now I want it in golang (change in req. you know ;) )

python code snippet:

    client = SoftLayer.create_client_from_env("softlayer username", "softlayer apikey")
    result = client['SoftLayer_Network_Storage'].createSnapshot("snapshot_name", "volume id")

thank you !

  • 写回答

2条回答 默认 最新

  • dongxianrang9269 2017-03-14 18:31
    关注

    If i am not misunderstanding, you are using Softlayer package for python to do what you are doing in your given code.

    Softlayer has official go package as well here

    Download the package in your go environment by

    go get github.com/softlayer/softlayer-go/...

    Then import he package in your application and use it.

    basic Example:

    // 1. Create a session
    sess := session.New(username, apikey)
    
    // 2. Get a service
    accountService := services.GetAccountService(sess)
    
    // 3. Invoke a method:
    account, err := accountService.GetObject()
    

    You need to find methods that does the job for you.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错