Skip to content

Commit

Permalink
* Fixed broken capability links for DS
Browse files Browse the repository at this point in the history
* Updated CHANGELOG.md

* Updated based on review comment as well as removed deleteServerCapability button(DS table) and menu-option(right click)
  • Loading branch information
rimashah25 committed Dec 4, 2023
1 parent 80255a0 commit 7bf741f
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 105 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed
- [#7846](https://github.com/apache/trafficcontrol/pull/7846) *Traffic Portal* Increase State character limit
- [#7878](https://github.com/apache/trafficcontrol/pull/7878) *Traffic Ops, Traffic Portal* Fixed the case where TO was failing to assign delivery services to a server, due to a bug in the way the list of preexisting delivery services was being returned.
- [#46](https://github.com/comcast-cdn/trafficcontrol/pull/46) *Traffic Ops, Traffic Portal* Fixed broken capability links for delivery service and added required capability as a column in DS table.

## [8.0.0] - 2023-09-20
### Added
Expand Down
76 changes: 39 additions & 37 deletions docs/source/api/v5/deliveryservices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,45 @@ Request Structure
-----------------
.. table:: Request Query Parameters

+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| Name | Required | Description |
+===================+==========+=========================================================================================================================================+
| cdn | no | Show only the :term:`Delivery Services` belonging to the :ref:`ds-cdn` identified by this integral, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| id | no | Show only the :term:`Delivery Service` that has this integral, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| logsEnabled | no | Show only the :term:`Delivery Services` that have :ref:`ds-logs-enabled` set or not based on this boolean |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| profile | no | Return only :term:`Delivery Services` using the :term:`Profile` that has this :ref:`profile-id` |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| tenant | no | Show only the :term:`Delivery Services` belonging to the :term:`Tenant` identified by this integral, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| topology | no | Show only the :term:`Delivery Services` assigned to the :term:`Topology` identified by this unique name |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| type | no | Return only :term:`Delivery Services` of the :term:`Delivery Service` :ref:`ds-types` identified by this integral, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| accessibleTo | no | Return the :term:`Delivery Services` accessible from a :term:`Tenant` *or it's children* identified by this integral, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| serviceCategory | no | Show only the :term:`Delivery Services` belonging to the :term:`Service Category` that has this name |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| xmlId | no | Show only the :term:`Delivery Service` that has this text-based, unique identifier |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| 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``. |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| active | no | Show only the :term:`Delivery Services` that have :ref:`ds-active` set or not based on this boolean (whether or not they are active) |
+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| Name | Required | Description |
+=======================+==========+=========================================================================================================================================+
| cdn | no | Show only the :term:`Delivery Services` belonging to the :ref:`ds-cdn` identified by this integral, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| id | no | Show only the :term:`Delivery Service` that has this integral, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| logsEnabled | no | Show only the :term:`Delivery Services` that have :ref:`ds-logs-enabled` set or not based on this boolean |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| profile | no | Return only :term:`Delivery Services` using the :term:`Profile` that has this :ref:`profile-id` |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| tenant | no | Show only the :term:`Delivery Services` belonging to the :term:`Tenant` identified by this integral, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| topology | no | Show only the :term:`Delivery Services` assigned to the :term:`Topology` identified by this unique name |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| type | no | Return only :term:`Delivery Services` of the :term:`Delivery Service` :ref:`ds-types` identified by this integral, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| accessibleTo | no | Return the :term:`Delivery Services` accessible from a :term:`Tenant` *or it's children* identified by this integral, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| serviceCategory | no | Show only the :term:`Delivery Services` belonging to the :term:`Service Category` that has this name |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| requiredCapability | no | Return the :term:`Delivery Services` belonging to the :term:`Server Capability` identified by this unique name |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| xmlId | no | Show only the :term:`Delivery Service` that has this text-based, unique identifier |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| 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``. |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| active | no | Show only the :term:`Delivery Services` that have :ref:`ds-active` set or not based on this boolean (whether or not they are active) |
+-----------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+

.. code-block:: http
:caption: Request Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,10 +1443,10 @@ func readGetDeliveryServices(h http.Header, params map[string]string, tx *sqlx.T
"profile": {Column: "ds.profile", Checker: api.IsInt},
"type": {Column: "ds.type", Checker: api.IsInt},
"logsEnabled": {Column: "ds.logs_enabled", Checker: api.IsBool},
"tenant": {Column: "ds.tenant_id", Checker: api.IsInt},
"signingAlgorithm": {Column: "ds.signing_algorithm"},
"topology": {Column: "ds.topology"},
"serviceCategory": {Column: "ds.service_category"},
"tenant": {Column: "ds.tenant_id", Checker: api.IsInt},
"topology": {Column: "ds.topology"},
}

where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(params, queryParamsToSQLCols)
Expand Down Expand Up @@ -1491,6 +1491,11 @@ func readGetDeliveryServices(h http.Header, params map[string]string, tx *sqlx.T
where += " AND ds.tenant_id = ANY(CAST(:accessibleTo AS bigint[])) "
queryValues["accessibleTo"] = pq.Array(accessibleTenants)
}

if reqCap, ok := params["requiredCapability"]; ok {
where += " AND '" + reqCap + "'=ANY(ds.required_capabilities)"
}

query := SelectDeliveryServicesQuery + where + orderBy + pagination
log.Debugln("generated deliveryServices query: " + query)
log.Debugf("executing with values: %++v\n", queryValues)
Expand Down
24 changes: 3 additions & 21 deletions traffic_portal/app/src/common/api/DeliveryServiceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property {string[]} [exampleURLs]
* @property {number} [id]
* @property {string} [lastUpdated]
* @property {string[]} requiredCapabilities
* @property {string} routingName
* @property {boolean} signed
* @property {null|number} [sslKeyVersion]
Expand Down Expand Up @@ -157,10 +158,10 @@ class DeliveryServiceService {
* Gets the server capabilities required by the identified Delivery Service.
*
* @param {number} deliveryServiceID The ID of the Delivery Service in question.
* @returns {Promise<DSRequiredCapability[]>} The Server Capabilities required by the DS with the given ID.
* @returns {Promise<DeliveryService[]>} The Server Capabilities required by the DS with the given ID.
*/
async getServerCapabilities(deliveryServiceID) {
const result = await this.$http.get(`${this.ENV.api.unstable}deliveryservices_required_capabilities`, { params: { deliveryServiceID } });
const result = await this.$http.get(`${this.ENV.api.unstable}deliveryservices`, { params: { deliveryServiceID } });
return result.data.response;
};

Expand Down Expand Up @@ -191,25 +192,6 @@ class DeliveryServiceService {
}
}

/**
* Removes the requirement of a particular Capability from the identified Delivery Service.
*
* @param {number} deliveryServiceID The ID of the Delivery Service from which a Capability requirement will be removed.
* @param {string} requiredCapability The name of the Capability being removed as a requirement.
* @returns {Promise<{alerts: {text: string; level: string}[]}>} The full API response.
*/
async removeServerCapability(deliveryServiceID, requiredCapability) {
try {
const result = await this.$http.delete(`${this.ENV.api.unstable}deliveryservices_required_capabilities`, { params: { deliveryServiceID, requiredCapability } });
return result.data;
} catch (err) {
if (err.data && err.data.alerts) {
this.messageModel.setMessages(err.data.alerts, false);
}
throw err;
}
}

/**
* Get the Delivery Service for which the identified server is responsible for serving content.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var ServerCapabilityService = function($http, ENV, locationUtils, messageModel)
};

this.getServerCapabilityDeliveryServices = function(capabilityName) {
return $http.get(ENV.api.unstable + 'deliveryservices_required_capabilities', { params: { requiredCapability: capabilityName } }).then(
return $http.get(ENV.api.unstable + 'deliveryservices', { params: { requiredCapability: capabilityName } }).then(
function (result) {
return result.data.response;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ function TableDeliveryServicesController(tableName, deliveryServices, steeringTa
field: "remapText",
hide: true
},
{
headerName: "Required Capability(ies)",
field: "requiredCapabilities",
hide: true
},
{
headerName: "Routing Name",
field: "routingName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ var TableServerCapabilitiesController = function(serverCapabilities, $scope, $st
{
text: 'View Delivery Services',
click: function ($itemScope) {
locationUtils.navigateToPath('/server-capabilities/' + $itemScope.sc.name + '/delivery-services');
locationUtils.navigateToPath('/server-capabilities/delivery-services?name=' + $itemScope.sc.name);
}
},
{
text: 'View Servers',
click: function ($itemScope) {
locationUtils.navigateToPath('/server-capabilities/' + $itemScope.sc.name + '/servers');
locationUtils.navigateToPath('/server-capabilities/servers?name=' + $itemScope.sc.name );
}
}
];
Expand Down
Loading

0 comments on commit 7bf741f

Please sign in to comment.