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

Fixed lastUpdated timestamp format in api v5 federation resolvers #7596

Merged
merged 26 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
daec738
fr changes
gbkannan89 Jun 22, 2023
7e28bcf
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jun 23, 2023
d02c96b
fr changes
gbkannan89 Jun 23, 2023
4870a84
changelog added
gbkannan89 Jun 23, 2023
5171f6c
type import correction
gbkannan89 Jun 26, 2023
57cdedc
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 4, 2023
e2384b2
fr codefix
gbkannan89 Jul 4, 2023
a0412cd
fr code changes
gbkannan89 Jul 4, 2023
d9c2ef6
comment correction
gbkannan89 Jul 4, 2023
98a9ca5
fixes
gbkannan89 Jul 5, 2023
65094f0
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 5, 2023
a9d345c
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 6, 2023
47337a6
comments addressed
gbkannan89 Jul 6, 2023
c2bde3f
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 6, 2023
c7e5f6d
changelog correction
gbkannan89 Jul 7, 2023
e6a2eac
fr changed to give rfc format res
gbkannan89 Jul 7, 2023
f027940
removed unused function
gbkannan89 Jul 7, 2023
c911558
version revert for deletion
gbkannan89 Jul 7, 2023
2d86f48
space added
gbkannan89 Jul 7, 2023
6a3e0f1
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 10, 2023
ef6a13f
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 11, 2023
8e923f0
comments addressed
gbkannan89 Jul 11, 2023
98bd9a5
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 12, 2023
7aea476
Merge branch 'master' into federation-resolvers-v5
gbkannan89 Jul 13, 2023
d3f17ac
comments addressed
gbkannan89 Jul 13, 2023
80001fe
reference mistake correction
gbkannan89 Jul 13, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7469](https://github.com/apache/trafficcontrol/pull/7469) *Traffic Ops* Changed logic to not report empty or missing cookies into TO error.log.
- [#7586](https://github.com/apache/trafficcontrol/pull/7586) *Traffic Ops* Add permission to Operations Role to read from dnsseckeys endpoint.
- [#7600](https://github.com/apache/trafficcontrol/pull/7600) *t3c* changed default go-direct command line arg to be old to avoid unexpected config changes upon upgrade.
- [#7596](https://github.com/apache/trafficcontrol/pull/7596) *Traffic Ops* Fixes `federation_resolvers` v5 apis to respond with `RFC3339` date/time Format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a part of the "fixed" section.


### Fixed
- [#6318](https://github.com/apache/trafficcontrol/issues/6318) *Docs* Included docs for POST, PUT, DELETE (v3,v4,v5) for statuses and statuses{id}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/api/v5/federation_resolvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Response Structure
------------------
:id: The integral, unique identifier of the resolver
:ipAddress: The IP address or :abbr:`CIDR (Classless Inter-Domain Routing)`-notation subnet of the resolver - may be IPv4 or IPv6
:lastUpdated: The date and time at which this resolver was last updated, in :ref:`non-rfc-datetime`
:lastUpdated: The date and time at which this resolver was last updated, in :rfc:`3339`
:type: The :term:`Type` of the resolver

.. code-block:: http
Expand All @@ -92,7 +92,7 @@ Response Structure
{
"id": 1,
"ipAddress": "::1/1",
"lastUpdated": "2019-11-06 00:00:40+00",
"lastUpdated": "2019-11-06T15:18:14.952814+05:30",
"type": "RESOLVE6"
}
]}
Expand Down
31 changes: 31 additions & 0 deletions lib/go-tc/federation_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"database/sql"
"errors"
"net"
"time"

validation "github.com/go-ozzo/ozzo-validation"
)
Expand Down Expand Up @@ -50,6 +51,36 @@ type FederationResolver struct {
TypeID *uint `json:"typeId,omitempty" db:"type"`
}

// [V5] FederationResolverV5 is an alias for the Federal Resolver struct response used for the latest minor version associated with api major version 5.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GoDoc comment should be gin with the name of the function/ struct that it applies to.

type FederationResolverV5 = FederationResolverV50

// [V50] FederationResolverV50 is used for RFC3339 format timestamp in FederationResolver which represents a resolver record for a CDN Federation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here about godocs.

type FederationResolverV50 struct {
ID *uint `json:"id" db:"id"`
IPAddress *string `json:"ipAddress" db:"ip_address"`
LastUpdated *time.Time `json:"lastUpdated,omitempty" db:"last_updated"`
Type *string `json:"type"`
TypeID *uint `json:"typeId,omitempty" db:"type"`
}

// [V5] FederationResolversV5Response is an alias for the FederationResolvers struct response used for the latest minor version associated with api major version 5.
type FederationResolversV5Response = FederationResolversV50Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like this comment was addressed :)


// [V50] GET request to its /federation_resolvers endpoint for APIv5.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

type FederationResolversV50Response struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V50 should be at the end of the name of the struct here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well.

Alerts
Response []FederationResolverV5 `json:"response"`
}

// [V5] FederationResolverV5Response represents struct response used for the latest minor version associated with api major version 5.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

type FederationResolverV5Response = FederationResolverV50Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V5 should be at the end of the names of the structs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


// [V50] POST request to its /federation_resolvers endpoint APIv5.
type FederationResolverV50Response struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, following the conventions in our repo, the struct name should end with V50

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Alerts
Response FederationResolverV5 `json:"response"`
}

// Validate implements the github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api.ParseValidator
// interface.
func (fr *FederationResolver) Validate(tx *sql.Tx) error {
Expand Down
11 changes: 11 additions & 0 deletions lib/go-tc/tovalidate/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,14 @@ func StringIsValidFloat() *validation.StringRule {
return err == nil && !math.IsNaN(validated)
}, "must be a valid float")
}

// IsValidIPorCIDR returns whether the input is a valid IP address or CIDR notation subnet
func IsValidIPorCIDR(input string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The name should be IsValidIPOrCIDR, instead of IsValidIPorCIDR
Note that the O needs to be capitalized

ip := net.ParseIP(input)
if ip != nil {
return true // Valid IP address
}

_, _, err := net.ParseCIDR(input)
return err == nil // Valid CIDR notation subnet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return the error from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now removed as i removed post method itself.

}
14 changes: 7 additions & 7 deletions traffic_ops/testing/api/v5/federation_resolvers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestFederationResolvers(t *testing.T) {
currentTime := time.Now().UTC().Add(-15 * time.Second)
tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)

