srijeet0406 commented on a change in pull request #6003:
URL: https://github.com/apache/trafficcontrol/pull/6003#discussion_r695906448
##########
File path: traffic_ops/v2-client/profile.go
##########
@@ -164,7 +164,8 @@ func (to *Session) GetProfileByName(name string)
([]tc.Profile, ReqInf, error) {
// GetProfileByParameter GETs a Profile by the Profile "param".
func (to *Session) GetProfileByParameter(param string) ([]tc.Profile, ReqInf,
error) {
- URI := fmt.Sprintf("%s?param=%s", API_PROFILES, url.QueryEscape(param))
+ paramId, _ := strconv.Atoi(url.QueryEscape(param))
Review comment:
We should probably check for the error here.
##########
File path: traffic_ops/v3-client/profile.go
##########
@@ -127,7 +127,7 @@ func (to *Session) GetProfileByName(name string)
([]tc.Profile, toclientlib.ReqI
}
func (to *Session) GetProfileByParameterWithHdr(param string, header
http.Header) ([]tc.Profile, toclientlib.ReqInf, error) {
- URI := fmt.Sprintf("%s?param=%s", APIProfiles, url.QueryEscape(param))
+ URI := fmt.Sprintf("%s?param=%s", APIProfiles, param)
Review comment:
Same comment as above here.
##########
File path: traffic_ops/v2-client/profile.go
##########
@@ -164,7 +164,8 @@ func (to *Session) GetProfileByName(name string)
([]tc.Profile, ReqInf, error) {
// GetProfileByParameter GETs a Profile by the Profile "param".
func (to *Session) GetProfileByParameter(param string) ([]tc.Profile, ReqInf,
error) {
- URI := fmt.Sprintf("%s?param=%s", API_PROFILES, url.QueryEscape(param))
+ paramId, _ := strconv.Atoi(url.QueryEscape(param))
Review comment:
Also, as I suggested earlier, instead of breaking the way pre existing
client methods work, why not create a new client method that takes in a param
ID instead of a param name, and then make the `GET` call? Something like this:
```
func (to *Session) GetProfileByParameterID(paramID string, header
http.Header) ([]tc.Profile, ReqInf, error) {
uri := fmt.Sprintf("%s?param=%d", APIProfiles, paramID)
var data tc.ProfilesResponse
reqInf, err := to.get(uri, header, &data)
return data.Response, reqInf, err
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]