Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 6709a28

Browse files
authored
Merge branch 'master' into phys_location_region_mismatch
2 parents a34233e + 82901de commit 6709a28

File tree

6 files changed

+90
-30
lines changed

6 files changed

+90
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
7979

8080
### Fixed
8181
- [RFC3339](https://github.com/apache/trafficcontrol/issues/5911)
82+
- [#7759](https://github.com/apache/trafficcontrol/pull/7759) *Traffic Ops* Fixed `/profiles/{{ID}}/parameters` and `profiles/name/{{name}}/parameters` v5 APIs to respond with `RFC3339` timestamps.
8283
- [#7734](https://github.com/apache/trafficcontrol/pull/7734) *Traffic Ops* Fixed `/profiles` v5 APIs to respond with `RFC3339` timestamps.
8384
- [#7708](https://github.com/apache/trafficcontrol/pull/7708) *Traffic Ops* Fixed `/parameters` v5 APIs to respond with `RFC3339` timestamps
8485
- [#7740](https://github.com/apache/trafficcontrol/pull/7740) *Traffic Ops* Fixed `/staticDNSEntries` v5 APIs to respond with `RFC3339` timestamps.
@@ -101,8 +102,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
101102
- [#7691](https://github.com/apache/trafficcontrol/pull/7691) *Traffic Ops* Fixed `/topologies` v5 APIs to respond with `RFC3339` timestamps.
102103
- [#7413](https://github.com/apache/trafficcontrol/issues/7413) *Traffic Ops* Fixed `/service_category` v5 APIs to respond with `RFC3339` timestamps.
103104
- [#7413](https://github.com/apache/trafficcontrol/issues/7706) *Traffic Ops* Fixed `/statuses` v5 APIs to respond with `RFC3339` timestamps.
104-
- [#](https://github.com/apache/trafficcontrol/pull/) *Traffic Ops* Fixed `/phys_locations` update API to remove error related to mismatching region name and ID.
105-
- [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic Ops* Fixes /server_server_capabilities apis to respond with RFC3339 date/time format
105+
- [#7762](https://github.com/apache/trafficcontrol/pull/7762) *Traffic Ops* Fixed `/phys_locations` update API to remove error related to mismatching region name and ID.
106+
- [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic Ops* Fixed `/server_server_capabilities` v5 APIs to respond with `RFC3339` timestamps.
106107
- [#7730](https://github.com/apache/trafficcontrol/pull/7730) *Traffic Monitor* Fixed the panic seen in TM when `plugin.system_stats.timestamp_ms` appears as float and not string.
107108
- [#4393](https://github.com/apache/trafficcontrol/issues/4393) *Traffic Ops* Fixed the error code and alert structure when TO is queried for a delivery service with no ssl keys.
108109
- [#7623](https://github.com/apache/trafficcontrol/pull/7623) *Traffic Ops* Removed TryIfModifiedSinceQuery from servicecategories.go and reused from ims.go

docs/source/api/v5/profiles_id_parameters.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Response Structure
5252
------------------
5353
:configFile: The :term:`Parameter`'s :ref:`parameter-config-file`
5454
:id: The :term:`Parameter`'s :ref:`parameter-id`
55-
:lastUpdated: The date and time at which this :term:`Parameter` was last updated, in :ref:`non-rfc-datetime`
55+
:lastUpdated: The date and time at which this :term:`Parameter` was last updated, in :rfc:`3339`
5656
:name: :ref:`parameter-name` of the :term:`Parameter`
5757
:profiles: An array of :term:`Profile` :ref:`Names <profile-name>` that use this :term:`Parameter`
5858
:secure: A boolean value that describes whether or not the :term:`Parameter` is :ref:`parameter-secure`
@@ -77,23 +77,23 @@ Response Structure
7777
{
7878
"configFile": "global",
7979
"id": 4,
80-
"lastUpdated": "2018-12-05 17:50:49+00",
80+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
8181
"name": "tm.instance_name",
8282
"secure": false,
8383
"value": "Traffic Ops CDN"
8484
},
8585
{
8686
"configFile": "global",
8787
"id": 5,
88-
"lastUpdated": "2018-12-05 17:50:49+00",
88+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
8989
"name": "tm.toolname",
9090
"secure": false,
9191
"value": "Traffic Ops"
9292
},
9393
{
9494
"configFile": "regex_revalidate.config",
9595
"id": 7,
96-
"lastUpdated": "2018-12-05 17:50:49+00",
96+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
9797
"name": "maxRevalDurationDays",
9898
"secure": false,
9999
"value": "90"

docs/source/api/v5/profiles_name_name_parameters.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Response Structure
5151
------------------
5252
:configFile: The :term:`Parameter`'s :ref:`parameter-config-file`
5353
:id: The :term:`Parameter`'s :ref:`parameter-id`
54-
:lastUpdated: The date and time at which this :term:`Parameter` was last updated, in :ref:`non-rfc-datetime`
54+
:lastUpdated: The date and time at which this :term:`Parameter` was last updated, in :rfc:`3339`
5555
:name: :ref:`parameter-name` of the :term:`Parameter`
5656
:profiles: An array of :term:`Profile` :ref:`Names <profile-name>` that use this :term:`Parameter`
5757
:secure: A boolean value that describes whether or not the :term:`Parameter` is :ref:`parameter-secure`
@@ -76,23 +76,23 @@ Response Structure
7676
{
7777
"configFile": "global",
7878
"id": 4,
79-
"lastUpdated": "2018-12-05 17:50:49+00",
79+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
8080
"name": "tm.instance_name",
8181
"secure": false,
8282
"value": "Traffic Ops CDN"
8383
},
8484
{
8585
"configFile": "global",
8686
"id": 5,
87-
"lastUpdated": "2018-12-05 17:50:49+00",
87+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
8888
"name": "tm.toolname",
8989
"secure": false,
9090
"value": "Traffic Ops"
9191
},
9292
{
9393
"configFile": "regex_revalidate.config",
9494
"id": 7,
95-
"lastUpdated": "2018-12-05 17:50:49+00",
95+
"lastUpdated": "2018-12-05T23:52:59.696337+05:30",
9696
"name": "maxRevalDurationDays",
9797
"secure": false,
9898
"value": "90"

lib/go-tc/parameters.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ type ProfileParameterByName struct {
127127
Value string `json:"value"`
128128
}
129129

130+
// ProfileParameterByNameV5 is the alias to the latest minor version of major version 5
131+
type ProfileParameterByNameV5 ProfileParameterByNameV50
132+
133+
// ProfileParameterByNameV50 is a structure that's used to represent a Parameter
134+
// in a context where they are associated with some Profile specified by a
135+
// client of the Traffic Ops API by its Name.
136+
type ProfileParameterByNameV50 struct {
137+
ConfigFile string `json:"configFile"`
138+
ID int `json:"id"`
139+
LastUpdated time.Time `json:"lastUpdated"`
140+
Name string `json:"name"`
141+
Secure bool `json:"secure"`
142+
Value string `json:"value"`
143+
}
144+
130145
// ProfileParameterByNamePost is a structure that's only used internally to
131146
// represent a Parameter that has been requested by a client of the Traffic Ops
132147
// API to be associated with some Profile which was specified by Name.

traffic_ops/traffic_ops_golang/profileparameter/parameterprofilebyid.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ func GetProfileID(w http.ResponseWriter, r *http.Request) {
3535
return
3636
}
3737
defer inf.Close()
38-
api.RespWriter(w, r, inf.Tx.Tx)(getParametersByProfileID(inf.IntParams["id"], inf.Tx.Tx))
38+
params, paramsV5, err := getParametersByProfileID(inf.IntParams["id"], inf.Tx.Tx, inf.Version)
39+
40+
if inf.Version.Major >= 5 {
41+
api.RespWriter(w, r, inf.Tx.Tx)(paramsV5, err)
42+
} else {
43+
api.RespWriter(w, r, inf.Tx.Tx)(params, err)
44+
}
45+
3946
}
4047

41-
func getParametersByProfileID(profileID int, tx *sql.Tx) ([]tc.ProfileParameterByName, error) {
48+
func getParametersByProfileID(profileID int, tx *sql.Tx, version *api.Version) ([]tc.ProfileParameterByName, []tc.ProfileParameterByNameV5, error) {
4249
q := `
4350
SELECT
4451
parameter.id, parameter.name, parameter.value, parameter.config_file, parameter.secure, parameter.last_updated
@@ -49,16 +56,31 @@ WHERE profile.id = $1
4956
`
5057
rows, err := tx.Query(q, profileID)
5158
if err != nil {
52-
return nil, errors.New("querying profile name parameters: " + err.Error())
59+
return nil, nil, errors.New("querying profile name parameters: " + err.Error())
5360
}
5461
defer rows.Close()
55-
params := []tc.ProfileParameterByName{}
56-
for rows.Next() {
57-
p := tc.ProfileParameterByName{}
58-
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
59-
return nil, errors.New("scanning profile id parameters: " + err.Error())
62+
63+
if version.GreaterThanOrEqualTo(&api.Version{Major: 5, Minor: 0}) {
64+
params := []tc.ProfileParameterByNameV5{}
65+
for rows.Next() {
66+
p := tc.ProfileParameterByNameV5{}
67+
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
68+
return nil, nil, errors.New("scanning profile id parameters: " + err.Error())
69+
}
70+
params = append(params, p)
6071
}
61-
params = append(params, p)
72+
return nil, params, nil
73+
74+
} else {
75+
params := []tc.ProfileParameterByName{}
76+
for rows.Next() {
77+
p := tc.ProfileParameterByName{}
78+
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
79+
return nil, nil, errors.New("scanning profile id parameters: " + err.Error())
80+
}
81+
params = append(params, p)
82+
}
83+
return params, nil, nil
6284
}
63-
return params, nil
85+
6486
}

traffic_ops/traffic_ops_golang/profileparameter/parameterprofilebyname.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ func GetProfileName(w http.ResponseWriter, r *http.Request) {
3737
defer inf.Close()
3838

3939
name := inf.Params["name"]
40-
api.RespWriter(w, r, inf.Tx.Tx)(getParametersByProfileName(inf.Tx.Tx, name))
40+
41+
params, paramsV5, err := getParametersByProfileName(inf.Tx.Tx, name, inf.Version)
42+
43+
if inf.Version.Major >= 5 {
44+
api.RespWriter(w, r, inf.Tx.Tx)(paramsV5, err)
45+
} else {
46+
api.RespWriter(w, r, inf.Tx.Tx)(params, err)
47+
}
4148
}
4249

43-
func getParametersByProfileName(tx *sql.Tx, profileName string) ([]tc.ProfileParameterByName, error) {
50+
func getParametersByProfileName(tx *sql.Tx, profileName string, version *api.Version) ([]tc.ProfileParameterByName, []tc.ProfileParameterByNameV5, error) {
4451
q := `
4552
SELECT
4653
parameter.id, parameter.name, parameter.value, parameter.config_file, parameter.secure, parameter.last_updated
@@ -51,16 +58,31 @@ WHERE profile.name = $1
5158
`
5259
rows, err := tx.Query(q, profileName)
5360
if err != nil {
54-
return nil, errors.New("querying profile name parameters: " + err.Error())
61+
return nil, nil, errors.New("querying profile name parameters: " + err.Error())
5562
}
5663
defer rows.Close()
57-
params := []tc.ProfileParameterByName{}
58-
for rows.Next() {
59-
p := tc.ProfileParameterByName{}
60-
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
61-
return nil, errors.New("scanning profile name parameters: " + err.Error())
64+
65+
if version.GreaterThanOrEqualTo(&api.Version{Major: 5, Minor: 0}) {
66+
params := []tc.ProfileParameterByNameV5{}
67+
for rows.Next() {
68+
p := tc.ProfileParameterByNameV5{}
69+
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
70+
return nil, nil, errors.New("scanning profile name parameters: " + err.Error())
71+
}
72+
params = append(params, p)
6273
}
63-
params = append(params, p)
74+
return nil, params, nil
75+
76+
} else {
77+
params := []tc.ProfileParameterByName{}
78+
for rows.Next() {
79+
p := tc.ProfileParameterByName{}
80+
if err := rows.Scan(&p.ID, &p.Name, &p.Value, &p.ConfigFile, &p.Secure, &p.LastUpdated); err != nil {
81+
return nil, nil, errors.New("scanning profile name parameters: " + err.Error())
82+
}
83+
params = append(params, p)
84+
}
85+
return params, nil, nil
6486
}
65-
return params, nil
87+
6688
}

0 commit comments

Comments
 (0)