Skip to content

Commit

Permalink
To origin rfc3339 (#7733)
Browse files Browse the repository at this point in the history
* origin initial function completion

* origin test fixes

* origin doc updated

* origin change log

* v50 correction

* typo fix

* type correction

* format caps removed

* changed refrence types

* comments addresed

* test updated

* origin delete

* review comments addressed

* test case and comment fixes

* Merge branch 'master' into to-origin-rfc3339

* var fix

* changelog

* test case issues

* for delete fnc

* test pass

* fixes test case

* test case fixes

* comment fixs

* comment addresed

* comment fixed

* comment addressed

* comment

* comment addressed

* formatting
  • Loading branch information
gbkannan89 committed Sep 5, 2023
1 parent de2cc53 commit 8ce828a
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 191 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7691](https://github.com/apache/trafficcontrol/pull/7691) *Traffic Ops* Fixed `/topologies` v5 APIs to respond with `RFC3339` timestamps.
- [#7413](https://github.com/apache/trafficcontrol/issues/7413) *Traffic Ops* Fixed `/service_category` v5 APIs to respond with `RFC3339` timestamps.
- [#7413](https://github.com/apache/trafficcontrol/issues/7706) *Traffic Ops* Fixed `/statuses` v5 APIs to respond with `RFC3339` timestamps.
- [#7733](https://github.com/apache/trafficcontrol/pull/7733) *Traffic Ops* Fixes `origins` v5 apis to respond with `RFC3339` date/time Format.
- [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic Ops* Fixed `/server_server_capabilities` v5 APIs to respond with `RFC3339` timestamps.
- [#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.
- [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic Ops* Fixed `/server_server_capabilities` v5 APIs to respond with `RFC3339` timestamps.
- [#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.
- [#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.
- [#7623](https://github.com/apache/trafficcontrol/pull/7623) *Traffic Ops* Removed TryIfModifiedSinceQuery from servicecategories.go and reused from ims.go
Expand Down
12 changes: 6 additions & 6 deletions docs/source/api/v5/origins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Response Structure
:ip6Address: The IPv6 address of the :term:`Origin`
:ipAddress: The IPv4 address of the :term:`Origin`
:isPrimary: A boolean value which, when ``true`` specifies this :term:`Origin` as the 'primary' :term:`Origin` served by ``deliveryService``
:lastUpdated: The date and time at which this :term:`Origin` was last modified
:lastUpdated: The date and time at which this :term:`Origin` was last modified in :rfc:`3339` format
:name: The name of the :term:`Origin`
:port: The TCP port on which the :term:`Origin` listens
:profile: The :ref:`profile-name` of the :term:`Profile` used by this :term:`Origin`
Expand Down Expand Up @@ -126,7 +126,7 @@ Response Structure
"ip6Address": null,
"ipAddress": null,
"isPrimary": true,
"lastUpdated": "2018-12-10 19:11:32+00",
"lastUpdated": "2018-12-10T15:59:33.7096-06:00",
"name": "demo1",
"port": null,
"profile": null,
Expand Down Expand Up @@ -201,7 +201,7 @@ Response Structure
:ip6Address: The IPv6 address of the :term:`Origin`
:ipAddress: The IPv4 address of the :term:`Origin`
:isPrimary: A boolean value which, when ``true`` specifies this :term:`Origin` as the 'primary' :term:`Origin` served by ``deliveryService``
:lastUpdated: The date and time at which this :term:`Origin` was last modified
:lastUpdated: The date and time at which this :term:`Origin` was last modified in :rfc:`3339` format
:name: The name of the :term:`Origin`
:port: The TCP port on which the :term:`Origin` listens
:profile: The :ref:`profile-name` of the :term:`Profile` used by this :term:`Origin`
Expand Down Expand Up @@ -243,7 +243,7 @@ Response Structure
"ip6Address": null,
"ipAddress": null,
"isPrimary": null,
"lastUpdated": "2018-12-11 15:14:27+00",
"lastUpdated": "2018-12-11T15:59:33.7096-06:00",
"name": "example",
"port": 80,
"profile": null,
Expand Down Expand Up @@ -320,7 +320,7 @@ Response Structure
:ip6Address: The IPv6 address of the :term:`Origin`
:ipAddress: The IPv4 address of the :term:`Origin`
:isPrimary: A boolean value which, when ``true`` specifies this :term:`Origin` as the 'primary' :term:`Origin` served by ``deliveryService``
:lastUpdated: The date and time at which this :term:`Origin` was last modified
:lastUpdated: The date and time at which this :term:`Origin` was last modified in :rfc:`3339` format
:name: The name of the :term:`Origin`
:port: The TCP port on which the :term:`Origin` listens
:profile: The :ref:`profile-name` of the :term:`Profile` used by this :term:`Origin`
Expand Down Expand Up @@ -362,7 +362,7 @@ Response Structure
"ip6Address": null,
"ipAddress": null,
"isPrimary": true,
"lastUpdated": "2018-12-11 15:40:53+00",
"lastUpdated": "2018-12-11T17:59:33.7096-06:00",
"name": "example",
"port": 443,
"profile": null,
Expand Down
74 changes: 74 additions & 0 deletions lib/go-tc/origins.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package tc
* under the License.
*/

import "time"

// OriginsResponse is a list of Origins as a response.
type OriginsResponse struct {
Response []Origin `json:"response"`
Expand Down Expand Up @@ -54,3 +56,75 @@ type Origin struct {
Tenant *string `json:"tenant" db:"tenant"`
TenantID *int `json:"tenantId" db:"tenant_id"`
}

// OriginsResponseV5 is an alias for the latest minor version of the major version 5.
type OriginsResponseV5 = OriginsResponseV50

// OriginsResponseV50 is a list of Origins as a response for APIv5.
type OriginsResponseV50 struct {
Response []OriginV5 `json:"response"`
Alerts
}

// OriginDetailResponseV5 is an alias for the latest minor version of the major version 5.
type OriginDetailResponseV5 = OriginDetailResponseV50

// OriginDetailResponseV50 is the JSON object returned for a single origin in APIv5.
type OriginDetailResponseV50 struct {
Response OriginV5 `json:"response"`
Alerts
}

// OriginV5 is an alias for the latest minor version of the major version 5.
type OriginV5 = OriginV50

// OriginV50 contains information relating to an Origin, in the latest minor version APIv50.
type OriginV50 struct {
Cachegroup *string `json:"cachegroup" db:"cachegroup"`
CachegroupID *int `json:"cachegroupId" db:"cachegroup_id"`
Coordinate *string `json:"coordinate" db:"coordinate"`
CoordinateID *int `json:"coordinateId" db:"coordinate_id"`
DeliveryService string `json:"deliveryService" db:"deliveryservice"`
DeliveryServiceID int `json:"deliveryServiceId" db:"deliveryservice_id"`
FQDN string `json:"fqdn" db:"fqdn"`
ID int `json:"id" db:"id"`
IP6Address *string `json:"ip6Address" db:"ip6_address"`
IPAddress *string `json:"ipAddress" db:"ip_address"`
IsPrimary bool `json:"isPrimary" db:"is_primary"`
LastUpdated time.Time `json:"lastUpdated" db:"last_updated"`
Name string `json:"name" db:"name"`
Port *int `json:"port" db:"port"`
Profile *string `json:"profile" db:"profile"`
ProfileID *int `json:"profileId" db:"profile_id"`
Protocol string `json:"protocol" db:"protocol"`
Tenant string `json:"tenant" db:"tenant"`
TenantID int `json:"tenantId" db:"tenant_id"`
}

// ToOriginV5 upgrades from Origin to APIv5.
func (old Origin) ToOriginV5() OriginV5 {
r := time.Unix(old.LastUpdated.Unix(), 0)

var originV5 OriginV5
originV5.Cachegroup = old.Cachegroup
originV5.CachegroupID = old.CachegroupID
originV5.Coordinate = old.Coordinate
originV5.CoordinateID = old.CoordinateID
originV5.DeliveryService = *old.DeliveryService
originV5.DeliveryServiceID = *old.DeliveryServiceID
originV5.FQDN = *old.FQDN
originV5.ID = *old.ID
originV5.IP6Address = old.IP6Address
originV5.IPAddress = old.IPAddress
originV5.IsPrimary = *old.IsPrimary
originV5.LastUpdated = r
originV5.Name = *old.Name
originV5.Port = old.Port
originV5.Profile = old.Profile
originV5.ProfileID = old.ProfileID
originV5.Protocol = *old.Protocol
originV5.Tenant = *old.Tenant
originV5.TenantID = *old.TenantID

return originV5
}

0 comments on commit 8ce828a

Please sign in to comment.