Esempio n. 1
0
func (nbe *netblockEndpoint) updateNetblock(req *restful.Request, res *restful.Response) {
	err := validateUpdateRequest(req)
	if err != nil {
		res.WriteError(http.StatusBadRequest, err)
		return
	}

	newnetblock := new(model.Netblock)
	err = req.ReadEntity(newnetblock)
	if err != nil {
		res.WriteErrorString(http.StatusInternalServerError, err.Error())
		return
	}

	filterNetblock(newnetblock)

	newnetblock.Uuid = req.PathParameter(param_name)

	nbe.Model.StoreNetblock(newnetblock)
	res.WriteHeader(http.StatusAccepted)
	res.WriteEntity(newnetblock)
}
Esempio n. 2
0
// this function removes data from the Netblock object
// before saving (fields which can never be set by
// the user...uuid, created, modified...)
func filterNetblock(n *model.Netblock) {
	_newnetblock := new(model.Netblock)
	n.Created = _newnetblock.Created
	n.Modified = _newnetblock.Modified
	n.Uuid = _newnetblock.Uuid
}