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:32:03 UTC
[trafficcontrol] branch master updated: Deprecate GET
phys_locations/:id (#4503)
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 b144a1e Deprecate GET phys_locations/:id (#4503)
b144a1e is described below
commit b144a1efdd0d10068ccc742850001f30b8c92353
Author: Michael Hoppal <54...@users.noreply.github.com>
AuthorDate: Tue Mar 17 15:31:52 2020 -0600
Deprecate GET phys_locations/:id (#4503)
---
CHANGELOG.md | 1 +
docs/source/api/v1/phys_locations_id.rst | 9 ++
docs/source/api/v2/phys_locations_id.rst | 97 ----------------------
.../clients/python/trafficops/tosession.py | 11 ---
traffic_ops/client/phys_location.go | 2 +-
traffic_ops/traffic_ops_golang/routing/routes.go | 3 +-
6 files changed, 12 insertions(+), 111 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70e044d..ec9a89d 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/:id/unassigned_profiles
- /parameters/profile/:name
- /parameters/validate
+ - /phys_locations/:id (GET)
- /profile/:id/unassigned_parameters
- /profile/trimmed
- /regions/:region_name/phys_locations
diff --git a/docs/source/api/v1/phys_locations_id.rst b/docs/source/api/v1/phys_locations_id.rst
index e55498c..653be03 100644
--- a/docs/source/api/v1/phys_locations_id.rst
+++ b/docs/source/api/v1/phys_locations_id.rst
@@ -21,6 +21,9 @@
``GET``
=======
+.. deprecated:: ATCv4
+ Use the ``GET`` method of :ref:`to-api-v1-phys_locations` with the query parameter ``id`` instead.
+
Retrieves information about a specific :term:`Physical Location`
:Auth. Required: Yes
@@ -114,6 +117,12 @@ Response Structure
"state": "DC",
"zip": "20500"
}
+ ],
+ "alerts": [
+ {
+ "text": "This endpoint is deprecated, please use GET /phys_locations with query parameter id instead",
+ "level": "warning"
+ }
]}
``PUT``
diff --git a/docs/source/api/v2/phys_locations_id.rst b/docs/source/api/v2/phys_locations_id.rst
index aaa8eca..936de16 100644
--- a/docs/source/api/v2/phys_locations_id.rst
+++ b/docs/source/api/v2/phys_locations_id.rst
@@ -19,103 +19,6 @@
``phys_locations/{{ID}}``
*************************
-``GET``
-=======
-Retrieves information about a specific :term:`Physical Location`
-
-:Auth. Required: Yes
-:Roles Required: None
-:Response Type: Array
-
-Request Structure
------------------
-.. 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``. |
- +-----------+----------+---------------------------------------------------------------------------------------------------------------+
-
-.. table:: Request Path Parameters
-
- +------+--------------------------------------------------------------------------+
- | Name | Description |
- +======+==========================================================================+
- | ID | The integral, unique identifier of the physical location being retrieved |
- +------+--------------------------------------------------------------------------+
-
-.. code-block:: http
- :caption: Request Example
-
- GET /api/2.0/phys_locations/2 HTTP/1.1
- Host: trafficops.infra.ciab.test
- User-Agent: curl/7.47.0
- Accept: */*
- Cookie: mojolicious=...
-
-Response Structure
-------------------
-:address: The physical location's street address
-:city: The name of the city in which the physical location lies
-:comments: Any and all human-readable comments
-:email: The email address of the physical location's ``poc``
-:id: An integral, unique identifier for the physical location
-:lastUpdated: The date and time at which the physical location was last updated, in ISO format
-:name: The name of the physical location
-:phone: A phone number where the the physical location's ``poc`` might be reached
-:poc: The name of a "point of contact" for the physical location
-:region: The name of the region within which the physical location lies
-:regionId: An integral, unique identifier for the region within which the physical location lies
-:shortName: An abbreviation of the ``name``
-:state: An abbreviation of the name of the state or province within which this physical location lies
-:zip: The zip code of the 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: 0g4b3W1AwXytCnBo8TReQQij2v9oHAl7MG9KuwMig5V4sFcMM5qP8dgPsFTunFr00DPI20c7BpUbZsvJtsYTEQ==
- X-Server-Name: traffic_ops_golang/
- Date: Wed, 05 Dec 2018 22:45:47 GMT
- Content-Length: 275
-
- { "response": [
- {
- "address": "1600 Pennsylvania Avenue NW",
- "city": "Washington",
- "comments": "",
- "email": "",
- "id": 2,
- "lastUpdated": "2018-12-05 17:50:58+00",
- "name": "CDN_in_a_Box",
- "phone": "",
- "poc": "",
- "regionId": 1,
- "region": "Washington, D.C",
- "shortName": "ciab",
- "state": "DC",
- "zip": "20500"
- }
- ]}
-
``PUT``
=======
Updates a :term:`Physical Location`
diff --git a/traffic_control/clients/python/trafficops/tosession.py b/traffic_control/clients/python/trafficops/tosession.py
index 92031ec..e837870 100644
--- a/traffic_control/clients/python/trafficops/tosession.py
+++ b/traffic_control/clients/python/trafficops/tosession.py
@@ -1365,17 +1365,6 @@ class TOSession(RestApiSession):
:raises: Union[LoginError, OperationError]
"""
- @api_request('get', 'phys_locations/{physical_location_id:d}', ('2.0',))
- def get_physical_location_by_id(self, physical_location_id=None):
- """
- Get Physical Location by id
- :ref:`to-api-phys_locations-id`
- :param physical_location_id: The id to retrieve
- :type physical_location_id: int
- :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/client/phys_location.go b/traffic_ops/client/phys_location.go
index 9646c82..1a8ca1e 100644
--- a/traffic_ops/client/phys_location.go
+++ b/traffic_ops/client/phys_location.go
@@ -94,7 +94,7 @@ func (to *Session) GetPhysLocations() ([]tc.PhysLocation, ReqInf, error) {
// GET a PhysLocation by the PhysLocation ID
func (to *Session) GetPhysLocationByID(id int) ([]tc.PhysLocation, ReqInf, error) {
- route := fmt.Sprintf("%s/%d", API_PHYS_LOCATIONS, id)
+ route := fmt.Sprintf("%s?id=%d", API_PHYS_LOCATIONS, 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 a99fd53..e456548 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -254,7 +254,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.MethodGet, `phys_locations/{id}$`, api.ReadHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelReadOnly, Authenticated, nil, 2554216025, 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},
@@ -654,7 +653,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
//Phys_Location: CRUD
{api.Version{1, 1}, http.MethodGet, `phys_locations/?(\.json)?$`, api.ReadHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelReadOnly, Authenticated, nil, 120405182, noPerlBypass},
{api.Version{1, 1}, http.MethodGet, `phys_locations/trimmed/?(\.json)?$`, physlocation.GetTrimmed, auth.PrivLevelReadOnly, Authenticated, nil, 1097221000, noPerlBypass},
- {api.Version{1, 1}, http.MethodGet, `phys_locations/{id}$`, api.ReadHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelReadOnly, Authenticated, nil, 1554216025, noPerlBypass},
+ {api.Version{1, 1}, http.MethodGet, `phys_locations/{id}$`, api.DeprecatedReadHandler(&physlocation.TOPhysLocation{}, util.StrPtr("GET /phys_locations with query parameter id")), auth.PrivLevelReadOnly, Authenticated, nil, 1554216025, noPerlBypass},
{api.Version{1, 1}, http.MethodPut, `phys_locations/{id}$`, api.UpdateHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, Authenticated, nil, 226795021, noPerlBypass},
{api.Version{1, 1}, http.MethodPost, `phys_locations/?$`, api.CreateHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, Authenticated, nil, 2146456648, noPerlBypass},
{api.Version{1, 1}, http.MethodDelete, `phys_locations/{id}$`, api.DeleteHandler(&physlocation.TOPhysLocation{}), auth.PrivLevelOperations, Authenticated, nil, 15614221, noPerlBypass},