You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2020/03/17 21:12:20 UTC

[trafficcontrol] branch master updated: Deprecate profiles/trimmed (#4511)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4d2d622  Deprecate profiles/trimmed (#4511)
4d2d622 is described below

commit 4d2d6220969a5aece4e28d249998e0087724b2b3
Author: Michael Hoppal <54...@users.noreply.github.com>
AuthorDate: Tue Mar 17 15:12:10 2020 -0600

    Deprecate profiles/trimmed (#4511)
---
 CHANGELOG.md                                       |  1 +
 docs/source/api/v1/profiles_trimmed.rst            |  8 +++
 docs/source/api/v2/profiles_trimmed.rst            | 66 ----------------------
 .../clients/python/trafficops/tosession.py         |  9 ---
 traffic_ops/traffic_ops_golang/profile/trimmed.go  | 11 +++-
 traffic_ops/traffic_ops_golang/routing/routes.go   |  1 -
 6 files changed, 18 insertions(+), 78 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cfd4e1e..a949cf0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -79,6 +79,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
   - /parameters/profile/:name
   - /parameters/validate
   - /profile/:id/unassigned_parameters
+  - /profile/trimmed
   - /regions/:region_name/phys_locations
   - /regions/name/:region_name
   - /riak/bucket/:bucket/key/:key/vault
diff --git a/docs/source/api/v1/profiles_trimmed.rst b/docs/source/api/v1/profiles_trimmed.rst
index bedc01a..7239acb 100644
--- a/docs/source/api/v1/profiles_trimmed.rst
+++ b/docs/source/api/v1/profiles_trimmed.rst
@@ -18,6 +18,8 @@
 ********************
 ``profiles/trimmed``
 ********************
+.. deprecated:: ATCv4
+	Use the ``GET`` method of :ref:`to-api-v1-profiles` instead.
 
 ``GET``
 =======
@@ -63,4 +65,10 @@ Response Structure
 		{ "name": "CCR_CIAB" },
 		{ "name": "ENROLLER_ALL" },
 		{ "name": "RASCAL-Traffic_Monitor" }
+	],
+	"alerts": [
+		{
+			"text": "This endpoint is deprecated, please use GET /profiles instead",
+			"level": "warning"
+		}
 	]}
diff --git a/docs/source/api/v2/profiles_trimmed.rst b/docs/source/api/v2/profiles_trimmed.rst
deleted file mode 100644
index cfe2c0f..0000000
--- a/docs/source/api/v2/profiles_trimmed.rst
+++ /dev/null
@@ -1,66 +0,0 @@
-..
-..
-.. 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.
-..
-
-.. _to-api-profiles-trimmed:
-
-********************
-``profiles/trimmed``
-********************
-
-``GET``
-=======
-:Auth. Required: Yes
-:Roles Required: None
-:Response Type:  Array
-
-Request Structure
------------------
-No parameters available
-
-Response Structure
-------------------
-:name: The :ref:`profile-name` of the :term:`Profile`
-
-.. code-block:: http
- 	:caption: Response Example
-
-	HTTP/1.1 200 OK
-	Access-Control-Allow-Credentials: true
-	Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
-	Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
-	Access-Control-Allow-Origin: *
-	Content-Type: application/json
-	Set-Cookie: mojolicious=...; Path=/; Expires=Mon, 18 Nov 2019 17:40:54 GMT; Max-Age=3600; HttpOnly
-	Whole-Content-Sha512: 1XiReeWNZfrLjdordj5RpZJxJS1eAJ8v3rOulOnmBXEfTe+Sn3cKx3Pa0Rch4TII4ck/93sI+5L1V1m6MvTCaQ==
-	X-Server-Name: traffic_ops_golang/
-	Date: Fri, 07 Dec 2018 20:51:28 GMT
-	Content-Length: 360
-
-	{ "response": [
-		{ "name": "GLOBAL" },
-		{ "name": "TRAFFIC_ANALYTICS" },
-		{ "name": "TRAFFIC_OPS" },
-		{ "name": "TRAFFIC_OPS_DB" },
-		{ "name": "TRAFFIC_PORTAL" },
-		{ "name": "TRAFFIC_STATS" },
-		{ "name": "INFLUXDB" },
-		{ "name": "RIAK_ALL" },
-		{ "name": "ATS_EDGE_TIER_CACHE" },
-		{ "name": "ATS_MID_TIER_CACHE" },
-		{ "name": "BIND_ALL" },
-		{ "name": "CCR_CIAB" },
-		{ "name": "ENROLLER_ALL" },
-		{ "name": "RASCAL-Traffic_Monitor" }
-	]}
diff --git a/traffic_control/clients/python/trafficops/tosession.py b/traffic_control/clients/python/trafficops/tosession.py
index 0309f5d..b1db5c7 100644
--- a/traffic_control/clients/python/trafficops/tosession.py
+++ b/traffic_control/clients/python/trafficops/tosession.py
@@ -1421,15 +1421,6 @@ class TOSession(RestApiSession):
 		:raises: Union[LoginError, OperationError]
 		"""
 
-	@api_request('get', 'profiles/trimmed', ('2.0',))
-	def get_trimmed_profiles(self):
-		"""
-		Get Profiles with names only
-		:ref:`to-api-profiles-trimmed`
-		:rtype: Tuple[Union[Dict[str, Any], List[Dict[str, Any]]], requests.Response]
-		:raises: Union[LoginError, OperationError]
-		"""
-
 	@api_request('get', 'profiles/{profile_id:d}', ('2.0',))
 	def get_profile_by_id(self, profile_id=None):
 		"""
