You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/07/11 01:19:57 UTC

[trafficcontrol] 10/13: updated to use parameters instead of path params

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

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

commit 955bf8a0d963bccac5a6b063d16c5cb0aa38ea52
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Jun 25 12:01:42 2018 -0600

    updated to use parameters instead of path params
---
 traffic_ops/client/v13/staticdnsentry.go             | 10 +++++-----
 traffic_ops/testing/api/v13/staticdnsentries_test.go |  4 ++--
 traffic_ops/testing/api/v13/tc-fixtures.json         |  6 +++---
 traffic_ops/traffic_ops_golang/routes.go             |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/traffic_ops/client/v13/staticdnsentry.go b/traffic_ops/client/v13/staticdnsentry.go
index 45eca07..15e1a42 100644
--- a/traffic_ops/client/v13/staticdnsentry.go
+++ b/traffic_ops/client/v13/staticdnsentry.go
@@ -21,8 +21,8 @@ import (
 	"net"
 	"net/http"
 
-	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
-	"github.com/apache/incubator-trafficcontrol/lib/go-tc/v13"
+	"github.com/apache/trafficcontrol/lib/go-tc"
+	"github.com/apache/trafficcontrol/lib/go-tc/v13"
 )
 
 const (
@@ -57,7 +57,7 @@ func (to *Session) UpdateStaticDNSEntryByID(id int, cdn v13.StaticDNSEntry) (tc.
 	if err != nil {
 		return tc.Alerts{}, reqInf, err
 	}
-	route := fmt.Sprintf("%s/%d", API_v13_StaticDNSEntries, id)
+	route := fmt.Sprintf("%s?id=%d", API_v13_StaticDNSEntries, id)
 	resp, remoteAddr, err := to.request(http.MethodPut, route, reqBody)
 	if err != nil {
 		return tc.Alerts{}, reqInf, err
@@ -84,7 +84,7 @@ func (to *Session) GetStaticDNSEntries() ([]v13.StaticDNSEntry, ReqInf, error) {
 
 // GET a StaticDNSEntry by the StaticDNSEntry ID
 func (to *Session) GetStaticDNSEntryByID(id int) ([]v13.StaticDNSEntry, ReqInf, error) {
-	route := fmt.Sprintf("%s/%d", API_v13_StaticDNSEntries, id)
+	route := fmt.Sprintf("%s?id=%d", API_v13_StaticDNSEntries, id)
 	resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
 	reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
 	if err != nil {
@@ -120,7 +120,7 @@ func (to *Session) GetStaticDNSEntriesByHost(host string) ([]v13.StaticDNSEntry,
 
 // DELETE a StaticDNSEntry by ID
 func (to *Session) DeleteStaticDNSEntryByID(id int) (tc.Alerts, ReqInf, error) {
-	route := fmt.Sprintf("%s/%d", API_v13_StaticDNSEntries, id)
+	route := fmt.Sprintf("%s?id=%d", API_v13_StaticDNSEntries, id)
 	resp, remoteAddr, err := to.request(http.MethodDelete, route, nil)
 	reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
 	if err != nil {
diff --git a/traffic_ops/testing/api/v13/staticdnsentries_test.go b/traffic_ops/testing/api/v13/staticdnsentries_test.go
index b74336d..9dad333 100644
--- a/traffic_ops/testing/api/v13/staticdnsentries_test.go
+++ b/traffic_ops/testing/api/v13/staticdnsentries_test.go
@@ -18,8 +18,8 @@ package v13
 import (
 	"testing"
 
-	"github.com/apache/incubator-trafficcontrol/lib/go-log"
-	tc "github.com/apache/incubator-trafficcontrol/lib/go-tc"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	tc "github.com/apache/trafficcontrol/lib/go-tc"
 )
 
 func TestStaticDNSEntries(t *testing.T) {
diff --git a/traffic_ops/testing/api/v13/tc-fixtures.json b/traffic_ops/testing/api/v13/tc-fixtures.json
index 3381924..e6b7c37 100644
--- a/traffic_ops/testing/api/v13/tc-fixtures.json
+++ b/traffic_ops/testing/api/v13/tc-fixtures.json
@@ -1026,7 +1026,7 @@
         {
             "address": "address1",
             "cachegroup": "cachegroup1",
-            "deliveryservice": "test-ds1",
+            "deliveryservice": "ds1",
             "host": "host1",
             "type": "AAAA_RECORD",
             "ttl": 10
@@ -1034,14 +1034,14 @@
         {
             "address": "address2",
             "cachegroup": "cachegroup2",
-            "deliveryservice": "test-ds1",
+            "deliveryservice": "ds1",
             "host": "host2",
             "type": "A_RECORD",
             "ttl": 10
         },
         {
             "host": "host3",
-            "deliveryservice": "test-ds1",
+            "deliveryservice": "ds1",
             "cachegroup": "cachegroup2",
             "address": "127.0.0.1",
             "type": "CNAME_RECORD",
diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index d976577..dc79fb6 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -318,10 +318,10 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 		//StaticDNSEntries
 		{1.1, http.MethodGet, `staticdnsentries/?(\.json)?$`, api.ReadOnlyHandler(staticdnsentry.GetReaderSingleton()), auth.PrivLevelReadOnly, Authenticated, nil},
 		{1.3, http.MethodGet, `staticdnsentries/?(\.json)?$`, api.ReadHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
-		{1.3, http.MethodGet, `staticdnsentries/{id}$`, api.ReadHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
-		{1.3, http.MethodPut, `staticdnsentries/{id}$`, api.UpdateHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
+		{1.3, http.MethodGet, `staticdnsentries/?$`, api.ReadHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
+		{1.3, http.MethodPut, `staticdnsentries/?$`, api.UpdateHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
 		{1.3, http.MethodPost, `staticdnsentries/?$`, api.CreateHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
-		{1.3, http.MethodDelete, `staticdnsentries/{id}$`, api.DeleteHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
+		{1.3, http.MethodDelete, `staticdnsentries/?$`, api.DeleteHandler(staticdnsentry.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
 
 		//ProfileParameters
 		{1.1, http.MethodGet, `profiles/{id}/parameters/?(\.json)?$`, profileparameter.GetProfileID(d.DB.DB), auth.PrivLevelReadOnly, Authenticated, nil},