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

rawlin 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 5045517  Deprecate GET statuses/:id (#4506)
5045517 is described below

commit 5045517b31ad59b15b3e84be6479cfd727d07e86
Author: Michael Hoppal <[email protected]>
AuthorDate: Wed Mar 18 15:56:53 2020 -0600

    Deprecate GET statuses/:id (#4506)
---
 CHANGELOG.md                                       |  1 +
 docs/source/api/v1/statuses_id.rst                 |  9 ++
 docs/source/api/v2/statuses_id.rst                 | 97 ----------------------
 .../clients/python/trafficops/tosession.py         | 13 +--
 traffic_ops/client/status.go                       |  2 +-
 traffic_ops/traffic_ops_golang/routing/routes.go   |  3 +-
 6 files changed, 13 insertions(+), 112 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 871febb..078b1b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -93,6 +93,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
   - /servers/:id (GET)
   - /servers/totals
   - /stats_summary/create
+  - /statuses/:id (GET)
   - /to_extensions/:id/delete
   - /traffic_monitor/stats
   - /types/trimmed
diff --git a/docs/source/api/v1/statuses_id.rst 
b/docs/source/api/v1/statuses_id.rst
index a49f299..5007a31 100644
--- a/docs/source/api/v1/statuses_id.rst
+++ b/docs/source/api/v1/statuses_id.rst
@@ -21,6 +21,9 @@
 
 ``GET``
 =======
+.. deprecated:: ATCv4
+       Use the ``GET`` method of :ref:`to-api-v1-statuses` with the query 
parameter ``id`` instead.
+
 Retrieves information about a particular :term:`Status`
 
 :Auth. Required: Yes
@@ -94,4 +97,10 @@ Response Structure
                        "lastUpdated": "2018-12-10 19:11:17+00",
                        "name": "REPORTED"
                }
+       ],
+       "alerts": [
+               {
+                       "text": "This endpoint is deprecated, please use GET 
/statuses with query parameter id instead",
+                       "level": "warning"
+               }
        ]}
diff --git a/docs/source/api/v2/statuses_id.rst 
b/docs/source/api/v2/statuses_id.rst
deleted file mode 100644
index c2143b5..0000000
--- a/docs/source/api/v2/statuses_id.rst
+++ /dev/null
@@ -1,97 +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-statuses-id:
-
-*******************
-``statuses/{{ID}}``
-*******************
-
-``GET``
-=======
-Retrieves information about a particular :term:`Status`
-
-:Auth. Required: Yes
-:Roles Required: None
-:Response Type:  Array
-
-Request Structure
------------------
-.. table:: Request Path Parameters
-
-       
+------+-----------------------------------------------------------------------+
-       | Name | Description                                                    
       |
-       
+======+=======================================================================+
-       | ID   | The integral, unique identifier of the :term:`Status` being 
inspected |
-       
+------+-----------------------------------------------------------------------+
-
-.. table:: Request Query Parameters
-
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-       | Name      | Required | Description                                    
                                                               |
-       
+===========+==========+===============================================================================================================+
-       | orderby   | no       | Choose the ordering of the results - must be 
the name of one of the fields of the objects in the ``response`` |
-       |           |          | array                                          
                                                               |
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-       | sortOrder | no       | Changes the order of sorting. Either ascending 
(default or "asc") or descending ("desc")                      |
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-       | limit     | no       | Choose the maximum number of results to return 
                                                               |
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-       | offset    | no       | The number of results to skip before beginning 
to return results. Must use in conjunction with limit          |
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-       | page      | no       | Return the n\ :sup:`th` page of results, where 
"n" is the value of this parameter, pages are ``limit`` long   |
-       |           |          | and the first page is 1. If ``offset`` was 
defined, this query parameter has no effect. ``limit`` must be     |
-       |           |          | defined to make use of ``page``.               
                                                               |
-       
+-----------+----------+---------------------------------------------------------------------------------------------------------------+
-
-.. code-block:: http
-       :caption: Request Example
-
-       GET /api/2.0/statuses/3 HTTP/1.1
-       Host: trafficops.infra.ciab.test
-       User-Agent: curl/7.47.0
-       Accept: */*
-       Cookie: mojolicious=...
-
-Response Structure
-------------------
-:description: A short description of the status
-:id:          The integral, unique identifier of this status
-:lastUpdated: The date and time at which this status was last modified, in an 
ISO-like format
-:name:        The name of the status
-
-.. 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: 
dHNip9kpTGGS1w39/fWcFehNktgmXZus8XaufnmDpv0PyG/3fK/KfoCO3ZOj9V74/CCffps7doEygWeL/xRtKA==
-       X-Server-Name: traffic_ops_golang/
-       Date: Mon, 10 Dec 2018 21:04:20 GMT
-       Content-Length: 150
-
-       { "response": [
-               {
-                       "description": "Server is online and reported in the 
health protocol.",
-                       "id": 3,
-                       "lastUpdated": "2018-12-10 19:11:17+00",
-                       "name": "REPORTED"
-               }
-       ]}
diff --git a/traffic_control/clients/python/trafficops/tosession.py 
b/traffic_control/clients/python/trafficops/tosession.py
index 82ff492..1c666b5 100644
--- a/traffic_control/clients/python/trafficops/tosession.py
+++ b/traffic_control/clients/python/trafficops/tosession.py
@@ -1803,7 +1803,7 @@ class TOSession(RestApiSession):
        # Status
        #
        @api_request('get', 'statuses', ('2.0',))
-       def get_statuses(self):
+       def get_statuses(self, query_params=None):
                """
                Retrieves a list of the server status codes available.
                :ref:`to-api-statuses`
@@ -1811,17 +1811,6 @@ class TOSession(RestApiSession):
                :raises: Union[LoginError, OperationError]
                """
 
-       @api_request('get', 'statuses/{status_id:d}', ('2.0',))
-       def get_statuses_by_id(self, status_id=None):
-               """
-               Retrieves a server status by ID.
-               :ref:`to-api-statuses-id`
-               :param status_id: The status id to retrieve
-               :type status_id: int
-               :rtype: Tuple[Union[Dict[str, Any], List[Dict[str, Any]]], 
requests.Response]
-               :raises: Union[LoginError, OperationError]
-               """
-
        #
        # System
        #
diff --git a/traffic_ops/client/status.go b/traffic_ops/client/status.go
index 02e3b2a..d00576f 100644
--- a/traffic_ops/client/status.go
+++ b/traffic_ops/client/status.go
@@ -103,7 +103,7 @@ func (to *Session) GetStatuses() ([]tc.Status, ReqInf, 
error) {
 
 // GetStatusByID GETs a Status by the Status ID.
 func (to *Session) GetStatusByID(id int) ([]tc.Status, ReqInf, error) {
-       route := fmt.Sprintf("%s/%d", API_STATUSES, id)
+       route := fmt.Sprintf("%s?id=%d", API_STATUSES, id)
        resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
        reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
        if err != nil {
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go 
b/traffic_ops/traffic_ops_golang/routing/routes.go
index 222731c..0e10f20 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -329,7 +329,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, 
http.Handler, error) {
 
                //Status: CRUD
                {api.Version{2, 0}, http.MethodGet, `statuses/?$`, 
api.ReadHandler(&status.TOStatus{}), auth.PrivLevelReadOnly, Authenticated, 
nil, 2244905656, noPerlBypass},
-               {api.Version{2, 0}, http.MethodGet, `statuses/{id}$`, 
api.ReadHandler(&status.TOStatus{}), auth.PrivLevelReadOnly, Authenticated, 
nil, 2899095947, noPerlBypass},
                {api.Version{2, 0}, http.MethodPut, `statuses/{id}$`, 
api.UpdateHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 2207966504, noPerlBypass},
                {api.Version{2, 0}, http.MethodPost, `statuses/?$`, 
api.CreateHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 2369123612, noPerlBypass},
                {api.Version{2, 0}, http.MethodDelete, `statuses/{id}$`, 
api.DeleteHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 255111360, noPerlBypass},
@@ -735,7 +734,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, 
http.Handler, error) {
 
                //Status: CRUD
                {api.Version{1, 1}, http.MethodGet, `statuses/?(\.json)?$`, 
api.ReadHandler(&status.TOStatus{}), auth.PrivLevelReadOnly, Authenticated, 
nil, 2044905656, noPerlBypass},
-               {api.Version{1, 1}, http.MethodGet, `statuses/{id}$`, 
api.ReadHandler(&status.TOStatus{}), auth.PrivLevelReadOnly, Authenticated, 
nil, 1899095947, noPerlBypass},
+               {api.Version{1, 1}, http.MethodGet, `statuses/{id}$`, 
api.DeprecatedReadHandler(&status.TOStatus{}, util.StrPtr("GET /statuses with 
query parameter id")), auth.PrivLevelReadOnly, Authenticated, nil, 1899095947, 
noPerlBypass},
                {api.Version{1, 1}, http.MethodPut, `statuses/{id}$`, 
api.UpdateHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 1207966504, noPerlBypass},
                {api.Version{1, 1}, http.MethodPost, `statuses/?$`, 
api.CreateHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 1369123612, noPerlBypass},
                {api.Version{1, 1}, http.MethodDelete, `statuses/{id}$`, 
api.DeleteHandler(&status.TOStatus{}), auth.PrivLevelOperations, Authenticated, 
nil, 755111360, noPerlBypass},

Reply via email to