func (gnp *genericNetworksProvider) RemoveRouterInterface(routerId string, portId string) error {

	ep := gnp.endpoint + "/v2.0/routers/" + routerId + "/remove_router_interface"
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			PortId string `json:"port_id"`
		}{portId},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return err
}
func (gnp *genericNetworksProvider) UnassociateFloatingIp(floatingIpId string) error {
	floatingIp := FloatingIp{}

	ep := gnp.endpoint + "/v2.0/floatingips/" + floatingIpId
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			FloatingIp *FloatingIp `json:"floatingip"`
		}{&floatingIp},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return err
}
func (gnp *genericNetworksProvider) UpdateNetwork(networkId string, updatedNetwork UpdatedNetwork) (*Network, error) {
	var n *Network

	ep := gnp.endpoint + "/v2.0/networks/" + networkId
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			UpdatedNetwork *UpdatedNetwork `json:"network"`
		}{&updatedNetwork},
		Results: &struct{ Network **Network }{&n},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return n, err
}
func (gnp *genericNetworksProvider) UpdateRouter(router Router) (*Router, error) {
	var r *Router

	ep := gnp.endpoint + "/v2.0/routers/" + router.Id
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			router Router `json:"router"`
		}{router},
		Results: &struct{ Router **Router }{&r},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return r, err
}
func (gnp *genericNetworksProvider) AddRouterInterface(routerId string, subnetId string) (*Port, error) {
	var portId *Port

	ep := gnp.endpoint + "/v2.0/routers/" + routerId + "/add_router_interface"
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			SubnetId string `json:"subnet_id"`
		}{subnetId},
		Results: &struct{ Port **Port }{&portId},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return portId, err
}
func (gnp *genericNetworksProvider) UpdateSubnet(subnetId string, updatedSubnet UpdatedSubnet) (*Subnet, error) {
	var s *Subnet

	ep := gnp.endpoint + "/v2.0/subnets/" + subnetId
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			UpdatedSubnet *UpdatedSubnet `json:"subnet"`
		}{&updatedSubnet},
		Results: &struct{ Subnet **Subnet }{&s},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return s, err
}
Exemple #7
0
// See the CloudServersProvider interface for details
func (gsp *genericServersProvider) UpdateServer(id string, changes NewServerSettings) (*Server, error) {
	var svr *Server
	err := gsp.context.WithReauth(gsp.access, func() error {
		url := fmt.Sprintf("%s/servers/%s", gsp.endpoint, id)
		return perigee.Put(url, perigee.Options{
			ReqBody: &struct {
				Server NewServerSettings `json:"server"`
			}{changes},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
			Results: &struct {
				Server **Server `json:"server"`
			}{&svr},
		})
	})
	return svr, err
}
func (gnp *genericNetworksProvider) UpdatePool(pool Pool) (*Pool, error) {
	var updatedPool *Pool

	ep := gnp.endpoint + "/v2.0/lb/pools/" + pool.Id

	pool.Id = "" // remove read-only attribute
	err := perigee.Put(ep, perigee.Options{
		ReqBody: &struct {
			Pool *Pool `json:"pool"`
		}{&pool},
		Results: &struct{ Pool **Pool }{&updatedPool},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{200},
	})

	return updatedPool, err
}