dangogh commented on a change in pull request #3163: Fix Traffic Ops Tenancy 
and Activity Bugs, Fix TO API Test Framework to work with Tenancy
URL: https://github.com/apache/trafficcontrol/pull/3163#discussion_r244385609
 
 

 ##########
 File path: traffic_ops/client/deliveryserviceserver.go
 ##########
 @@ -42,3 +45,48 @@ func (to *Session) CreateDeliveryServiceServers(dsID int, 
serverIDs []int, repla
        }
        return &resp.Response, nil
 }
+
+func (to *Session) DeleteDeliveryServiceServer(dsID int, serverID int) 
(tc.Alerts, ReqInf, error) {
+       route := apiBase + `/deliveryservice_server/` + strconv.Itoa(dsID) + 
"/" + strconv.Itoa(serverID)
+       reqResp, remoteAddr, err := to.request(http.MethodDelete, route, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return tc.Alerts{}, reqInf, errors.New("requesting from Traffic 
Ops: " + err.Error())
+       }
+       defer reqResp.Body.Close()
+       resp := tc.Alerts{}
+       if err = json.NewDecoder(reqResp.Body).Decode(&resp); err != nil {
+               return tc.Alerts{}, reqInf, errors.New("decoding response: " + 
err.Error())
+       }
+       return resp, reqInf, nil
+}
+
+func (to *Session) GetDeliveryServiceServers() 
(tc.DeliveryServiceServerResponse, ReqInf, error) {
+       route := apiBase + `/deliveryserviceserver`
+       reqResp, remoteAddr, err := to.request(http.MethodGet, route, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return tc.DeliveryServiceServerResponse{}, reqInf, 
errors.New("requesting from Traffic Ops: " + err.Error())
+       }
+       defer reqResp.Body.Close()
+       resp := tc.DeliveryServiceServerResponse{}
+       if err = json.NewDecoder(reqResp.Body).Decode(&resp); err != nil {
+               return tc.DeliveryServiceServerResponse{}, reqInf, 
errors.New("decoding response: " + err.Error())
+       }
+       return resp, reqInf, nil
+}
+
+func (to *Session) GetDeliveryServiceServersN(n int) 
(tc.DeliveryServiceServerResponse, ReqInf, error) {
+       route := apiBase + `/deliveryserviceserver` + `?limit=` + 
strconv.Itoa(n)
+       reqResp, remoteAddr, err := to.request(http.MethodGet, route, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return tc.DeliveryServiceServerResponse{}, reqInf, 
errors.New("requesting from Traffic Ops: " + err.Error())
+       }
+       defer reqResp.Body.Close()
+       resp := tc.DeliveryServiceServerResponse{}
+       if err = json.NewDecoder(reqResp.Body).Decode(&resp); err != nil {
+               return tc.DeliveryServiceServerResponse{}, reqInf, 
errors.New("decoding response: " + err.Error())
+       }
+       return resp, reqInf, nil
 
 Review comment:
   that's a lot of duplicate code..  can the former call the latter with n=-1 
(for no limit)?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to