Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.68 KB

README.md

File metadata and controls

59 lines (45 loc) · 1.68 KB

go-maxcdn

MaxCDN Golang API.

GoDoc Build Status

import "gopkg.in/MaxCDN/go-maxcdn.v2"

Package maxcdn is the Golang bindings for MaxCDN's REST API.

Developer Notes:

	// Basic Get
	max := maxcdn.NewMaxCDN(alias, token, secret)
	var got maxcdn.Generic
	res, err := max.Get(&got, "/account.json", nil)
	if err != nil {
		panic(err)
	}

	fmt.Printf("code: %d\n", res.Code)
	fmt.Printf("name: %s\n", got["name"].(string))

	// Basic Put
	form := url.Values{}
	form.Set("name", "new name")

	var put maxcdn.Generic
	if _, err = max.Put(&put, "/account.json", form); err == nil &&
		put["name"].(string) == "new name" {
		fmt.Println("name successfully updated")
	}

	// Basic Delete
	if _, err = max.Delete("/zones/pull.json/123456", nil); err == nil {
		fmt.Println("zone successfully deleted")
	}

    // Logs
    if logs, err := max.GetLogs(nil); err == nil {
        for _, line := range logs.Records {
            fmt.Println("%+v\n", line)
        }
    }