ocket8888 commented on a change in pull request #3964: Add GET/POST/DELETE for 
server_server_capabilities
URL: https://github.com/apache/trafficcontrol/pull/3964#discussion_r334676891
 
 

 ##########
 File path: traffic_ops/client/server_server_capabilities.go
 ##########
 @@ -0,0 +1,79 @@
+/*
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+
+package client
+
+import (
+       "encoding/json"
+       "fmt"
+       "net"
+       "net/url"
+       "strconv"
+
+       "github.com/apache/trafficcontrol/lib/go-tc"
+)
+
+const (
+       API_v14_Server_Server_Capabilities = apiBase + 
"/server_server_capabilities"
+)
+
+// CreateServerServerCapability assigns a Server Capability to a Server
+func (to *Session) CreateServerServerCapability(ssc tc.ServerServerCapability) 
(tc.Alerts, ReqInf, error) {
+       var alerts tc.Alerts
+       var remoteAddr net.Addr
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       reqBody, err := json.Marshal(ssc)
+       if err != nil {
+               return tc.Alerts{}, reqInf, err
+       }
+       reqInf, err = post(to, API_v14_Server_Server_Capabilities, reqBody, 
&alerts)
+       return alerts, reqInf, err
+}
+
+// DeleteServerServerCapability unassigns a Server Capability from a Server
+func (to *Session) DeleteServerServerCapability(serverID int, serverCapability 
string) (tc.Alerts, ReqInf, error) {
+       var alerts tc.Alerts
+       endpoint := fmt.Sprintf("%v?serverId=%v&serverCapability=%v", 
API_v14_Server_Server_Capabilities, serverID, serverCapability)
 
 Review comment:
   Do you wanna use `net/url` to encode these parameters?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to