mattjackson220 commented on a change in pull request #4477: Deprecate
parameters/profile/:name
URL: https://github.com/apache/trafficcontrol/pull/4477#discussion_r391799320
##########
File path:
traffic_ops/traffic_ops_golang/profileparameter/parameterprofilebyname.go
##########
@@ -22,20 +22,59 @@ package profileparameter
import (
"database/sql"
"errors"
+ "github.com/apache/trafficcontrol/lib/go-util"
"net/http"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
)
+const API_PROFILES_NAME_NAME_PARAMETERS = "profiles/name/:name/parameters"
+
+func GetProfileNameDeprecated(w http.ResponseWriter, r *http.Request) {
+ getProfileName(w, r, true)
+}
+
func GetProfileName(w http.ResponseWriter, r *http.Request) {
+ getProfileName(w, r, false)
+}
+
+func deprecationString(deprecated bool) *string {
+ if deprecated {
+ return util.StrPtr(API_PROFILES_NAME_NAME_PARAMETERS)
+ } else {
+ return nil
+ }
+}
+
+func getProfileName(w http.ResponseWriter, r *http.Request, deprecated bool) {
+ deprecation := deprecationString(deprecated)
inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"name"}, nil)
if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+ if deprecation == nil {
+ api.HandleDeprecatedErr(w, r, inf.Tx.Tx, errCode,
userErr, sysErr, deprecation)
+ } else {
+ api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+ }
return
}
defer inf.Close()
- api.RespWriter(w, r, inf.Tx.Tx)(getParametersByProfileName(inf.Tx.Tx,
inf.Params["name"]))
+
+ name := inf.Params["name"]
+ if deprecated {
+ profiles, err := getParametersByProfileName(inf.Tx.Tx, name)
+ if err != nil {
+ if deprecation == nil {
+ api.HandleDeprecatedErr(w, r, inf.Tx.Tx,
http.StatusInternalServerError, err, nil, deprecation)
+ } else {
+ api.HandleErr(w, r, inf.Tx.Tx,
http.StatusInternalServerError, err, nil)
+ }
+ return
+ }
+ api.WriteAlertsObj(w, r, http.StatusOK,
api.CreateDeprecationAlerts(nil), profiles)
Review comment:
should have alternative in the api.CreateDeprecationAlerts
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services