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

[trafficcontrol] branch master updated: Deprecate deliveryservices available (#4498)

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 eedfeeb  Deprecate deliveryservices available (#4498)
eedfeeb is described below

commit eedfeebc59d48e31f96c1d3c2959f21c2728e2c0
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Tue Mar 17 16:08:54 2020 -0600

    Deprecate deliveryservices available (#4498)
    
    * removed documentation
    
    * Removed 2.0 route
    
    * Added deprecation notice to API responses
    
    * Added deprecation notice to documentation
    
    * Updated changelog
---
 CHANGELOG.md                                       |  1 +
 .../api/v1/user_id_deliveryservices_available.rst  |  9 ++-
 .../api/v2/user_id_deliveryservices_available.rst  | 78 ----------------------
 traffic_ops/traffic_ops_golang/routing/routes.go   |  1 -
 .../traffic_ops_golang/user/deliveryservices.go    | 11 +--
 5 files changed, 16 insertions(+), 84 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 958fdf4..6dd44f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -96,6 +96,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
   - /types/{{ID}} (GET)
   - /user/current/jobs
   - /servers/checks
+  - /user/{{user ID}}/deliveryservices/available
 
 ## [4.0.0] - 2019-12-16
 ### Added
diff --git a/docs/source/api/v1/user_id_deliveryservices_available.rst b/docs/source/api/v1/user_id_deliveryservices_available.rst
index 5463d54..798e3fe 100644
--- a/docs/source/api/v1/user_id_deliveryservices_available.rst
+++ b/docs/source/api/v1/user_id_deliveryservices_available.rst
@@ -19,6 +19,9 @@
 ``user/{{ID}}/deliveryservices/available``
 ******************************************
 
+.. deprecated:: ATCv4
+	This endpoint is deprecated, and will be removed in the future.
+
 ``GET``
 =======
 Lists identifying information for all of the :term:`Delivery Services` assigned to a user - **not**, as the name implies, the :term:`Delivery Services` *available* to be assigned to that user.
@@ -67,7 +70,11 @@ Response Structure
 	Date: Thu, 13 Dec 2018 22:31:44 GMT
 	Content-Length: 62
 
-	{ "response": [
+	{ "alerts": [{
+		"level": "warning",
+		"text": "This endpoint is deprecated, and will be removed in the future"
+	}],
+	"response": [
 		{
 			"id": 1,
 			"displayName": "Demo 1",
diff --git a/docs/source/api/v2/user_id_deliveryservices_available.rst b/docs/source/api/v2/user_id_deliveryservices_available.rst
deleted file mode 100644
index fb0f66f..0000000
--- a/docs/source/api/v2/user_id_deliveryservices_available.rst
+++ /dev/null
@@ -1,78 +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-user-id-deliveryservices-available:
-
-******************************************
-``user/{{ID}}/deliveryservices/available``
-******************************************
-
-``GET``
-=======
-Lists identifying information for all of the :term:`Delivery Services` assigned to a user - **not**, as the name implies, the :term:`Delivery Services` *available* to be assigned to that user.
-
-:Auth. Required: Yes
-:Roles Required: None\ [#tenancy]_
-:Response Type:  Array
-
-Request Structure
------------------
-.. table:: Request Path Parameters
-
-	+------+---------------------------------------------------------------------------------------------------+
-	| Name | Description                                                                                       |
-	+======+===================================================================================================+
-	|  ID  | The integral, unique identifier of the users whose :term:`Delivery Services` shall be retrieved   |
-	+------+---------------------------------------------------------------------------------------------------+
-
-.. code-block:: http
-	:caption: Request Example
-
-	GET /api/2.0/user/2/deliveryservices/available HTTP/1.1
-	Host: trafficops.infra.ciab.test
-	User-Agent: curl/7.47.0
-	Accept: */*
-	Cookie: mojolicious=...
-
-Response Structure
-------------------
-:displayName: This :term:`Delivery Service`'s :ref:`ds-display-name`
-:id:          The integral, unique identifier of this :term:`Delivery Service`
-:xmlId:       The :ref:`ds-xmlid` which (also) uniquely identifies this :term:`Delivery Service`
-
-.. 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: A1IUM2qkvJkviD0mcEADoCMiy76AWRO/Xnc70ur3CrOlkySXwqxfrhLc3wKlI1926yW+QrTd3nQaVpbX7Rd9wQ==
-	X-Server-Name: traffic_ops_golang/
-	Date: Thu, 13 Dec 2018 22:31:44 GMT
-	Content-Length: 62
-
-	{ "response": [
-		{
-			"id": 1,
-			"displayName": "Demo 1",
-			"xmlId": "demo1"
-		}
-	]}
-
-.. [#tenancy] Only the :term:`Delivery Services` visible to the requesting user's :term:`Tenant` will appear, regardless of :term:`Role` or actual 'assignment' status.
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go b/traffic_ops/traffic_ops_golang/routing/routes.go
index 34fe671..22481e1 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -224,7 +224,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 
 		//Login
 		{api.Version{2, 0}, http.MethodGet, `users/{id}/deliveryservices/?$`, user.GetDSes, auth.PrivLevelReadOnly, Authenticated, nil, 288787789, noPerlBypass},
-		{api.Version{2, 0}, http.MethodGet, `user/{id}/deliveryservices/available/?$`, user.GetAvailableDSes, auth.PrivLevelReadOnly, Authenticated, nil, 257082995, noPerlBypass},
 		{api.Version{2, 0}, http.MethodPost, `user/login/?$`, login.LoginHandler(d.DB, d.Config), 0, NoAuth, nil, 2392670821, noPerlBypass},
 		{api.Version{2, 0}, http.MethodPost, `user/logout/?$`, login.LogoutHandler(d.Config.Secrets[0]), 0, Authenticated, nil, 243434825, noPerlBypass},
 		{api.Version{2, 0}, http.MethodPost, `user/login/oauth/?$`, login.OauthLoginHandler(d.DB, d.Config), 0, NoAuth, nil, 2415886009, noPerlBypass},
diff --git a/traffic_ops/traffic_ops_golang/user/deliveryservices.go b/traffic_ops/traffic_ops_golang/user/deliveryservices.go
index 68a7714..c4fc98f 100644
--- a/traffic_ops/traffic_ops_golang/user/deliveryservices.go
+++ b/traffic_ops/traffic_ops_golang/user/deliveryservices.go
@@ -22,6 +22,7 @@ package user
 import (
 	"database/sql"
 	"errors"
+	"fmt"
 	"net/http"
 
 	"github.com/apache/trafficcontrol/lib/go-tc"
@@ -56,7 +57,7 @@ func GetDSes(w http.ResponseWriter, r *http.Request) {
 func GetAvailableDSes(w http.ResponseWriter, r *http.Request) {
 	inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"id"}, []string{"id"})
 	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, nil)
 		return
 	}
 	defer inf.Close()
@@ -64,16 +65,18 @@ func GetAvailableDSes(w http.ResponseWriter, r *http.Request) {
 	dsUserID := inf.IntParams["id"]
 	dses, err := getUserAvailableDSes(inf.Tx.Tx, dsUserID)
 	if err != nil {
-		api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, errors.New("getting user delivery services: "+err.Error()))
+		api.HandleDeprecatedErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, fmt.Errorf("getting user delivery services: %v", err), nil)
 		return
 	}
 
 	dses, err = filterAvailableAuthorized(inf.Tx.Tx, dses, inf.User)
 	if err != nil {
-		api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, errors.New("filtering user-authorized delivery services: "+err.Error()))
+		api.HandleDeprecatedErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, fmt.Errorf("filtering user-authorized delivery services: %v", err), nil)
 		return
 	}
-	api.WriteResp(w, r, dses)
+
+	alerts := api.CreateDeprecationAlerts(nil)
+	api.WriteAlertsObj(w, r, http.StatusOK, alerts, dses)
 }
 
 func filterAuthorized(tx *sql.Tx, dses []tc.DeliveryServiceNullable, user *auth.CurrentUser) ([]tc.DeliveryServiceNullable, error) {