diff --git a/vendor/github.com/prasmussen/gandi-api/.gitignore b/vendor/github.com/prasmussen/gandi-api/.gitignore new file mode 100644 index 000000000..f58a54fda --- /dev/null +++ b/vendor/github.com/prasmussen/gandi-api/.gitignore @@ -0,0 +1,5 @@ +# vim files +.*.sw[a-z] +*.un~ +Session.vim +.netrwhist diff --git a/vendor/github.com/prasmussen/gandi-api/README.md b/vendor/github.com/prasmussen/gandi-api/README.md new file mode 100644 index 000000000..b115fab29 --- /dev/null +++ b/vendor/github.com/prasmussen/gandi-api/README.md @@ -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) diff --git a/vendor/github.com/prasmussen/gandi-api/contact/contact.go b/vendor/github.com/prasmussen/gandi-api/contact/contact.go new file mode 100644 index 000000000..c4b6cf5d0 --- /dev/null +++ b/vendor/github.com/prasmussen/gandi-api/contact/contact.go @@ -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 +} diff --git a/vendor/github.com/prasmussen/gandi-api/contact/structs.go b/vendor/github.com/prasmussen/gandi-api/contact/structs.go new file mode 100644 index 000000000..285463035 --- /dev/null +++ b/vendor/github.com/prasmussen/gandi-api/contact/structs.go @@ -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 +} + diff --git a/vendor/github.com/prasmussen/gandi-api/contact/util.go b/vendor/github.com/prasmussen/gandi-api/contact/util.go new file mode 100644 index 000000000..f267dd910 --- /dev/null +++ b/vendor/github.com/prasmussen/gandi-api/contact/util.go @@ -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"]), + } +} diff --git a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go index ead956456..199bc4c2a 100644 --- a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go +++ b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/record.go @@ -73,7 +73,7 @@ func (self *Record) Update(args RecordUpdate) ([]*RecordInfo, error) { "value": args.Value, "ttl": args.Ttl, } - updateOpts := map[string]int64{ + updateOpts := map[string]string{ "id": args.Id, } diff --git a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go index 03d253c72..ea9fd143d 100644 --- a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go +++ b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/structs.go @@ -1,7 +1,7 @@ package record type RecordInfo struct { - Id int64 + Id string Name string Ttl int64 Type string @@ -24,7 +24,7 @@ type RecordUpdate struct { 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.'"` 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{} diff --git a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go index 5560f0daf..9a6add585 100644 --- a/vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go +++ b/vendor/github.com/prasmussen/gandi-api/domain/zone/record/util.go @@ -1,16 +1,15 @@ package record import ( - "github.com/prasmussen/gandi-api/util" + "github.com/prasmussen/gandi-api/util" ) - func ToRecordInfo(res map[string]interface{}) *RecordInfo { - return &RecordInfo{ - Id: util.ToInt64(res["id"]), - Name: util.ToString(res["name"]), - Ttl: util.ToInt64(res["ttl"]), - Type: util.ToString(res["type"]), - Value: util.ToString(res["value"]), - } + return &RecordInfo{ + Id: util.ToString(res["id"]), + Name: util.ToString(res["name"]), + Ttl: util.ToInt64(res["ttl"]), + Type: util.ToString(res["type"]), + Value: util.ToString(res["value"]), + } }