skytap-sdk-go

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0

README

Logo


Go version

Table of Contents

About

This package provides a Go client for the Skytap API. This is a fork of the origional. Please see acknowledgements.

Getting Started

Get started by installing the package:

go get -t github.com/YojimboSecurity/skytap-sdk-go

Prerequisites

All you need is Go.

Usage

First, create a client:

token := os.Getenv("SKYTAP_TOKEN")
user := os.Getenv("SKYTAP_USER")
if token == "" || user == "" {
    panic("SKYTAP_TOKEN and SKYTAP_USER must be set")
}
client := api.NewSkytapClient(user, token)

Here, I am using the environment variables to set the client. To set them, you can use the following command:

export SKYTAP_TOKEN=<your token>
export SKYTAP_USER=<your user>

Next, you can use the client to make API calls:

resp := interface{}(nil)
api.GetSkytapResource(*client, "https://cloud.skytap.com/v2/configurations?scope=company&count=40", &resp)

Here, I am using the GetSkytapResource method to make a call to the /v2/configurations endpoint. The resp variable is used to store the data. This returns all the environment configurations in the company.

To get an environment configuration, you can use the following call:

configurationId := "12345" // Replace with your configuration id
URL := fmt.Sprintf("https://cloud.skytap.com/v2/configurations/%s.json", configurationId)
resp := interface{}(nil)
api.GetSkytapResource(*client, URL, &resp)

To a virtual machine, you can use the following call:

vmId := "12345" // Replace with your virtual machine id
vm, err = api.GetVirtualMachine(*client, vmId)
if err != nil {
    log.Error(err)
}

To change the state of a virtual machine, you can use the following call:

vm, err := vm.Start(*client)
if err != nil {
    log.Error(err)
}

Test

The tests use canned API responses downloaded from the production service and slightly sanitized. Using this data, they validate that the API calls are being made correctly.

export GOPATH=`pwd`
go get -t github.com/skytap/skytap-sdk-go/api
cd api
go test -v

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Security

skytap-sdk-go follows good practices of security, but 100% security cannot be assured. skytap-sdk-go is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the Apache Software License 2.0.

See LICENSE for more information.

Acknowledgements

I would like to acknowledge that this is a fork of the original skytap-sdk-go project.

The two things I wanted to fix were:

  • case-insensitive import collision

  • go mod v2 issues

I would also like to thank the following projects for their contributions:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL