Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To types rfc format #7575

Merged
merged 30 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0a8b9a1
types rfc time changes
gbkannan89 Jun 6, 2023
502cf96
types rfc time changes fixes
gbkannan89 Jun 6, 2023
1f08a90
Merge branch 'to-types-rfc-format' of https://github.com/gbkannan89/t…
gbkannan89 Jun 6, 2023
205713a
type get api scan order fix
gbkannan89 Jun 7, 2023
3500159
types golang rfc changes
gbkannan89 Jun 12, 2023
45890cd
DOC UPDATED FOR TYPE
gbkannan89 Jun 12, 2023
aeb5f29
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jun 12, 2023
93fbe68
removed unwanted code
gbkannan89 Jun 13, 2023
e6864eb
test case fix
gbkannan89 Jun 13, 2023
b70e0fc
revert code
gbkannan89 Jun 13, 2023
d0928b0
revert old change
gbkannan89 Jun 13, 2023
049efd1
align correction
gbkannan89 Jun 13, 2023
212c662
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jun 16, 2023
832616a
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jun 19, 2023
5f948c9
Delete admin
gbkannan89 Jun 19, 2023
0f5d286
comments addresed
gbkannan89 Jun 19, 2023
02d15eb
typo changes
gbkannan89 Jun 22, 2023
0b51a37
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jun 27, 2023
725ab59
comment addressing
gbkannan89 Jul 3, 2023
0ccba59
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jul 4, 2023
40c7820
comment changes
gbkannan89 Jul 4, 2023
9a8457e
comments addressed
gbkannan89 Jul 5, 2023
ba0ae3d
removed unused TypeNullableV5
gbkannan89 Jul 5, 2023
8ff2951
comments corrected as per fnc name
gbkannan89 Jul 5, 2023
48f86be
test case fail fix
gbkannan89 Jul 5, 2023
aa0b885
correct method used
gbkannan89 Jul 5, 2023
d253c0a
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jul 5, 2023
f9f14ed
Merge branch 'master' into to-types-rfc-format
gbkannan89 Jul 6, 2023
4c0bf2d
type reference correction
gbkannan89 Jul 6, 2023
a6b4567
changelog fixed
gbkannan89 Jul 6, 2023
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
8 changes: 4 additions & 4 deletions docs/source/api/v5/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Response Structure
------------------
:description: A short description of this type
:id: An integral, unique identifier for this type
:lastUpdated: The date and time at which this type was last updated, in :ref:`non-rfc-datetime`
:lastUpdated: The date and time at which this type was last updated, in :rfc:`3339`
:name: The name of this type
:useInTable: The name of the Traffic Ops database table that contains objects which are grouped, identified, or described by this type

Expand All @@ -77,7 +77,7 @@ Response Structure
{ "response": [
{
"id": 48,
"lastUpdated": "2018-12-12 16:26:41+00",
"lastUpdated": "2018-12-12T20:49:28.111111Z"",
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
"name": "TC_LOC",
"description": "Location for Traffic Control Component Servers",
"useInTable": "cachegroup"
Expand Down Expand Up @@ -124,7 +124,7 @@ Response Structure

:description: A short description of this type
:id: An integral, unique identifier for this type
:lastUpdated: The date and time at which this type was last updated, in :ref:`non-rfc-datetime`
:lastUpdated: The date and time at which this type was last updated, in :rfc:`3339`
:name: The name of this type
:useInTable: The name of the Traffic Ops database table that contains objects which are grouped, identified, or described by this type

Expand Down Expand Up @@ -152,7 +152,7 @@ Response Structure
"response": [
{
"id": 3004,
"lastUpdated": "2020-02-26 18:58:41+00",
"lastUpdated": "2020-02-26T20:49:28.111111Z"",
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
"name": "Example01",
"description": "Example"
"useInTable": "server"
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v5/types_id.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Response Structure
"response": [
{
"id": 3004,
"lastUpdated": "2020-02-26 18:58:41+00",
"lastUpdated": "2020-02-26T20:49:28.111111Z",
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
"name": "Example02",
"description": "Example"
"useInTable": "server"
Expand Down
26 changes: 26 additions & 0 deletions lib/go-tc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package tc
import (
"database/sql"
"errors"
"time"
)

// TypesResponse is the type of a response from Traffic Ops to a GET request
Expand Down Expand Up @@ -49,6 +50,31 @@ type TypeNullable struct {
UseInTable *string `json:"useInTable" db:"use_in_table"`
}

rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
// TypesResponseV5 is the type of a response from Traffic Ops to a GET request
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
// made to its /types API endpoint.
type TypesResponseV5 struct {
Response []TypeV5 `json:"response"`
Alerts
}

// TypeV5 contains information about a given Type in Traffic Ops.
type TypeV5 struct {
ID int `json:"id"`
LastUpdated time.Time `json:"lastUpdated"`
Name string `json:"name"`
Description string `json:"description"`
UseInTable string `json:"useInTable"`
}

// TypeNullableV5 contains information about a given Type in Traffic Ops.
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
type TypeNullableV5 struct {
ID *int `json:"id" db:"id"`
LastUpdated *time.Time `json:"lastUpdated" db:"last_updated"`
Name *string `json:"name" db:"name"`
Description *string `json:"description" db:"description"`
UseInTable *string `json:"useInTable" db:"use_in_table"`
}

// GetTypeData returns the type's name and use_in_table, true/false if the
// query returned data, and any error.
//
Expand Down
Binary file added traffic_ops/app/admin
ocket8888 marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
2 changes: 1 addition & 1 deletion traffic_ops/testing/api/v5/traffic_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type TrafficControl struct {
Tenants []tc.Tenant `json:"tenants"`
ServerCheckExtensions []tc.ServerCheckExtensionNullable `json:"servercheck_extensions"`
Topologies []tc.Topology `json:"topologies"`
Types []tc.Type `json:"types"`
Types []tc.TypeV5 `json:"types"`
SteeringTargets []tc.SteeringTargetNullable `json:"steeringTargets"`
Serverchecks []tc.ServercheckRequestNullable `json:"serverchecks"`
Users []tc.UserV4 `json:"users"`
Expand Down
16 changes: 8 additions & 8 deletions traffic_ops/testing/api/v5/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestTypes(t *testing.T) {
currentTimeRFC := currentTime.Format(time.RFC1123)
tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)

methodTests := utils.TestCase[client.Session, client.RequestOptions, tc.Type]{
methodTests := utils.TestCase[client.Session, client.RequestOptions, tc.TypeV5]{
"GET": {
"NOT MODIFIED when NO CHANGES made": {
ClientSession: TOSession,
Expand All @@ -65,7 +65,7 @@ func TestTypes(t *testing.T) {
"POST": {
"BAD REQUEST when INVALID useInTable NOT server": {
ClientSession: TOSession,
RequestBody: tc.Type{
RequestBody: tc.TypeV5{
Description: "Host header regular expression-Test",
Name: "TEST_1",
UseInTable: "regex",
Expand All @@ -74,20 +74,20 @@ func TestTypes(t *testing.T) {
},
"OK when VALID request when useInTable=server": {
ClientSession: TOSession,
RequestBody: tc.Type{
RequestBody: tc.TypeV5{
Description: "Host header regular expression-Test",
Name: "TEST_4",
UseInTable: "server",
},
Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusCreated),
validateTypeUpdateCreateFields("TEST_4", map[string]interface{}{"Name": "TEST_4"})),
},
},
"PUT": {
"BAD REQUEST when useInTable NOT server": {
EndpointID: GetTypeID(t, "ACTIVE_DIRECTORY"),
ClientSession: TOSession,
RequestBody: tc.Type{
RequestBody: tc.TypeV5{
Description: "Active Directory User",
Name: "TEST_3",
UseInTable: "cachegroup",
Expand All @@ -97,7 +97,7 @@ func TestTypes(t *testing.T) {
"OK when VALID request when useInTable=server": {
EndpointID: GetTypeID(t, "RIAK"),
ClientSession: TOSession,
RequestBody: tc.Type{
RequestBody: tc.TypeV5{
Description: "riak type",
Name: "TEST_5",
UseInTable: "server",
Expand Down Expand Up @@ -158,7 +158,7 @@ func validateTypeSort() utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, alerts tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected Type response to not be nil.")
var typeNames []string
typeResp := resp.([]tc.Type)
typeResp := resp.([]tc.TypeV5)
for _, typ := range typeResp {
typeNames = append(typeNames, typ.Name)
}
Expand All @@ -169,7 +169,7 @@ func validateTypeSort() utils.CkReqFunc {
func validateTypeFields(expectedResp map[string]interface{}) utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected Type response to not be nil.")
typeResp := resp.([]tc.Type)
typeResp := resp.([]tc.TypeV5)
for field, expected := range expectedResp {
for _, typ := range typeResp {
switch field {
Expand Down
8 changes: 4 additions & 4 deletions traffic_ops/traffic_ops_golang/routing/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `system/info/?$`, Handler: systeminfo.Get, RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: nil, Authenticated: Authenticated, Middlewares: nil, ID: 42104747531},

//Type: CRUD
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `types/?$`, Handler: api.ReadHandler(&types.TOType{}), RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: []string{"TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 422670182331},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPut, Path: `types/{id}$`, Handler: api.UpdateHandler(&types.TOType{}), RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:UPDATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 4886011531},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPost, Path: `types/?$`, Handler: api.CreateHandler(&types.TOType{}), RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:CREATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 451330819531},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodDelete, Path: `types/{id}$`, Handler: api.DeleteHandler(&types.TOType{}), RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:DELETE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 4317577331},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `types/?$`, Handler: types.GetV5, RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: []string{"TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 422670182331},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPut, Path: `types/{id}$`, Handler: types.UpdateTypeV5, RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:UPDATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 4886011531},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPost, Path: `types/?$`, Handler: types.CreateTypeV5, RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:CREATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 451330819531},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodDelete, Path: `types/{id}$`, Handler: types.DeleteTypeV5, RequiredPrivLevel: auth.PrivLevelOperations, RequiredPermissions: []string{"TYPE:DELETE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 4317577331},

//About
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `about/?$`, Handler: about.Handler(), RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: nil, Authenticated: Authenticated, Middlewares: nil, ID: 431750116631},
Expand Down
Loading