methodTests := utils.TestCase[client.Session, client.RequestOptions, tc.FederationResolver]{
methodTests := utils.TestCase[client.Session, client.RequestOptions, tc.FederationResolverV5]{
"GET": {
"NOT MODIFIED when NO CHANGES made": {
ClientSession: TOSession,
Expand Down Expand Up @@ -111,12 +111,12 @@ func TestFederationResolvers(t *testing.T) {
"POST": {
"BAD REQUEST when MISSING IPADDRESS and TYPE FIELDS": {
ClientSession: TOSession,
RequestBody: tc.FederationResolver{},
RequestBody: tc.FederationResolverV5{},
Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
},
"BAD REQUEST when INVALID IP ADDRESS": {
ClientSession: TOSession,
RequestBody: tc.FederationResolver{
RequestBody: tc.FederationResolverV5{
IPAddress: util.Ptr("not a valid IP address"),
TypeID: util.Ptr((uint)(GetTypeId(t, "RESOLVE4"))),
},
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestFederationResolvers(t *testing.T) {
func validateFederationResolverFields(expectedResp map[string]interface{}) utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected Federation Resolver response to not be nil.")
frResp := resp.([]tc.FederationResolver)
frResp := resp.([]tc.FederationResolverV5)
for field, expected := range expectedResp {
for _, fr := range frResp {
switch field {
Expand All @@ -190,7 +190,7 @@ func validateFederationResolverFields(expectedResp map[string]interface{}) utils

func validateFederationResolverPagination(paginationParam string) utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
paginationResp := resp.([]tc.FederationResolver)
paginationResp := resp.([]tc.FederationResolverV5)

opts := client.NewRequestOptions()
opts.QueryParameters.Set("orderby", "id")
Expand All @@ -214,7 +214,7 @@ func validateFederationResolverIDSort() utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, alerts tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected Federation Resolver response to not be nil.")
var frIDs []int
frResp := resp.([]tc.FederationResolver)
frResp := resp.([]tc.FederationResolverV5)
for _, fr := range frResp {
frIDs = append(frIDs, int(*fr.ID))
}
Expand All @@ -225,7 +225,7 @@ func validateFederationResolverIDSort() utils.CkReqFunc {
func validateFederationResolverDescSort() utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, alerts tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected FederationResolver response to not be nil.")
frDescResp := resp.([]tc.FederationResolver)
frDescResp := resp.([]tc.FederationResolverV5)
var descSortedList []uint
var ascSortedList []uint
assert.RequireGreaterOrEqual(t, len(frDescResp), 2, "Need at least 2 Federation Resolvers in Traffic Ops to test desc sort, found: %d", len(frDescResp))
Expand Down
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 @@ -36,7 +36,7 @@ type TrafficControl struct {
TopologyBasedDeliveryServicesRequiredCapabilities []tc.DeliveryServicesRequiredCapability `json:"topologyBasedDeliveryServicesRequiredCapabilities"`
Divisions []tc.Division `json:"divisions"`
Federations []tc.CDNFederation `json:"federations"`
FederationResolvers []tc.FederationResolver `json:"federation_resolvers"`
FederationResolvers []tc.FederationResolverV5 `json:"federation_resolvers"`
Jobs []tc.InvalidationJobCreateV4 `json:"jobs"`
Origins []tc.Origin `json:"origins"`
Profiles []tc.Profile `json:"profiles"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,24 @@ package federation_resolvers

import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"github.com/apache/trafficcontrol/lib/go-log"
"github.com/apache/trafficcontrol/lib/go-rfc"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-tc/tovalidate"
"github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/util/ims"

"github.com/jmoiron/sqlx"

validation "github.com/go-ozzo/ozzo-validation"
)

const insertFederationResolverQuery = `
Expand Down Expand Up @@ -301,3 +306,153 @@ func deleteFederationResolver(inf *api.APIInfo) (tc.Alert, tc.FederationResolver

return alert, result, userErr, sysErr, statusCode
}

// GetFederationResolvers [V5] - get list of federation resolver for APIv5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since federation_resolvers is not using the CRUDer interface, it will be much easier (and would involve lesser lines of code) if we could just check the api version in the Get and Create methods of federation_resolvers, and return the appropriate structs.
You can take a look at this PR for reference: #7547

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, i would do this srijeet

func GetFederationResolvers(w http.ResponseWriter, r *http.Request) {
var maxTime time.Time
var runSecond bool
inf, sysErr, userErr, errCode := api.NewInfo(r, nil, nil)
tx := inf.Tx
if sysErr != nil || userErr != nil {
api.HandleErr(w, r, tx.Tx, errCode, userErr, sysErr)
return
}
defer inf.Close()

queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
"id": dbhelpers.WhereColumnInfo{Column: "federation_resolver.id", Checker: api.IsInt},
"ipAddress": dbhelpers.WhereColumnInfo{Column: "federation_resolver.ip_address"},
"type": dbhelpers.WhereColumnInfo{Column: "type.name"},
}
if _, ok := inf.Params["orderby"]; !ok {
inf.Params["orderby"] = "id"
}

where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, queryParamsToQueryCols)
if len(errs) > 0 {
sysErr = util.JoinErrs(errs)
errCode = http.StatusBadRequest
api.HandleErr(w, r, tx.Tx, errCode, nil, sysErr)
return
}

query := readQuery + where + orderBy + pagination
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)
}
if useIMS {
runSecond, maxTime = ims.TryIfModifiedSinceQuery(tx, r.Header, queryValues, SelectMaxLastUpdatedQuery(where, "federation_resolver"))
if !runSecond {
log.Debugln("IMS HIT")
api.AddLastModifiedHdr(w, maxTime)
w.WriteHeader(http.StatusNotModified)
api.WriteResp(w, r, []tc.FederationResolverV5{})
return
}
log.Debugln("IMS MISS")
} else {
log.Debugln("Non IMS request")
}

rows, err := inf.Tx.NamedQuery(query, queryValues)
Fixed Show fixed Hide fixed
if err != nil {
userErr, sysErr, errCode = api.ParseDBError(err)
if sysErr != nil {
sysErr = fmt.Errorf("federation_resolver read query: %v", sysErr)
}

api.HandleErr(w, r, tx.Tx, errCode, userErr, sysErr)
return
}
defer rows.Close()

var resolvers = []tc.FederationResolverV5{}
for rows.Next() {
var resolver tc.FederationResolverV5
if err := rows.Scan(&resolver.ID, &resolver.IPAddress, &resolver.LastUpdated, &resolver.Type); err != nil {
userErr, sysErr, errCode = api.ParseDBError(err)
if sysErr != nil {
sysErr = fmt.Errorf("federation_resolver scanning: %v", sysErr)
}
api.HandleErr(w, r, tx.Tx, errCode, userErr, sysErr)
return
}

resolvers = append(resolvers, resolver)
}

api.WriteResp(w, r, resolvers)
}

// CreateFederationResolver [V5] - creates the federation resolver with given data for APIv5
func CreateFederationResolver(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()
tx := inf.Tx.Tx

fr, readValErr := readAndValidateJsonStructV5(r)
if readValErr != nil {
api.HandleErr(w, r, tx, http.StatusBadRequest, readValErr, nil)
return
}

// check if type already exists
var exists bool
checkQuery := fmt.Sprintf("SELECT EXISTS(%s WHERE ip_address = $1)", readQuery)
err := tx.QueryRow(checkQuery, fr.IPAddress).Scan(&exists)

if err != nil {
api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, fmt.Errorf("error: %w, when checking if federation_resolver with ip_address %s exists", err, fr.IPAddress))
return
}
if exists {
api.HandleErr(w, r, tx, http.StatusBadRequest, fmt.Errorf("federation_resolver ip_address '%s' already exists", *fr.IPAddress), nil)
return
}

// create type
err = tx.QueryRow(insertFederationResolverQuery, fr.IPAddress, fr.TypeID).Scan(&fr.ID, &fr.IPAddress, &fr.Type, &fr.TypeID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
api.HandleErr(w, r, tx, http.StatusInternalServerError, fmt.Errorf("error: %w in creating federation_resolver ip_address with ip_address: %s", err, fr.IPAddress), nil)
return
}
usrErr, sysErr, code := api.ParseDBError(err)
api.HandleErr(w, r, tx, code, usrErr, sysErr)
return
}
message := fmt.Sprintf("Federation Resolver created [ IP = %s ] with id: %d", *fr.IPAddress, *fr.ID)
alerts := tc.CreateAlerts(tc.SuccessLevel, message)
w.Header().Set("Location", fmt.Sprintf("/api/%d.%d/federation_resolvers?id=%s", inf.Version.Major, inf.Version.Minor, fr.ID))
api.WriteAlertsObj(w, r, http.StatusCreated, alerts, fr)
return
}

// readAndValidateJsonStructV5 [V5] - validates the JSON object passed for APIv5
func readAndValidateJsonStructV5(r *http.Request) (tc.FederationResolverV5, error) {
var fr tc.FederationResolverV5
if err := json.NewDecoder(r.Body).Decode(&fr); err != nil {
userErr := fmt.Errorf("error decoding POST request body into FederationResolverV5 struct %w", err)
return fr, userErr
}

// validate JSON body
rule := validation.NewStringRule(tovalidate.IsValidIPorCIDR, "invalid network IP or CIDR-notation subnet.")
errs := tovalidate.ToErrors(validation.Errors{
"ip_address": validation.Validate(fr.IPAddress, validation.Required, rule),
})
if len(errs) > 0 {
userErr := util.JoinErrs(errs)
return fr, userErr
}
return fr, nil
}
4 changes: 2 additions & 2 deletions traffic_ops/traffic_ops_golang/routing/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodDelete, Path: `federations/{id}/deliveryservices/{dsID}/?$`, Handler: api.DeleteHandler(&federations.TOFedDSes{}), RequiredPrivLevel: auth.PrivLevelAdmin, RequiredPermissions: []string{"FEDERATION:UPDATE", "DELIVERY-SERVICE:UPDATE", "FEDERATION:READ", "DELIVERY-SERVICE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 441740257031},

// Federation Resolvers
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPost, Path: `federation_resolvers/?$`, Handler: federation_resolvers.Create, RequiredPrivLevel: auth.PrivLevelAdmin, RequiredPermissions: []string{"FEDERATION-RESOLVER:CREATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 413437366131},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `federation_resolvers/?$`, Handler: federation_resolvers.Read, RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: []string{"FEDERATION-RESOLVER:READ", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 45660875931},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPost, Path: `federation_resolvers/?$`, Handler: federation_resolvers.CreateFederationResolver, RequiredPrivLevel: auth.PrivLevelAdmin, RequiredPermissions: []string{"FEDERATION-RESOLVER:CREATE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 413437366131},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just used the same functions with the api version checks in there, you wouldn't need to change anything in this file.

{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `federation_resolvers/?$`, Handler: federation_resolvers.GetFederationResolvers, RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: []string{"FEDERATION-RESOLVER:READ", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 45660875931},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodPost, Path: `federations/{id}/federation_resolvers/?$`, Handler: federations.AssignFederationResolversToFederationHandler, RequiredPrivLevel: auth.PrivLevelAdmin, RequiredPermissions: []string{"FEDERATION:UPDATE", "FEDERATION:READ", "FEDERATION-RESOLVER:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 45660876031},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodGet, Path: `federations/{id}/federation_resolvers/?$`, Handler: federations.GetFederationFederationResolversHandler, RequiredPrivLevel: auth.PrivLevelReadOnly, RequiredPermissions: []string{"FEDERATION:READ", "FEDERATION-RESOLVER:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 45660876131},
{Version: api.Version{Major: 5, Minor: 0}, Method: http.MethodDelete, Path: `federation_resolvers/?$`, Handler: federation_resolvers.Delete, RequiredPrivLevel: auth.PrivLevelAdmin, RequiredPermissions: []string{"FEDERATION-RESOLVER:DELETE", "TYPE:READ"}, Authenticated: Authenticated, Middlewares: nil, ID: 400131},
Expand Down
12 changes: 6 additions & 6 deletions traffic_ops/v5-client/federation_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ import (
const apiFederationResolvers = "/federation_resolvers"

// GetFederationResolvers retrieves Federation Resolvers from Traffic Ops.
func (to *Session) GetFederationResolvers(opts RequestOptions) (tc.FederationResolversResponse, toclientlib.ReqInf, error) {
var data tc.FederationResolversResponse
func (to *Session) GetFederationResolvers(opts RequestOptions) (tc.FederationResolversV5Response, toclientlib.ReqInf, error) {
var data tc.FederationResolversV5Response
inf, err := to.get(apiFederationResolvers, opts, &data)
return data, inf, err
}

// CreateFederationResolver creates the Federation Resolver 'fr'.
func (to *Session) CreateFederationResolver(fr tc.FederationResolver, opts RequestOptions) (tc.FederationResolverResponse, toclientlib.ReqInf, error) {
var response tc.FederationResolverResponse
func (to *Session) CreateFederationResolver(fr tc.FederationResolverV5, opts RequestOptions) (tc.FederationResolverV5Response, toclientlib.ReqInf, error) {
var response tc.FederationResolverV5Response
reqInf, err := to.post(apiFederationResolvers, opts, fr, &response)
return response, reqInf, err
}

// DeleteFederationResolver deletes the Federation Resolver identified by 'id'.
func (to *Session) DeleteFederationResolver(id uint, opts RequestOptions) (tc.FederationResolverResponse, toclientlib.ReqInf, error) {
func (to *Session) DeleteFederationResolver(id uint, opts RequestOptions) (tc.FederationResolverV5Response, toclientlib.ReqInf, error) {
if opts.QueryParameters == nil {
opts.QueryParameters = url.Values{}
}
opts.QueryParameters.Set("id", strconv.FormatUint(uint64(id), 10))
var alerts tc.FederationResolverResponse
var alerts tc.FederationResolverV5Response
reqInf, err := to.del(apiFederationResolvers, opts, &alerts)
return alerts, reqInf, err
}