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 1669e97  Deprecate /phys_locations/trimmed (#4510)
1669e97 is described below

commit 1669e9765ddba1436e9d5da0aa7198a7ebcf8797
Author: Michael Hoppal <[email protected]>
AuthorDate: Fri Mar 20 12:00:22 2020 -0600

    Deprecate /phys_locations/trimmed (#4510)
    
    * Deprecate /phys_locations/trimmed
    
    * Update phys_locations_trimmed.rst
    
    * Update phys_locations_trimmed.rst
---
 CHANGELOG.md                                       |  1 +
 docs/source/api/v1/phys_locations_trimmed.rst      |  8 +++
 docs/source/api/v2/phys_locations_trimmed.rst      | 60 ----------------------
 .../clients/python/trafficops/tosession.py         |  9 ----
 .../traffic_ops_golang/physlocation/trimmed.go     | 11 +++-
 traffic_ops/traffic_ops_golang/routing/routes.go   |  1 -
 6 files changed, 18 insertions(+), 72 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70515ee..eeb6741 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -80,6 +80,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
   - /parameters/:id/unassigned_profiles
   - /parameters/profile/:name
   - /parameters/validate
+  - /phys_locations/trimmed
   - /phys_locations/:id (GET)
   - /profile/:id (GET)
   - /profile/:id/unassigned_parameters
diff --git a/docs/source/api/v1/phys_locations_trimmed.rst 
b/docs/source/api/v1/phys_locations_trimmed.rst
index 2f57174..9d603b1 100644
--- a/docs/source/api/v1/phys_locations_trimmed.rst
+++ b/docs/source/api/v1/phys_locations_trimmed.rst
@@ -18,6 +18,8 @@
 **************************
 ``phys_locations/trimmed``
 **************************
+.. deprecated:: ATCv4
+       Use the ``GET`` method of :ref:`to-api-v1-phys_locations` instead.
 
 ``GET``
 =======
@@ -57,4 +59,10 @@ Response Structure
                {
                        "name": "Apachecon North America 2018"
                }
+       ],
+       "alerts": [
+               {
+                       "text": "This endpoint is deprecated, please use GET 
/phys_locations instead",
+                       "level": "warning"
+               }
        ]}
diff --git a/docs/source/api/v2/phys_locations_trimmed.rst 
b/docs/source/api/v2/phys_locations_trimmed.rst
deleted file mode 100644
index c3e33b4..0000000
--- a/docs/source/api/v2/phys_locations_trimmed.rst
+++ /dev/null
@@ -1,60 +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-phys_locations-trimmed:
-
-**************************
-``phys_locations/trimmed``
-**************************
-
-``GET``
-=======
-Retrieves only the names of :term:`Physical Locations`.
-
-:Auth. Required: Yes
-:Roles Required: None
-:Response Type:  Array
-
-Request Structure
------------------
-No parameters available
-
-Response Structure
-------------------
-:name: The name of the :term:`Physical Location`
-
-.. 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: 
s4/q6oyQHa+mQ3d3gRGHvVsRyvsrkKxYnP574rVVUji0hHxYDbOnyPPswi4MuuQRm7dZq8cp4/iw9rlLRkBU0g==
-       X-Server-Name: traffic_ops_golang/
-       Date: Wed, 05 Dec 2018 22:35:02 GMT
-       Content-Length: 78
-
-       { "response": [
-               {
-                       "name": "CDN_in_a_Box"
-               },
-               {
-                       "name": "Apachecon North America 2018"
-               }
-       ]}
diff --git a/traffic_control/clients/python/trafficops/tosession.py 
b/traffic_control/clients/python/trafficops/tosession.py
index 3743ce9..19b5f46 100644
--- a/traffic_control/clients/python/trafficops/tosession.py
+++ b/traffic_control/clients/python/trafficops/tosession.py
@@ -1356,15 +1356,6 @@ class TOSession(RestApiSession):
                :raises: Union[LoginError, OperationError]
                """
 
-       @api_request('get', 'phys_locations/trimmed', ('2.0',))
-       def get_trimmed_physical_locations(self):
-               """
-               Get Physical Locations with name only
-               :ref:`to-api-phys_locations-trimmed`
-               :rtype: Tuple[Union[Dict[str, Any], List[Dict[str, Any]]], 
requests.Response]
-               :raises: Union[LoginError, OperationError]
-               """
-
        @api_request('put', 'phys_locations/{physical_location_id:d}', ('2.0',))
        def update_physical_location(self, physical_location_id=None, 
query_params=None):
                """
diff --git a/traffic_ops/traffic_ops_golang/physlocation/trimmed.go 
b/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
index 37719b9..88138de 100644
--- a/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
+++ b/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
@@ -29,13 +29,20 @@ import (
 )
 
 func GetTrimmed(w http.ResponseWriter, r *http.Request) {
+       alt := "GET /phys_locations"
        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)(getTrimmed(inf.Tx.Tx))
+       trimmed, err := getTrimmed(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 getTrimmed(tx *sql.Tx) ([]tc.PhysLocationTrimmed, error) {
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go 
b/traffic_ops/traffic_ops_golang/routing/routes.go
index e1b926a..3141bc7 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -252,7 +252,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, 
http.Handler, error) {
 
                //Phys_Location: CRUD
                {api.Version{2, 0}, http.MethodGet, `phys_locations/?$`, 
api.ReadHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelReadOnly, 
Authenticated, nil, 220405182, noPerlBypass},
-               {api.Version{2, 0}, http.MethodGet, 
`phys_locations/trimmed/?$`, physlocation.GetTrimmed, auth.PrivLevelReadOnly, 
Authenticated, nil, 2097221000, noPerlBypass},
                {api.Version{2, 0}, http.MethodPut, `phys_locations/{id}$`, 
api.UpdateHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, 
Authenticated, nil, 222795021, noPerlBypass},
                {api.Version{2, 0}, http.MethodPost, `phys_locations/?$`, 
api.CreateHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, 
Authenticated, nil, 2246456648, noPerlBypass},
                {api.Version{2, 0}, http.MethodDelete, `phys_locations/{id}$`, 
api.DeleteHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, 
Authenticated, nil, 25614221, noPerlBypass},

Reply via email to