Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- /jobs/:id
- /riak/stats
- /stats_summary/create
- /cdns/configs

## [4.0.0] - 2019-12-16
### Added
Expand Down
37 changes: 33 additions & 4 deletions docs/source/api/cdns_configs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
****************
``cdns/configs``
****************

.. deprecated:: ATCv4
Use the ``GET`` method of :ref:`to-api-cdns` instead.
.. danger:: This endpoint does not appear to work, and thus its use is strongly discouraged!

``GET``
Expand All @@ -34,9 +35,37 @@ No parameters available.

Response Properties
-------------------
:config_file: Presumably the name of some configuration file\ [1]_
:id: The integral, unique identifier for this CDN
:name: The CDN's name
:value: Presumably the content of some configuration file\ [1]_

.. [1] These values are currently missing from this endpoint's output. **DO NOT count on this endpoint to provide this information**.
.. 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: z9P1NkxGebPncUhaChDHtYKYI+XVZfhE6Y84TuwoASZFIMfISELwADLpvpPTN+wwnzBfREksLYn+0313QoBWhA==
X-Server-Name: traffic_ops_golang/
Date: Wed, 14 Nov 2018 20:46:57 GMT
Content-Length: 237

{ "response": [
{
"id": 1,
"name": "ALL"
},
{
"id": 2,
"name": "CDN-in-a-Box"
}
],
"alerts": [
{
"text": "This endpoint is deprecated, please use GET /cdns instead",
"level": "warning"
}
]}
50 changes: 23 additions & 27 deletions traffic_ops/traffic_ops_golang/cdn/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,33 @@ package cdn
*/

import (
"database/sql"
"errors"
"net/http"

"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
)

func GetConfigs(w http.ResponseWriter, r *http.Request) {
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
if userErr != nil || sysErr != nil {
api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
return
}
defer inf.Close()
api.RespWriter(w, r, inf.Tx.Tx)(getConfigs(inf.Tx.Tx))
// TOCDNConf used as a type alias to define functions on to satisfy shared API REST interfaces.
type TOCDNConf struct {
api.APIInfoImpl `json:"-"`
}

func (v *TOCDNConf) NewReadObj() interface{} { return &tc.CDNConfig{} }
func (v *TOCDNConf) SelectQuery() string { return cdnConfSelectQuery() }
func (v *TOCDNConf) ParamColumns() map[string]dbhelpers.WhereColumnInfo {
return map[string]dbhelpers.WhereColumnInfo{}
}

func cdnConfSelectQuery() string {
return `SELECT
name,
id
FROM cdn`
}

func (v *TOCDNConf) Read() ([]interface{}, error, error, int) {
return api.GenericRead(v)
}

func getConfigs(tx *sql.Tx) ([]tc.CDNConfig, error) {
rows, err := tx.Query(`SELECT name, id FROM cdn`)
if err != nil {
return nil, errors.New("querying cdn configs: " + err.Error())
}
cdns := []tc.CDNConfig{}
defer rows.Close()
for rows.Next() {
c := tc.CDNConfig{}
if err := rows.Scan(&c.Name, &c.ID); err != nil {
return nil, errors.New("scanning cdn config: " + err.Error())
}
cdns = append(cdns, c)
}
return cdns, nil
func (v TOCDNConf) GetType() string {
return "cdn_configs"
}
2 changes: 1 addition & 1 deletion traffic_ops/traffic_ops_golang/routing/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
{1.1, http.MethodGet, `cdns/metric_types`, notImplementedHandler, 0, NoAuth, nil, 683165463, noPerlBypass}, // MUST NOT end in $, because the 1.x route is longer

{1.1, http.MethodGet, `cdns/capacity$`, cdn.GetCapacity, auth.PrivLevelReadOnly, Authenticated, nil, 697185281, perlBypass},
{1.1, http.MethodGet, `cdns/configs/?(\.json)?$`, cdn.GetConfigs, auth.PrivLevelReadOnly, Authenticated, nil, 1768437852, noPerlBypass},
{1.1, http.MethodGet, `cdns/configs/?(\.json)?$`, api.DeprecatedReadHandler(&cdn.TOCDNConf{}, util.StrPtr("GET /cdns")), auth.PrivLevelReadOnly, Authenticated, nil, 1768437852, noPerlBypass},

{1.1, http.MethodGet, `cdns/{name}/health/?(\.json)?$`, cdn.GetNameHealth, auth.PrivLevelReadOnly, Authenticated, nil, 1135348194, perlBypass},
{1.1, http.MethodGet, `cdns/health/?(\.json)?$`, cdn.GetHealth, auth.PrivLevelReadOnly, Authenticated, nil, 1085381134, perlBypass},
Expand Down