diff --git a/traffic_ops/traffic_ops_golang/profile/trimmed.go b/traffic_ops/traffic_ops_golang/profile/trimmed.go
index 5f8d500..4231c6e 100644
--- a/traffic_ops/traffic_ops_golang/profile/trimmed.go
+++ b/traffic_ops/traffic_ops_golang/profile/trimmed.go
@@ -29,13 +29,20 @@ import (
 )
 
 func Trimmed(w http.ResponseWriter, r *http.Request) {
+	alt := "GET /profiles"
 	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
 	if userErr != nil || sysErr != nil {
-		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+		api.HandleDeprecatedErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr, &alt)
 		return
 	}
 	defer inf.Close()
-	api.RespWriter(w, r, inf.Tx.Tx)(getTrimmedProfiles(inf.Tx.Tx))
+	trimmed, err := getTrimmedProfiles(inf.Tx.Tx)
+	if err != nil {
+		api.HandleDeprecatedErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr, &alt)
+		return
+	}
+	alerts := api.CreateDeprecationAlerts(&alt)
+	api.WriteAlertsObj(w, r, http.StatusOK, alerts, trimmed)
 }
 
 func getTrimmedProfiles(tx *sql.Tx) ([]tc.ProfileTrimmed, error) {
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go b/traffic_ops/traffic_ops_golang/routing/routes.go
index cbe167c..6e50ef8 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -266,7 +266,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 
 		//Profile: CRUD
 		{api.Version{2, 0}, http.MethodGet, `profiles/?$`, api.ReadHandler(&profile.TOProfile{}), auth.PrivLevelReadOnly, Authenticated, nil, 268758589, noPerlBypass},
-		{api.Version{2, 0}, http.MethodGet, `profiles/trimmed/?$`, profile.Trimmed, auth.PrivLevelReadOnly, Authenticated, nil, 244942941, noPerlBypass},
 
 		{api.Version{2, 0}, http.MethodGet, `profiles/{id}$`, api.ReadHandler(&profile.TOProfile{}), auth.PrivLevelReadOnly, Authenticated, nil, 2570260672, noPerlBypass},
 		{api.Version{2, 0}, http.MethodPut, `profiles/{id}$`, api.UpdateHandler(&profile.TOProfile{}), auth.PrivLevelOperations, Authenticated, nil, 28439172, noPerlBypass},