Coder Social home page Coder Social logo

shopglobal / go-digitalocean Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urashidmalik/go-digitalocean

0.0 3.0 0.0 244 KB

GO digital ocean API for version 2 and version 1. As of now only version 2 is implemented

License: MIT License

Go 100.00%

go-digitalocean's Introduction

Build Status

go-digitalocean

GO digital ocean API for version 2 and version 1. As of now only version 2 is implemented

Usage

use go get github/urashidmalik/go-digitalocean to get the library.

Configuration

  • Copy github.com/urashidmalik/go-digitalocean/config.json file
  • Update your digitalocean API KEY
  • Place file in your $GOPATH
  • E.G

myProj

├──config.json
├──bin
├──pkg
└──src

└─────github.com/

Sample config.json file

{
	"API_TOKEN":"API_KEY_GOES_HERE"
}

Importing and Using go-digitalocean Library in you program

Basic Usage
package main

import (
	"github.com/urashidmalik/go-digitalocean/digitalocean"
	"github.com/urashidmalik/go-digitalocean/digitalocean/v2"
	"log"
)

func main() {
	var client digitalocean.DoProvisioner
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
	client = digitalocean.NewDoClient(digitalocean.APIV2)
	
	// Basic Usage
	listDropletResponseBasic, _ := client.ListDroplets()
	// Please remember you will get Interface Object which you can cast to *v2.ListDropletResponse
	log.Printf("Droplet List %v", listDropletRes.(*v2.ListDropletResponse))
}
Usage with Error Handling
package main

import (
    "github.com/urashidmalik/go-digitalocean/digitalocean"
    "github.com/urashidmalik/go-digitalocean/digitalocean/v2"
    "log"
)

func main() {
    var client digitalocean.DoProvisioner
    log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
    client = digitalocean.NewDoClient(digitalocean.APIV2)
        // Usage with error Handling
    if listDropletRes, errL := client.ListDroplets(); errL != nil {
        log.Printf("Houston We have Problem :%v", errL)
    } else {
        log.Printf("Droplet List %v", listDropletRes.(*v2.ListDropletResponse))
    }
}

Implemented Functionality (API version 2)

Droplet
  • Create Droplet
  • List all Droplets
  • Delete a Droplet
  • All Droplet Events
  • Reboot a Droplet
  • Power Cycle a Droplet
  • Shutdown a Droplet
  • Power Off a Droplet
  • Power On a Droplet
  • Password Reset for Droplet
  • Resize a Droplet
  • Restore a Droplet
  • Rebuild a Droplet
  • Rename a Droplet
  • Enable IPv6 for Droplet
  • Disable Backups for Droplet
  • Enable Private Networking on Droplet
  • Take a Droplet Snapshot
Domain
  • List all Domains
  • Show Domain Information
  • Create a Domain
  • Delete a Domain
Domain Records
  • Create AAAA Domain Record
  • Create A Domain Record
  • Create MX Domain Record
  • Create TXT Domain Record
  • Create SRV Domain Record
  • Create NS Domain Record
  • List Domain Records
  • Show Domain Record
  • Delete Domain Record
Images
  • List Images

go-digitalocean's People

Contributors

urashidmalik avatar

Watchers

James Cloos avatar ⛓️INTERCHAINED ⚡Electronero Network ʕ•̫͡•ʔ-̫͡-ʕ•͓͡•ʔ-̫͡-ʕ•̫͡•ʔ-̫͡-ʔ 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.