This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 609906d69103de498bf3d59c93c48338348d50ea
Author: Dewayne Richardson <dewr...@apache.org>
AuthorDate: Thu Mar 1 12:22:18 2018 -0700

    added name and configfile API calls
    
    added setup and teardown of parameters
    
    tweaked the url formatter
---
 traffic_ops/client/v13/parameter.go                | 40 ++++++++++++++++++++--
 .../api/v13/deliveryservice_requests_test.go       |  3 ++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/traffic_ops/client/v13/parameter.go 
b/traffic_ops/client/v13/parameter.go
index 6b5c4ce..94cf583 100644
--- a/traffic_ops/client/v13/parameter.go
+++ b/traffic_ops/client/v13/parameter.go
@@ -118,10 +118,46 @@ func (to *Session) GetParameterByName(name string) 
([]tc.Parameter, ReqInf, erro
        return data.Response, reqInf, nil
 }
 
+// GET a Parameter by the Parameter ConfigFile
+func (to *Session) GetParameterByConfigFile(configFile string) 
([]tc.Parameter, ReqInf, error) {
+       URI := API_v13_Parameters + "?configFile=" + url.QueryEscape(configFile)
+       resp, remoteAddr, err := to.request(http.MethodGet, URI, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data tc.ParametersResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return data.Response, reqInf, nil
+}
+
+// GET a Parameter by the Parameter Name and ConfigFile
+func (to *Session) GetParameterByNameAndConfigFile(name string, configFile 
string) ([]tc.Parameter, ReqInf, error) {
+       URI := fmt.Sprintf("%s?name=%s&configFile=%s", API_v13_Parameters, 
url.QueryEscape(name), url.QueryEscape(configFile))
+       resp, remoteAddr, err := to.request(http.MethodGet, URI, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data tc.ParametersResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return data.Response, reqInf, nil
+}
+
 // DELETE a Parameter by ID
 func (to *Session) DeleteParameterByID(id int) (tc.Alerts, ReqInf, error) {
-       route := fmt.Sprintf("%s/%d", API_v13_Parameters, id)
-       resp, remoteAddr, err := to.request(http.MethodDelete, route, nil)
+       URI := fmt.Sprintf("%s/%d", API_v13_Parameters, id)
+       resp, remoteAddr, err := to.request(http.MethodDelete, URI, nil)
        reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
        if err != nil {
                return tc.Alerts{}, reqInf, err
diff --git a/traffic_ops/testing/api/v13/deliveryservice_requests_test.go 
b/traffic_ops/testing/api/v13/deliveryservice_requests_test.go
index 9648e3c..ac8e97a 100644
--- a/traffic_ops/testing/api/v13/deliveryservice_requests_test.go
+++ b/traffic_ops/testing/api/v13/deliveryservice_requests_test.go
@@ -106,6 +106,8 @@ func TestDeliveryServiceRequestRules(t *testing.T) {
 }
 
 func TestDeliveryServiceRequestTypeFields(t *testing.T) {
+       CreateTestParameters(t)
+
        dsr := testData.DeliveryServiceRequests[dsrBadTenant]
        alerts, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
        if err != nil {
@@ -118,6 +120,7 @@ func TestDeliveryServiceRequestTypeFields(t *testing.T) {
        }
 
        utils.Compare(t, expected, alerts.ToStrings())
+       DeleteTestParameters(t)
 
 }
 

-- 
To stop receiving notification emails like this one, please contact
dang...@apache.org.

Reply via email to