diff --git a/CHANGELOG.md b/CHANGELOG.md index a26d088875..c558c6317d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - /cachegroups/:id (GET) - /cachegroup/:parameterID/parameter - /cachegroups/:parameterID/parameter/available + - /cachegroups/:id/unassigned_parameters - /cachegroups/trimmed - /cdns/:name/configs/routing - /cdns/:name/federations/:id (GET) diff --git a/docs/source/api/v1/cachegroups_id_unassigned_parameters.rst b/docs/source/api/v1/cachegroups_id_unassigned_parameters.rst index 49fa679e2c..ca7a2ce064 100644 --- a/docs/source/api/v1/cachegroups_id_unassigned_parameters.rst +++ b/docs/source/api/v1/cachegroups_id_unassigned_parameters.rst @@ -18,6 +18,8 @@ ******************************************** ``cachegroups/{{id}}/unassigned_parameters`` ******************************************** +.. deprecated:: ATCv4 + This endpoint and all of its functionality is deprecated. All of the information it can return can be obtained using :ref:`to-api-v1-cachegroupparameters` & :ref:`to-api-v1-parameters`. ``GET`` ======= @@ -104,4 +106,10 @@ Response Structure "id": 6843, "configFile": "hdr_rw_mid_bamtech-nhl-live-t.config" } + ], + "alerts": [ + { + "text": "This endpoint is deprecated, please use GET /cachegroupparameters & GET /parameters instead", + "level": "warning" + } ]} diff --git a/docs/source/api/v2/cachegroups_id_unassigned_parameters.rst b/docs/source/api/v2/cachegroups_id_unassigned_parameters.rst deleted file mode 100644 index 60efa732f7..0000000000 --- a/docs/source/api/v2/cachegroups_id_unassigned_parameters.rst +++ /dev/null @@ -1,107 +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-cachegroups-id-unassigned_parameters: - -******************************************** -``cachegroups/{{id}}/unassigned_parameters`` -******************************************** - -``GET`` -======= -Gets all the :term:`Parameters` that are *not* a specific :ref:`Cache Group's parameters `. - -:Auth. Required: Yes -:Roles Required: None -:Response Type: Array - -Request Structure ------------------ -.. table:: Request Query Parameters - - +-------------+----------+---------------------------------------------------------------------------------------------------------------+ - | Name | Required | Description | - +=============+==========+===============================================================================================================+ - | parameterId | no | Show only the :term:`Parameter` with the given ID | - +-------------+----------+---------------------------------------------------------------------------------------------------------------+ - | 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 | Required | Description | - +========+==========+====================================================+ - | ``id`` | yes | The :ref:`cache-group-id` of a :term:`Cache Group` | - +--------+----------+----------------------------------------------------+ - - -Response Structure ------------------- -:configFile: The :term:`Parameter`'s :ref:`parameter-config-file` -:id: The :term:`Parameter`'s :ref:`parameter-id` -:lastUpdated: The date and time at which this :term:`Parameter` was last updated, in an ISO-like format -:name: :ref:`parameter-name` of the :term:`Parameter` -:secure: A boolean value that describes whether or not the :term:`Parameter` is :ref:`parameter-secure` -:value: The :term:`Parameter`'s :ref:`parameter-value` - -.. code-block:: json - :caption: Response Example - - { "response": [ - { - "lastUpdated": "2018-10-09 11:14:33.862905+00", - "value": "/opt/trafficserver/etc/trafficserver", - "secure": false, - "name": "location", - "id": 6836, - "configFile": "hdr_rw_bamtech-nhl-live.config" - }, - { - "lastUpdated": "2018-10-09 11:14:33.862905+00", - "value": "/opt/trafficserver/etc/trafficserver", - "secure": false, - "name": "location", - "id": 6837, - "configFile": "hdr_rw_mid_bamtech-nhl-live.config" - }, - { - "lastUpdated": "2018-10-09 11:55:46.014844+00", - "value": "/opt/trafficserver/etc/trafficserver", - "secure": false, - "name": "location", - "id": 6842, - "configFile": "hdr_rw_bamtech-nhl-live-t.config" - }, - { - "lastUpdated": "2018-10-09 11:55:46.014844+00", - "value": "/opt/trafficserver/etc/trafficserver", - "secure": false, - "name": "location", - "id": 6843, - "configFile": "hdr_rw_mid_bamtech-nhl-live-t.config" - } - ]} diff --git a/traffic_control/clients/python/trafficops/tosession.py b/traffic_control/clients/python/trafficops/tosession.py index 827b5b408d..9bc3d0dc06 100644 --- a/traffic_control/clients/python/trafficops/tosession.py +++ b/traffic_control/clients/python/trafficops/tosession.py @@ -387,17 +387,6 @@ def get_cachegroup_parameters(self, cache_group_id=None): :raises: Union[LoginError, OperationError] """ - @api_request('get', 'cachegroups/{cache_group_id:d}/unassigned_parameters', ('2.0',)) - def get_cachegroup_unassigned_parameters(self, cache_group_id=None): - """ - Get a cache groups unassigned parameters - :ref:`to-api-cachegroups-id-unassigned_parameters` - :param cache_group_id: The cache group Id - :type cache_group_id: int - :rtype: Tuple[Dict[str, Any], requests.Response] - :raises: Union[LoginError, OperationError] - """ - @api_request('get', 'cachegroupparameters', ('2.0',)) def get_all_cachegroup_parameters(self): """ diff --git a/traffic_ops/client/cachegroup_parameters.go b/traffic_ops/client/cachegroup_parameters.go index 687b2805c4..8dc7930cdd 100644 --- a/traffic_ops/client/cachegroup_parameters.go +++ b/traffic_ops/client/cachegroup_parameters.go @@ -39,18 +39,6 @@ func (to *Session) GetCacheGroupParametersByQueryParams(cacheGroupID int, queryP return to.getCacheGroupParameters(route, queryParams) } -// GetCacheGroupUnassignedParameters Gets a Cache Group's Unassigned Parameters -func (to *Session) GetCacheGroupUnassignedParameters(cacheGroupID int) ([]tc.CacheGroupParameter, ReqInf, error) { - route := fmt.Sprintf("%s/%d/unassigned_parameters", API_CACHEGROUPS, cacheGroupID) - return to.getCacheGroupParameters(route, "") -} - -// GetCacheGroupParametersByQueryParams Gets a Cache Group's Unassigned Parameters with query parameters -func (to *Session) GetCacheGroupUnassignedParametersByQueryParams(cacheGroupID int, queryParams string) ([]tc.CacheGroupParameter, ReqInf, error) { - route := fmt.Sprintf("%s/%d/unassigned_parameters", API_CACHEGROUPS, cacheGroupID) - return to.getCacheGroupParameters(route, queryParams) -} - func (to *Session) getCacheGroupParameters(route, queryParams string) ([]tc.CacheGroupParameter, ReqInf, error) { r := fmt.Sprintf("%s%s", route, queryParams) resp, remoteAddr, err := to.request(http.MethodGet, r, nil) diff --git a/traffic_ops/testing/api/v2/cachegroups_parameters_test.go b/traffic_ops/testing/api/v2/cachegroups_parameters_test.go index bd61614b11..e5d256a111 100644 --- a/traffic_ops/testing/api/v2/cachegroups_parameters_test.go +++ b/traffic_ops/testing/api/v2/cachegroups_parameters_test.go @@ -25,7 +25,6 @@ import ( func TestCacheGroupParameters(t *testing.T) { WithObjs(t, []TCObj{Types, Parameters, CacheGroups, CacheGroupParameters}, func() { GetTestCacheGroupParameters(t) - GetTestCacheGroupUnassignedParameters(t) }) } @@ -75,25 +74,6 @@ func GetTestCacheGroupParameters(t *testing.T) { } } -func GetTestCacheGroupUnassignedParameters(t *testing.T) { - for _, cgp := range testData.CacheGroupParameterRequests { - // Check that Unassigned Parameters does not include Assigned Parameter - unassignedCGParamsResp, _, err := TOSession.GetCacheGroupUnassignedParameters(cgp.CacheGroupID) - if err != nil { - t.Errorf("could not get unassigned parameters for cache group %v: %v", cgp.CacheGroupID, err) - } - if unassignedCGParamsResp == nil { - t.Fatal("unassigned parameters response should not be nil") - } - - for _, param := range unassignedCGParamsResp { - if cgp.ParameterID == param.ID { - t.Errorf("assigned parameter %v found in unassigned response", param.ID) - } - } - } -} - func DeleteTestCacheGroupParameters(t *testing.T) { for _, cgp := range testData.CacheGroupParameterRequests { DeleteTestCacheGroupParameter(t, cgp) @@ -121,24 +101,6 @@ func DeleteTestCacheGroupParameter(t *testing.T, cgp tc.CacheGroupParameterReque t.Errorf("expected Parameter: %d to be to be disassociated from Cache Group: %d", cgp.ParameterID, cgp.CacheGroupID) } - // Check that the disassociated Parameter is now apart of Unassigned Parameters - unassignedCGParamsResp, _, err := TOSession.GetCacheGroupUnassignedParameters(cgp.CacheGroupID) - if err != nil { - t.Errorf("could not get unassigned parameters for cache group %v: %v", cgp.CacheGroupID, err) - } - if unassignedCGParamsResp == nil { - t.Fatal("unassigned parameters response should not be nil") - } - found := false - for _, param := range unassignedCGParamsResp { - if cgp.ParameterID == param.ID { - found = true - } - } - if !found { - t.Fatalf("parameter %v removed from cache group %v was not found in unassigned parameters response", cgp.ParameterID, cgp.CacheGroupID) - } - // Attempt to delete it again and it should return an error now _, _, err = TOSession.DeleteCacheGroupParameter(cgp.CacheGroupID, cgp.ParameterID) if err == nil { diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go b/traffic_ops/traffic_ops_golang/routing/routes.go index 9f62a2c68c..947474e680 100644 --- a/traffic_ops/traffic_ops_golang/routing/routes.go +++ b/traffic_ops/traffic_ops_golang/routing/routes.go @@ -175,7 +175,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) { {api.Version{2, 0}, http.MethodGet, `cachegroupparameters/?$`, cachegroupparameter.ReadAllCacheGroupParameters, auth.PrivLevelReadOnly, Authenticated, nil, 212449724, perlBypass}, {api.Version{2, 0}, http.MethodPost, `cachegroupparameters/?$`, cachegroupparameter.AddCacheGroupParameters, auth.PrivLevelOperations, Authenticated, nil, 212449725, perlBypass}, {api.Version{2, 0}, http.MethodGet, `cachegroups/{id}/parameters/?$`, api.ReadHandler(&cachegroupparameter.TOCacheGroupParameter{}), auth.PrivLevelReadOnly, Authenticated, nil, 212449723, noPerlBypass}, - {api.Version{2, 0}, http.MethodGet, `cachegroups/{id}/unassigned_parameters/?$`, api.ReadHandler(&cachegroupparameter.TOCacheGroupUnassignedParameter{}), auth.PrivLevelReadOnly, Authenticated, nil, 2457339250, noPerlBypass}, {api.Version{2, 0}, http.MethodDelete, `cachegroupparameters/{cachegroupID}/{parameterId}$`, api.DeleteHandler(&cachegroupparameter.TOCacheGroupParameter{}), auth.PrivLevelOperations, Authenticated, nil, 212449733, noPerlBypass}, //Capabilities @@ -559,7 +558,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) { {api.Version{1, 1}, http.MethodGet, `cachegroupparameters/?(\.json)?$`, cachegroupparameter.ReadAllCacheGroupParameters, auth.PrivLevelReadOnly, Authenticated, nil, 912449724, perlBypass}, {api.Version{1, 1}, http.MethodPost, `cachegroupparameters/?(\.json)?$`, cachegroupparameter.AddCacheGroupParameters, auth.PrivLevelOperations, Authenticated, nil, 912449725, perlBypass}, {api.Version{1, 1}, http.MethodGet, `cachegroups/{id}/parameters/?(\.json)?$`, api.ReadHandler(&cachegroupparameter.TOCacheGroupParameter{}), auth.PrivLevelReadOnly, Authenticated, nil, 912449723, perlBypass}, - {api.Version{1, 1}, http.MethodGet, `cachegroups/{id}/unassigned_parameters/?(\.json)?$`, api.ReadHandler(&cachegroupparameter.TOCacheGroupUnassignedParameter{}), auth.PrivLevelReadOnly, Authenticated, nil, 1457339250, perlBypass}, + {api.Version{1, 1}, http.MethodGet, `cachegroups/{id}/unassigned_parameters/?(\.json)?$`, api.DeprecatedReadHandler(&cachegroupparameter.TOCacheGroupUnassignedParameter{}, util.StrPtr("GET /cachegroupparameters & GET /parameters")), auth.PrivLevelReadOnly, Authenticated, nil, 1457339250, perlBypass}, {api.Version{1, 1}, http.MethodDelete, `cachegroupparameters/{cachegroupID}/{parameterId}$`, api.DeleteHandler(&cachegroupparameter.TOCacheGroupParameter{}), auth.PrivLevelOperations, Authenticated, nil, 912449733, perlBypass}, //Capabilities diff --git a/traffic_portal/app/src/common/api/ParameterService.js b/traffic_portal/app/src/common/api/ParameterService.js index a5d9829e88..978dfccb11 100644 --- a/traffic_portal/app/src/common/api/ParameterService.js +++ b/traffic_portal/app/src/common/api/ParameterService.js @@ -94,17 +94,6 @@ var ParameterService = function($http, locationUtils, messageModel, ENV) { ); }; - this.getCacheGroupUnassignedParams = function(cgId) { - return $http.get(ENV.api['legacy'] + 'cachegroups/' + cgId + '/unassigned_parameters').then( - function (result) { - return result.data.response; - }, - function (err) { - throw err; - } - ); - }; - }; ParameterService.$inject = ['$http', 'locationUtils', 'messageModel', 'ENV']; diff --git a/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js b/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js index d9206aee29..90a56d69f8 100644 --- a/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js +++ b/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js @@ -55,8 +55,11 @@ var TableCacheGroupParametersController = function(cacheGroup, parameters, $cont cg: function() { return cacheGroup; }, - parameters: function(parameterService) { - return parameterService.getCacheGroupUnassignedParams(cacheGroup.id); + allParams: function(parameterService) { + return parameterService.getParameters(); + }, + assignedParams: function() { + return new Set(parameters.map(function(x){return x.id;})); } } }); diff --git a/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js b/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js index e6a6b9b899..502464ab56 100644 --- a/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js +++ b/traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js @@ -17,22 +17,30 @@ * under the License. */ -var TableCacheGroupParamsUnassignedController = function(cg, parameters, $scope, $uibModalInstance) { +var TableCacheGroupParamsUnassignedController = function(cg, allParams, assignedParams, $scope, $uibModalInstance) { var selectedParams = []; $scope.cg = cg; - $scope.unassignedParams = parameters; + $scope.unassignedParams = allParams.filter( + function(p) { + return !assignedParams.has(p.id); + } + ); var addParam = function(paramId) { - if (_.indexOf(selectedParams, paramId) == -1) { + if (selectedParams.indexOf(paramId) === -1) { selectedParams.push(paramId); } }; var removeParam = function(paramId) { - selectedParams = _.without(selectedParams, paramId); + selectedParams = selectedParams.filter( + function (param) { + return param !== paramId; + } + ); }; $scope.updateParams = function($event, paramId) { @@ -70,5 +78,5 @@ var TableCacheGroupParamsUnassignedController = function(cg, parameters, $scope, }; -TableCacheGroupParamsUnassignedController.$inject = ['cg', 'parameters', '$scope', '$uibModalInstance']; +TableCacheGroupParamsUnassignedController.$inject = ['cg', 'allParams', 'assignedParams', '$scope', '$uibModalInstance']; module.exports = TableCacheGroupParamsUnassignedController;