mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Upgrade vendor/github.com/prasmussen/gandi-api
This commit is contained in:
5
vendor/github.com/prasmussen/gandi-api/.gitignore
generated
vendored
Normal file
5
vendor/github.com/prasmussen/gandi-api/.gitignore
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# vim files
|
||||||
|
.*.sw[a-z]
|
||||||
|
*.un~
|
||||||
|
Session.vim
|
||||||
|
.netrwhist
|
16
vendor/github.com/prasmussen/gandi-api/README.md
generated
vendored
Normal file
16
vendor/github.com/prasmussen/gandi-api/README.md
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
gandi-api
|
||||||
|
=========
|
||||||
|
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
gandi-api is a go library for the [gandi.net API](http://doc.rpc.gandi.net/). See [gandi CLI tools](https://github.com/prasmussen/gandi)
|
||||||
|
and [gandi Restful Resource Records](https://github.com/prasmussen/gandi-rrr) for example usage.
|
||||||
|
|
||||||
|
### Godoc links
|
||||||
|
- [client](http://godoc.org/github.com/prasmussen/gandi-api/client)
|
||||||
|
- [contact](http://godoc.org/github.com/prasmussen/gandi-api/contact)
|
||||||
|
- [domain](http://godoc.org/github.com/prasmussen/gandi-api/domain)
|
||||||
|
- [zone](http://godoc.org/github.com/prasmussen/gandi-api/domain/zone)
|
||||||
|
- [record](http://godoc.org/github.com/prasmussen/gandi-api/domain/zone/record)
|
||||||
|
- [version](http://godoc.org/github.com/prasmussen/gandi-api/domain/zone/version)
|
||||||
|
- [operation](http://godoc.org/github.com/prasmussen/gandi-api/operation)
|
76
vendor/github.com/prasmussen/gandi-api/contact/contact.go
generated
vendored
Normal file
76
vendor/github.com/prasmussen/gandi-api/contact/contact.go
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package contact
|
||||||
|
|
||||||
|
import "github.com/prasmussen/gandi-api/client"
|
||||||
|
|
||||||
|
type Contact struct {
|
||||||
|
*client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(c *client.Client) *Contact {
|
||||||
|
return &Contact{c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get contact financial balance
|
||||||
|
func (self *Contact) Balance() (*BalanceInformation, error) {
|
||||||
|
var res map[string]interface{}
|
||||||
|
params := []interface{}{self.Key}
|
||||||
|
if err := self.Call("contact.balance", params, &res); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return toBalanceInformation(res), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get contact information
|
||||||
|
func (self *Contact) Info(handle string) (*ContactInformation, error) {
|
||||||
|
var res map[string]interface{}
|
||||||
|
|
||||||
|
var params []interface{}
|
||||||
|
if handle == "" {
|
||||||
|
params = []interface{}{self.Key}
|
||||||
|
} else {
|
||||||
|
params = []interface{}{self.Key, handle}
|
||||||
|
}
|
||||||
|
if err := self.Call("contact.info", params, &res); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return toContactInformation(res), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a contact
|
||||||
|
func (self *Contact) Create(opts ContactCreate) (*ContactInformation, error) {
|
||||||
|
var res map[string]interface{}
|
||||||
|
createArgs := map[string]interface{}{
|
||||||
|
"given": opts.Firstname,
|
||||||
|
"family": opts.Lastname,
|
||||||
|
"email": opts.Email,
|
||||||
|
"password": opts.Password,
|
||||||
|
"streetaddr": opts.Address,
|
||||||
|
"zip": opts.Zipcode,
|
||||||
|
"city": opts.City,
|
||||||
|
"country": opts.Country,
|
||||||
|
"phone": opts.Phone,
|
||||||
|
"type": opts.ContactType(),
|
||||||
|
}
|
||||||
|
|
||||||
|
params := []interface{}{self.Key, createArgs}
|
||||||
|
if err := self.Call("contact.create", params, &res); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return toContactInformation(res), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a contact
|
||||||
|
func (self *Contact) Delete(handle string) (bool, error) {
|
||||||
|
var res bool
|
||||||
|
|
||||||
|
var params []interface{}
|
||||||
|
if handle == "" {
|
||||||
|
params = []interface{}{self.Key}
|
||||||
|
} else {
|
||||||
|
params = []interface{}{self.Key, handle}
|
||||||
|
}
|
||||||
|
if err := self.Call("contact.delete", params, &res); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
80
vendor/github.com/prasmussen/gandi-api/contact/structs.go
generated
vendored
Normal file
80
vendor/github.com/prasmussen/gandi-api/contact/structs.go
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package contact
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PrepaidInformation struct {
|
||||||
|
Id int64
|
||||||
|
Amount string
|
||||||
|
Currency string
|
||||||
|
DateCreated time.Time
|
||||||
|
DateUpdated time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type BalanceInformation struct {
|
||||||
|
AnnualBalance string
|
||||||
|
Grid string
|
||||||
|
OutstandingAmount float64
|
||||||
|
Prepaid *PrepaidInformation
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContactInformation struct {
|
||||||
|
Firstname string
|
||||||
|
Lastname string
|
||||||
|
Email string
|
||||||
|
Address string
|
||||||
|
Zipcode string
|
||||||
|
City string
|
||||||
|
Country string
|
||||||
|
Phone string
|
||||||
|
ContactType int64
|
||||||
|
Handle string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self ContactInformation) ContactTypeString() string {
|
||||||
|
switch self.ContactType {
|
||||||
|
case 0:
|
||||||
|
return "Person"
|
||||||
|
case 1:
|
||||||
|
return "Company"
|
||||||
|
case 2:
|
||||||
|
return "Association"
|
||||||
|
case 3:
|
||||||
|
return "Public Body"
|
||||||
|
case 4:
|
||||||
|
return "Reseller"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContactCreate struct {
|
||||||
|
Firstname string `goptions:"--firstname, obligatory, description='First name'"`
|
||||||
|
Lastname string `goptions:"--lastname, obligatory, description='Last name'"`
|
||||||
|
Email string `goptions:"--email, obligatory, description='Email address'"`
|
||||||
|
Password string `goptions:"--password, obligatory, description='Password'"`
|
||||||
|
Address string `goptions:"--address, obligatory, description='Street address'"`
|
||||||
|
Zipcode string `goptions:"--zipcode, obligatory, description='Zip code'"`
|
||||||
|
City string `goptions:"--city, obligatory, description='City'"`
|
||||||
|
Country string `goptions:"--country, obligatory, description='Country'"`
|
||||||
|
Phone string `goptions:"--phone, obligatory, description='Phone number'"`
|
||||||
|
|
||||||
|
// Contact types
|
||||||
|
IsPerson bool `goptions:"--person, obligatory, mutexgroup='type', description='Contact type person'"`
|
||||||
|
IsCompany bool `goptions:"--company, obligatory, mutexgroup='type', description='Contact type company'"`
|
||||||
|
IsAssociation bool `goptions:"--association, obligatory, mutexgroup='type', description='Contact type association'"`
|
||||||
|
IsPublicBody bool `goptions:"--publicbody, obligatory, mutexgroup='type', description='Contact type public body'"`
|
||||||
|
IsReseller bool `goptions:"--reseller, obligatory, mutexgroup='type', description='Contact type reseller'"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self ContactCreate) ContactType() int {
|
||||||
|
if self.IsPerson { return 0 }
|
||||||
|
if self.IsCompany { return 1 }
|
||||||
|
if self.IsAssociation { return 2 }
|
||||||
|
if self.IsPublicBody { return 3 }
|
||||||
|
if self.IsReseller { return 4 }
|
||||||
|
|
||||||
|
// Default to person
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
39
vendor/github.com/prasmussen/gandi-api/contact/util.go
generated
vendored
Normal file
39
vendor/github.com/prasmussen/gandi-api/contact/util.go
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package contact
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prasmussen/gandi-api/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func toBalanceInformation(res map[string]interface{}) *BalanceInformation {
|
||||||
|
return &BalanceInformation{
|
||||||
|
AnnualBalance: util.ToString(res["annual_balance"]),
|
||||||
|
Grid: util.ToString(res["grid"]),
|
||||||
|
OutstandingAmount: util.ToFloat64(res["outstanding_amount"]),
|
||||||
|
Prepaid: toPrepaidInformation(util.ToXmlrpcStruct(res["prepaid"])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func toPrepaidInformation(res map[string]interface{}) *PrepaidInformation {
|
||||||
|
return &PrepaidInformation{
|
||||||
|
Id: util.ToInt64(res["id"]),
|
||||||
|
Amount: util.ToString(res["amount"]),
|
||||||
|
Currency: util.ToString(res["currency"]),
|
||||||
|
DateCreated: util.ToTime(res["date_created"]),
|
||||||
|
DateUpdated: util.ToTime(res["date_updated"]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func toContactInformation(res map[string]interface{}) *ContactInformation {
|
||||||
|
return &ContactInformation{
|
||||||
|
Firstname: util.ToString(res["given"]),
|
||||||
|
Lastname: util.ToString(res["family"]),
|
||||||
|
Email: util.ToString(res["email"]),
|
||||||
|
Address: util.ToString(res["streetaddr"]),
|
||||||
|
Zipcode: util.ToString(res["zip"]),
|
||||||
|
City: util.ToString(res["city"]),
|
||||||
|
Country: util.ToString(res["country"]),
|
||||||
|
Phone: util.ToString(res["phone"]),
|
||||||
|
ContactType: util.ToInt64(res["type"]),
|
||||||
|
Handle: util.ToString(res["handle"]),
|
||||||
|
}
|
||||||
|
}
|
2
vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go
generated
vendored
2
vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go
generated
vendored
@ -73,7 +73,7 @@ func (self *Record) Update(args RecordUpdate) ([]*RecordInfo, error) {
|
|||||||
"value": args.Value,
|
"value": args.Value,
|
||||||
"ttl": args.Ttl,
|
"ttl": args.Ttl,
|
||||||
}
|
}
|
||||||
updateOpts := map[string]int64{
|
updateOpts := map[string]string{
|
||||||
"id": args.Id,
|
"id": args.Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go
generated
vendored
4
vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go
generated
vendored
@ -1,7 +1,7 @@
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
type RecordInfo struct {
|
type RecordInfo struct {
|
||||||
Id int64
|
Id string
|
||||||
Name string
|
Name string
|
||||||
Ttl int64
|
Ttl int64
|
||||||
Type string
|
Type string
|
||||||
@ -24,7 +24,7 @@ type RecordUpdate struct {
|
|||||||
Type string `goptions:"-t, --type, obligatory, description='Record type'"`
|
Type string `goptions:"-t, --type, obligatory, description='Record type'"`
|
||||||
Value string `goptions:"-V, --value, obligatory, description='Value for record. Semantics depends on the record type.'"`
|
Value string `goptions:"-V, --value, obligatory, description='Value for record. Semantics depends on the record type.'"`
|
||||||
Ttl int64 `goptions:"-T, --ttl, description='Time to live, in seconds, between 5 minutes and 30 days'"`
|
Ttl int64 `goptions:"-T, --ttl, description='Time to live, in seconds, between 5 minutes and 30 days'"`
|
||||||
Id int64 `goptions:"-r, --record, obligatory, description='Record id'"`
|
Id string `goptions:"-r, --record, obligatory, description='Record id'"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecordSet map[string]interface{}
|
type RecordSet map[string]interface{}
|
||||||
|
17
vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go
generated
vendored
17
vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go
generated
vendored
@ -1,16 +1,15 @@
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prasmussen/gandi-api/util"
|
"github.com/prasmussen/gandi-api/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func ToRecordInfo(res map[string]interface{}) *RecordInfo {
|
func ToRecordInfo(res map[string]interface{}) *RecordInfo {
|
||||||
return &RecordInfo{
|
return &RecordInfo{
|
||||||
Id: util.ToInt64(res["id"]),
|
Id: util.ToString(res["id"]),
|
||||||
Name: util.ToString(res["name"]),
|
Name: util.ToString(res["name"]),
|
||||||
Ttl: util.ToInt64(res["ttl"]),
|
Ttl: util.ToInt64(res["ttl"]),
|
||||||
Type: util.ToString(res["type"]),
|
Type: util.ToString(res["type"]),
|
||||||
Value: util.ToString(res["value"]),
|
Value: util.ToString(res["value"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user