rimashah25 commented on code in PR #7575:
URL: https://github.com/apache/trafficcontrol/pull/7575#discussion_r1231385206


##########
docs/source/api/v5/types.rst:
##########
@@ -77,7 +77,7 @@ Response Structure
        { "response": [
                {
                        "id": 48,
-                       "lastUpdated": "2018-12-12 16:26:41+00",
+                       "lastUpdated": "2018-12-12T20:49:28.111111Z"",

Review Comment:
   missing time offset, like `+05:30`. This is how RFC format looks like: 
`2023-05-25T15:59:33.7096-06:00`



##########
docs/source/api/v5/types_id.rst:
##########
@@ -93,7 +93,7 @@ Response Structure
                "response": [
                {
                        "id": 3004,
-                       "lastUpdated": "2020-02-26 18:58:41+00",
+                       "lastUpdated": "2020-02-26T20:49:28.111111Z",

Review Comment:
   missing time offset, like `+05:30`. This is how RFC format looks like: 
`2023-05-25T15:59:33.7096-06:00`



##########
docs/source/api/v5/types.rst:
##########
@@ -152,7 +152,7 @@ Response Structure
                "response": [
                {
                        "id": 3004,
-                       "lastUpdated": "2020-02-26 18:58:41+00",
+                       "lastUpdated": "2020-02-26T20:49:28.111111Z"",

Review Comment:
   missing time offset, like `+05:30`. This is how RFC format looks like: 
`2023-05-25T15:59:33.7096-06:00`



##########
traffic_ops/traffic_ops_golang/types/types.go:
##########
@@ -211,3 +215,324 @@ func deleteQuery() string {
 WHERE id=:id`
        return query
 }
+
+// Get [Version :V5]

Review Comment:
   Could use a bit more description like: `GetV5 will retrieve a list of 
types`. And the function name has to match the start of the comment.



##########
lib/go-tc/types.go:
##########
@@ -49,6 +50,31 @@ type TypeNullable struct {
        UseInTable  *string    `json:"useInTable" db:"use_in_table"`
 }
 
+// TypesResponseV5 is the type of a response from Traffic Ops to a GET request

Review Comment:
   Can you added why you created V5 struct? like `TypesResponseV5 is the type 
of a response (for RFC3339) from Traffic Ops to a GET Request`



##########
traffic_ops/app/admin:
##########


Review Comment:
   umm.. a binary file was added by mistake, I think.



##########
traffic_ops/traffic_ops_golang/types/types.go:
##########
@@ -211,3 +215,324 @@ func deleteQuery() string {
 WHERE id=:id`
        return query
 }
+
+// Get [Version :V5]
+func GetV5(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()
+
+       code := http.StatusOK
+       useIMS := false
+       config, e := api.GetConfig(r.Context())
+       if e == nil && config != nil {
+               useIMS = config.UseIMS
+       } else {
+               log.Warnf("Couldn't get config %v", e)
+       }
+
+       var maxTime time.Time
+       var usrErr error
+       var syErr error
+
+       var typeList []tc.TypeV5
+
+       tx := inf.Tx
+
+       typeList, maxTime, code, usrErr, syErr = GetTypesV5(tx, inf.Params, 
useIMS, r.Header)
+       if code == http.StatusNotModified {
+               w.WriteHeader(code)
+               api.WriteResp(w, r, []tc.TypeV5{})
+               return
+       }
+
+       if code == http.StatusBadRequest {
+               api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, usrErr, 
nil)
+               return
+       }
+
+       if sysErr != nil {
+               api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, 
nil, syErr)
+               return
+       }
+
+       if maxTime != (time.Time{}) && api.SetLastModifiedHeader(r, useIMS) {
+               api.AddLastModifiedHdr(w, maxTime)
+       }
+
+       api.WriteResp(w, r, typeList)
+}
+
+// GetTypes [Version : V5] returns types.
+func GetTypesV5(tx *sqlx.Tx, params map[string]string, useIMS bool, header 
http.Header) ([]tc.TypeV5, time.Time, int, error, error) {

Review Comment:
   You can actually combine, `Get` and `GetTypeV5`. But if you don't want to.. 
`GetTypeV5` doesn't need to be global since it isn't call elsewhere except this 
file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to