mirror of https://github.com/hashicorp/packer
parent
a61716d4a4
commit
e26e533e9b
@ -1,55 +1,121 @@
|
||||
package profitbricks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/profitbricks/profitbricks-sdk-go/model"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDatacenterRequest struct {
|
||||
DCProperties `json:"properties"`
|
||||
type Datacenter struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties DatacenterProperties `json:"properties,omitempty"`
|
||||
Entities DatacenterEntities `json:"entities,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type DCProperties struct {
|
||||
type DatacenterElementMetadata struct {
|
||||
CreatedDate time.Time `json:"createdDate,omitempty"`
|
||||
CreatedBy string `json:"createdBy,omitempty"`
|
||||
Etag string `json:"etag,omitempty"`
|
||||
LastModifiedDate time.Time `json:"lastModifiedDate,omitempty"`
|
||||
LastModifiedBy string `json:"lastModifiedBy,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type DatacenterProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Version int32 `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type DatacenterEntities struct {
|
||||
Servers *Servers `json:"servers,omitempty"`
|
||||
Volumes *Volumes `json:"volumes,omitempty"`
|
||||
Loadbalancers *Loadbalancers `json:"loadbalancers,omitempty"`
|
||||
Lans *Lans `json:"lans,omitempty"`
|
||||
}
|
||||
|
||||
type Datacenters struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Datacenter `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
// ListDatacenters returns a Collection struct
|
||||
func ListDatacenters() Collection {
|
||||
func ListDatacenters() Datacenters {
|
||||
path := dc_col_path()
|
||||
return is_list(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
resp := do(req)
|
||||
return toDataCenters(resp)
|
||||
}
|
||||
|
||||
// CreateDatacenter creates a datacenter and returns a Instance struct
|
||||
func CreateDatacenter(dc CreateDatacenterRequest) Instance {
|
||||
func CreateDatacenter(dc Datacenter) Datacenter {
|
||||
obj, _ := json.Marshal(dc)
|
||||
path := dc_col_path()
|
||||
return is_post(path, obj)
|
||||
url := mk_url(path)
|
||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(obj))
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
|
||||
return toDataCenter(do(req))
|
||||
}
|
||||
|
||||
func CompositeCreateDatacenter(datacenter model.Datacenter) model.Datacenter {
|
||||
func CompositeCreateDatacenter(datacenter Datacenter) Datacenter {
|
||||
obj, _ := json.Marshal(datacenter)
|
||||
path := dc_col_path()
|
||||
return is_composite_post(path, obj)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(obj))
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toDataCenter(do(req))
|
||||
}
|
||||
|
||||
// GetDatacenter returns a Instance struct where id == dcid
|
||||
func GetDatacenter(dcid string) Instance {
|
||||
func GetDatacenter(dcid string) Datacenter {
|
||||
path := dc_path(dcid)
|
||||
return is_get(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toDataCenter(do(req))
|
||||
}
|
||||
|
||||
// PatchDatacenter replaces any Datacenter properties with the values in jason
|
||||
//returns an Instance struct where id ==dcid
|
||||
func PatchDatacenter(dcid string, obj map[string]string) Instance {
|
||||
func PatchDatacenter(dcid string, obj DatacenterProperties) Datacenter {
|
||||
jason_patch := []byte(MkJson(obj))
|
||||
path := dc_path(dcid)
|
||||
return is_patch(path, jason_patch)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(jason_patch))
|
||||
req.Header.Add("Content-Type", PatchHeader)
|
||||
return toDataCenter(do(req))
|
||||
}
|
||||
|
||||
// Deletes a Datacenter where id==dcid
|
||||
func DeleteDatacenter(dcid string) Resp {
|
||||
path := dc_path(dcid)
|
||||
return is_delete(path)
|
||||
}
|
||||
|
||||
func toDataCenter(resp Resp) Datacenter {
|
||||
var dc Datacenter
|
||||
json.Unmarshal(resp.Body, &dc)
|
||||
dc.Response = string(resp.Body)
|
||||
dc.Headers = &resp.Headers
|
||||
dc.StatusCode = resp.StatusCode
|
||||
return dc
|
||||
}
|
||||
|
||||
func toDataCenters(resp Resp) Datacenters {
|
||||
var col Datacenters
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
package profitbricks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type FirewallRule struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties FirewallruleProperties `json:"properties,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallruleProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
SourceMac string `json:"sourceMac,omitempty"`
|
||||
SourceIp string `json:"sourceIp,omitempty"`
|
||||
TargetIp string `json:"targetIp,omitempty"`
|
||||
IcmpCode int `json:"icmpCode,omitempty"`
|
||||
IcmpType int `json:"icmpType,omitempty"`
|
||||
PortRangeStart int `json:"portRangeStart,omitempty"`
|
||||
PortRangeEnd int `json:"portRangeEnd,omitempty"`
|
||||
}
|
||||
|
||||
type FirewallRules struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []FirewallRule `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
func ListFirewallRules(dcId string, serverid string, nicId string) FirewallRules {
|
||||
path := fwrule_col_path(dcId, serverid, nicId)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
resp := do(req)
|
||||
return toFirewallRules(resp)
|
||||
}
|
||||
|
||||
func GetFirewallRule(dcid string, srvid string, nicId string, fwId string) FirewallRule {
|
||||
path := fwrule_path(dcid, srvid, nicId, fwId)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
resp := do(req)
|
||||
return toFirewallRule(resp)
|
||||
}
|
||||
|
||||
func CreateFirewallRule(dcid string, srvid string, nicId string, fw FirewallRule) FirewallRule {
|
||||
path := fwrule_col_path(dcid, srvid, nicId)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
obj, _ := json.Marshal(fw)
|
||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(obj))
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toFirewallRule(do(req))
|
||||
}
|
||||
|
||||
func PatchFirewallRule(dcid string, srvid string, nicId string, fwId string, obj FirewallruleProperties) FirewallRule {
|
||||
jason_patch := []byte(MkJson(obj))
|
||||
path := fwrule_path(dcid, srvid, nicId, fwId)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(jason_patch))
|
||||
req.Header.Add("Content-Type", PatchHeader)
|
||||
return toFirewallRule(do(req))
|
||||
}
|
||||
|
||||
func DeleteFirewallRule(dcid string, srvid string, nicId string, fwId string) Resp {
|
||||
path := fwrule_path(dcid, srvid, nicId, fwId)
|
||||
return is_delete(path)
|
||||
}
|
||||
|
||||
func toFirewallRule(resp Resp) FirewallRule {
|
||||
var dc FirewallRule
|
||||
json.Unmarshal(resp.Body, &dc)
|
||||
dc.Response = string(resp.Body)
|
||||
dc.Headers = &resp.Headers
|
||||
dc.StatusCode = resp.StatusCode
|
||||
return dc
|
||||
}
|
||||
|
||||
func toFirewallRules(resp Resp) FirewallRules {
|
||||
var col FirewallRules
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
@ -1,27 +1,98 @@
|
||||
package profitbricks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Image struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties ImageProperties `json:"properties,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type ImageProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
|
||||
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
|
||||
RamHotPlug bool `json:"ramHotPlug,omitempty"`
|
||||
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
|
||||
NicHotPlug bool `json:"nicHotPlug,omitempty"`
|
||||
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
|
||||
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
|
||||
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
|
||||
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
|
||||
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
|
||||
LicenceType string `json:"licenceType,omitempty"`
|
||||
ImageType string `json:"imageType,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type Images struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Image `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type Cdroms struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Image `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
// ListImages returns an Collection struct
|
||||
func ListImages() Collection {
|
||||
func ListImages() Images {
|
||||
path := image_col_path()
|
||||
return is_list(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
resp := do(req)
|
||||
return toImages(resp)
|
||||
}
|
||||
|
||||
// GetImage returns an Instance struct where id ==imageid
|
||||
func GetImage(imageid string) Instance {
|
||||
func GetImage(imageid string) Image {
|
||||
path := image_path(imageid)
|
||||
return is_get(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
resp := do(req)
|
||||
return toImage(resp)
|
||||
}
|
||||
|
||||
// PatchImage replaces any image properties from values in jason
|
||||
//returns an Instance struct where id ==imageid
|
||||
func PatchImage(imageid string, obj map[string]string) Instance {
|
||||
jason := []byte(MkJson(obj))
|
||||
path := image_path(imageid)
|
||||
return is_patch(path, jason)
|
||||
func toImage(resp Resp) Image {
|
||||
var image Image
|
||||
json.Unmarshal(resp.Body, &image)
|
||||
image.Response = string(resp.Body)
|
||||
image.Headers = &resp.Headers
|
||||
image.StatusCode = resp.StatusCode
|
||||
return image
|
||||
}
|
||||
|
||||
// Deletes an image where id==imageid
|
||||
func DeleteImage(imageid string) Resp {
|
||||
path := image_path(imageid)
|
||||
return is_delete(path)
|
||||
func toImages(resp Resp) Images {
|
||||
var col Images
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
|
||||
@ -1,34 +1,82 @@
|
||||
package profitbricks
|
||||
|
||||
import "encoding/json"
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type IPBlockReserveRequest struct {
|
||||
IPBlockProperties `json:"properties"`
|
||||
type IpBlock struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties IpBlockProperties `json:"properties,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type IPBlockProperties struct {
|
||||
Size int `json:"size,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
type IpBlockProperties struct {
|
||||
Ips []string `json:"ips,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
type IpBlocks struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []IpBlock `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
// ListIpBlocks
|
||||
func ListIpBlocks() Collection {
|
||||
func ListIpBlocks() IpBlocks {
|
||||
path := ipblock_col_path()
|
||||
return is_list(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toIpBlocks(do(req))
|
||||
}
|
||||
|
||||
func ReserveIpBlock(request IPBlockReserveRequest) Instance {
|
||||
func ReserveIpBlock(request IpBlock) IpBlock {
|
||||
obj, _ := json.Marshal(request)
|
||||
path := ipblock_col_path()
|
||||
return is_post(path, obj)
|
||||
|
||||
url := mk_url(path)
|
||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(obj))
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toIpBlock(do(req))
|
||||
}
|
||||
func GetIpBlock(ipblockid string) Instance {
|
||||
func GetIpBlock(ipblockid string) IpBlock {
|
||||
path := ipblock_path(ipblockid)
|
||||
return is_get(path)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toIpBlock(do(req))
|
||||
}
|
||||
|
||||
func ReleaseIpBlock(ipblockid string) Resp {
|
||||
path := ipblock_path(ipblockid)
|
||||
return is_delete(path)
|
||||
}
|
||||
|
||||
func toIpBlock(resp Resp) IpBlock {
|
||||
var obj IpBlock
|
||||
json.Unmarshal(resp.Body, &obj)
|
||||
obj.Response = string(resp.Body)
|
||||
obj.Headers = &resp.Headers
|
||||
obj.StatusCode = resp.StatusCode
|
||||
return obj
|
||||
}
|
||||
|
||||
func toIpBlocks(resp Resp) IpBlocks {
|
||||
var col IpBlocks
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
|
||||
@ -1,11 +1,65 @@
|
||||
package profitbricks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Location struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties Properties `json:"properties,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type Locations struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Location `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type Properties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// ListLocations returns location collection data
|
||||
func ListLocations() Collection {
|
||||
return is_list(location_col_path())
|
||||
func ListLocations() Locations {
|
||||
url := mk_url(location_col_path()) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toLocations(do(req))
|
||||
}
|
||||
|
||||
// GetLocation returns location data
|
||||
func GetLocation(locid string) Instance {
|
||||
return is_get(location_path(locid))
|
||||
func GetLocation(locid string) Location {
|
||||
url := mk_url(location_path(locid)) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toLocation(do(req))
|
||||
}
|
||||
|
||||
func toLocation(resp Resp) Location {
|
||||
var obj Location
|
||||
json.Unmarshal(resp.Body, &obj)
|
||||
obj.Response = string(resp.Body)
|
||||
obj.Headers = &resp.Headers
|
||||
obj.StatusCode = resp.StatusCode
|
||||
return obj
|
||||
}
|
||||
|
||||
func toLocations(resp Resp) Locations {
|
||||
var col Locations
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type AttachedVolumes struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Volume `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type BalancedNics struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Nic `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Cdroms struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Image `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package model
|
||||
|
||||
import "net/http"
|
||||
|
||||
type Datacenter struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Properties DatacenterProperties `json:"properties,omitempty"`
|
||||
Entities DatacenterEntities `json:"entities,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
15
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterElementMetadata.go
generated
vendored
15
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterElementMetadata.go
generated
vendored
@ -1,15 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type DatacenterElementMetadata struct {
|
||||
CreatedDate time.Time `json:"createdDate,omitempty"`
|
||||
CreatedBy string `json:"createdBy,omitempty"`
|
||||
Etag string `json:"etag,omitempty"`
|
||||
LastModifiedDate time.Time `json:"lastModifiedDate,omitempty"`
|
||||
LastModifiedBy string `json:"lastModifiedBy,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
|
||||
}
|
||||
11
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterEntities.go
generated
vendored
11
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterEntities.go
generated
vendored
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type DatacenterEntities struct {
|
||||
Servers *Servers `json:"servers,omitempty"`
|
||||
Volumes *Volumes `json:"volumes,omitempty"`
|
||||
Loadbalancers *Loadbalancers `json:"loadbalancers,omitempty"`
|
||||
Lans *Lans `json:"lans,omitempty"`
|
||||
|
||||
}
|
||||
11
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterProperties.go
generated
vendored
11
vendor/github.com/profitbricks/profitbricks-sdk-go/model/DatacenterProperties.go
generated
vendored
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type DatacenterProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Version int32 `json:"version,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Datacenters struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Datacenter `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type FirewallRule struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties FirewallruleProperties `json:"properties,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type FirewallRules struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []FirewallRule `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
16
vendor/github.com/profitbricks/profitbricks-sdk-go/model/FirewallruleProperties.go
generated
vendored
16
vendor/github.com/profitbricks/profitbricks-sdk-go/model/FirewallruleProperties.go
generated
vendored
@ -1,16 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type FirewallruleProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
SourceMac string `json:"sourceMac,omitempty"`
|
||||
SourceIp string `json:"sourceIp,omitempty"`
|
||||
TargetIp string `json:"targetIp,omitempty"`
|
||||
IcmpCode int32 `json:"icmpCode,omitempty"`
|
||||
IcmpType int32 `json:"icmpType,omitempty"`
|
||||
PortRangeStart int32 `json:"portRangeStart,omitempty"`
|
||||
PortRangeEnd int32 `json:"portRangeEnd,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Image struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties ImageProperties `json:"properties,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type ImageProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
|
||||
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
|
||||
RamHotPlug bool `json:"ramHotPlug,omitempty"`
|
||||
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
|
||||
NicHotPlug bool `json:"nicHotPlug,omitempty"`
|
||||
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
|
||||
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
|
||||
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
|
||||
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
|
||||
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
|
||||
LicenceType string `json:"licenceType,omitempty"`
|
||||
ImageType string `json:"imageType,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Images struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Image `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Lan struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties LanProperties `json:"properties,omitempty"`
|
||||
Entities LanEntities `json:"entities,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type LanEntities struct {
|
||||
Nics *LanNics `json:"nics,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type LanNics struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Nic `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type LanProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Lans struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Lan `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Loadbalancer struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties LoadbalancerProperties `json:"properties,omitempty"`
|
||||
Entities LoadbalancerEntities `json:"entities,omitempty"`
|
||||
|
||||
}
|
||||
8
vendor/github.com/profitbricks/profitbricks-sdk-go/model/LoadbalancerEntities.go
generated
vendored
8
vendor/github.com/profitbricks/profitbricks-sdk-go/model/LoadbalancerEntities.go
generated
vendored
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type LoadbalancerEntities struct {
|
||||
Balancednics *BalancedNics `json:"balancednics,omitempty"`
|
||||
|
||||
}
|
||||
10
vendor/github.com/profitbricks/profitbricks-sdk-go/model/LoadbalancerProperties.go
generated
vendored
10
vendor/github.com/profitbricks/profitbricks-sdk-go/model/LoadbalancerProperties.go
generated
vendored
@ -1,10 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type LoadbalancerProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Ip string `json:"ip,omitempty"`
|
||||
Dhcp bool `json:"dhcp,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type Loadbalancers struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Loadbalancer `json:"items,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package model
|
||||
|
||||
type Nic struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
// Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties NicProperties `json:"properties,omitempty"`
|
||||
Entities *NicEntities `json:"entities,omitempty"`
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
package model
|
||||
|
||||
type NicEntities struct {
|
||||
Firewallrules *FirewallRules `json:"firewallrules,omitempty"`
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package model
|
||||
|
||||
|
||||
|
||||
type NicProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Mac string `json:"mac,omitempty"`
|
||||
Ips []string `json:"ips,omitempty"`
|
||||
Dhcp bool `json:"dhcp,omitempty"`
|
||||
Lan string `json:"lan,omitempty"`
|
||||
FirewallActive bool `json:"firewallActive,omitempty"`
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
type Nics struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Nic `json:"items,omitempty"`
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
package model
|
||||
|
||||
type Properties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package model
|
||||
|
||||
type ResourceReference struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package model
|
||||
|
||||
type Server struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
//Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties ServerProperties `json:"properties,omitempty"`
|
||||
Entities ServerEntities `json:"entities,omitempty"`
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package model
|
||||
|
||||
type ServerEntities struct {
|
||||
Cdroms *Cdroms `json:"cdroms,omitempty"`
|
||||
Volumes *AttachedVolumes `json:"volumes,omitempty"`
|
||||
Nics *Nics `json:"nics,omitempty"`
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package model
|
||||
|
||||
type ServerProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Cores int `json:"cores,omitempty"`
|
||||
Ram int `json:"ram,omitempty"`
|
||||
AvailabilityZone string `json:"availabilityZone,omitempty"`
|
||||
VmState string `json:"vmState,omitempty"`
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
type Servers struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Server `json:"items,omitempty"`
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
type Volume struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Properties VolumeProperties `json:"properties,omitempty"`
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package model
|
||||
|
||||
type VolumeProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
ImagePassword string `json:"imagePassword,omitempty"`
|
||||
SshKeys []string `json:"sshKeys,omitempty"`
|
||||
Bus string `json:"bus,omitempty"`
|
||||
LicenceType string `json:"licenceType,omitempty"`
|
||||
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
|
||||
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
|
||||
RamHotPlug bool `json:"ramHotPlug,omitempty"`
|
||||
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
|
||||
NicHotPlug bool `json:"nicHotPlug,omitempty"`
|
||||
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
|
||||
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
|
||||
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
|
||||
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
|
||||
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
|
||||
DeviceNumber int64 `json:"deviceNumber,omitempty"`
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package model
|
||||
|
||||
type Volumes struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Volume `json:"items,omitempty"`
|
||||
}
|
||||
@ -1,5 +1,43 @@
|
||||
package profitbricks
|
||||
|
||||
func GetRequestStatus(path string)Instance{
|
||||
return is_get(path)
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RequestStatus struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata RequestStatusMetadata `json:"metadata,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
type RequestStatusMetadata struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Etag string `json:"etag,omitempty"`
|
||||
Targets []RequestTarget `json:"targets,omitempty"`
|
||||
}
|
||||
|
||||
type RequestTarget struct {
|
||||
Target ResourceReference `json:"target,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
func GetRequestStatus(path string) RequestStatus {
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toRequestStatus(do(req))
|
||||
}
|
||||
|
||||
func toRequestStatus(resp Resp) RequestStatus {
|
||||
var server RequestStatus
|
||||
json.Unmarshal(resp.Body, &server)
|
||||
server.Response = string(resp.Body)
|
||||
server.Headers = &resp.Headers
|
||||
server.StatusCode = resp.StatusCode
|
||||
return server
|
||||
}
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
package profitbricks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Snapshot struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
|
||||
Properties SnapshotProperties `json:"properties,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
type SnapshotProperties struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
|
||||
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
|
||||
RamHotPlug bool `json:"ramHotPlug,omitempty"`
|
||||
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
|
||||
NicHotPlug bool `json:"nicHotPlug,omitempty"`
|
||||
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
|
||||
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
|
||||
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
|
||||
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
|
||||
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
|
||||
LicenceType string `json:"licenceType,omitempty"`
|
||||
}
|
||||
|
||||
type Snapshots struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Items []Snapshot `json:"items,omitempty"`
|
||||
Response string `json:"Response,omitempty"`
|
||||
Headers *http.Header `json:"headers,omitempty"`
|
||||
StatusCode int `json:"headers,omitempty"`
|
||||
}
|
||||
|
||||
func ListSnapshots() Snapshots {
|
||||
path := snapshot_col_path()
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toSnapshots(do(req))
|
||||
}
|
||||
|
||||
func GetSnapshot(snapshotId string) Snapshot {
|
||||
path := snapshot_col_path() + slash(snapshotId)
|
||||
url := mk_url(path) + `?depth=` + Depth
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return toSnapshot(do(req))
|
||||
}
|
||||
|
||||
func DeleteSnapshot(snapshotId string) Resp {
|
||||
path := snapshot_col_path() + slash(snapshotId)
|
||||
url := mk_url(path)
|
||||
req, _ := http.NewRequest("DELETE", url, nil)
|
||||
req.Header.Add("Content-Type", FullHeader)
|
||||
return do(req)
|
||||
}
|
||||
|
||||
func UpdateSnapshot(snapshotId string, request SnapshotProperties) Snapshot {
|
||||
path := snapshot_col_path() + slash(snapshotId)
|
||||
obj, _ := json.Marshal(request)
|
||||
url := mk_url(path)
|
||||
req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(obj))
|
||||
req.Header.Add("Content-Type", PatchHeader)
|
||||
return toSnapshot(do(req))
|
||||
}
|
||||
|
||||
func toSnapshot(resp Resp) Snapshot {
|
||||
var lan Snapshot
|
||||
json.Unmarshal(resp.Body, &lan)
|
||||
lan.Response = string(resp.Body)
|
||||
lan.Headers = &resp.Headers
|
||||
lan.StatusCode = resp.StatusCode
|
||||
return lan
|
||||
}
|
||||
func toSnapshots(resp Resp) Snapshots {
|
||||
var col Snapshots
|
||||
json.Unmarshal(resp.Body, &col)
|
||||
col.Response = string(resp.Body)
|
||||
col.Headers = &resp.Headers
|
||||
col.StatusCode = resp.StatusCode
|
||||
return col
|
||||
}
|
||||
Loading…
Reference in new issue