You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2021/07/16 20:28:17 UTC
[trafficcontrol] branch master updated: Remove types used only by
removed APIv1 endpoints/client (#6028)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 0d84f2a Remove types used only by removed APIv1 endpoints/client (#6028)
0d84f2a is described below
commit 0d84f2a8a821e3ef4bf7b5d35f6a38ed633cfe13
Author: ocket8888 <oc...@apache.org>
AuthorDate: Fri Jul 16 14:28:02 2021 -0600
Remove types used only by removed APIv1 endpoints/client (#6028)
* Remove a type alias used only by removed APIv1 endpoints.
* Remove CGFallbacks structures
* Remove unused DS structures
* Remove file containing only logic for APIv1
---
lib/go-tc/cachegroupfallback.go | 51 --------
lib/go-tc/deliveryservice_ssl_keys.go | 3 -
lib/go-tc/deliveryservices.go | 85 -------------
lib/go-tc/nullable_test.go | 1 -
.../cachegroupparameter/parameters_test.go | 3 +-
.../cachegroupparameter/unassigned_parameters.go | 135 ---------------------
.../trafficvault/backends/riaksvc/dsutil.go | 8 +-
traffic_ops/v2-client/dsuser.go | 12 +-
8 files changed, 15 insertions(+), 283 deletions(-)
diff --git a/lib/go-tc/cachegroupfallback.go b/lib/go-tc/cachegroupfallback.go
deleted file mode 100644
index 4152e87..0000000
--- a/lib/go-tc/cachegroupfallback.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package tc
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// CacheGroupFallbacksResponse is a list of CacheGroupFallbacks as a response.
-// swagger:response CacheGroupFallbacksResponse
-// in: body
-type CacheGroupFallbacksResponse struct {
- // in: body
- Response []CacheGroupFallback `json:"response"`
-}
-
-// CacheGroupFallbackResponse is a single CacheGroupFallback response for Update
-// and Create to depict what changed.
-// swagger:response CacheGroupFallbackResponse
-// in: body
-type CacheGroupFallbackResponse struct {
- // in: body
- Response CacheGroupFallback `json:"response"`
-}
-
-// CacheGroupFallback ...
-type CacheGroupFallback struct {
- PrimaryCgId int `json:"primaryId" db:"primary_cg"`
- BackupCgId int `json:"backupId" db:"backup_cg"`
- SetOrder int `json:"setOrder" db:"set_order"`
-}
-
-// CacheGroupFallbackNullable ...
-type CacheGroupFallbackNullable struct {
- PrimaryCgId *int `json:"primaryId" db:"primary_cg"`
- BackupCgId *int `json:"backupId" db:"backup_cg"`
- SetOrder *int `json:"setOrder" db:"set_order"`
-}
diff --git a/lib/go-tc/deliveryservice_ssl_keys.go b/lib/go-tc/deliveryservice_ssl_keys.go
index f81f2ce..b1c0db0 100644
--- a/lib/go-tc/deliveryservice_ssl_keys.go
+++ b/lib/go-tc/deliveryservice_ssl_keys.go
@@ -230,9 +230,6 @@ type URISignerKeyset struct {
Keys []jwk.EssentialHeader `json:"keys"`
}
-// Deprecated: use TrafficVaultPing instead.
-type RiakPingResp TrafficVaultPing
-
// TrafficVaultPing represents the status of a given Traffic Vault server.
type TrafficVaultPing struct {
Status string `json:"status"`
diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index d4b2037..2884301 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -31,18 +31,6 @@ const DefaultMaxRequestHeaderBytes = 0
const MinRangeSliceBlockSize = 262144 // 265Kib
const MaxRangeSliceBlockSize = 33554432 // 32Mib
-// GetDeliveryServiceResponse is deprecated use DeliveryServicesResponse...
-type GetDeliveryServiceResponse struct {
- Response []DeliveryService `json:"response"`
-}
-
-// DeliveryServicesResponse ...
-// Deprecated: use DeliveryServicesNullableResponse instead
-type DeliveryServicesResponse struct {
- Response []DeliveryService `json:"response"`
- Alerts
-}
-
// DeliveryServicesResponseV30 is the type of a response from the
// /api/3.0/deliveryservices Traffic Ops endpoint.
// TODO: Move these into the respective clients?
@@ -70,13 +58,6 @@ type DeliveryServicesNullableResponse struct {
Alerts
}
-// CreateDeliveryServiceResponse ...
-// Deprecated: use CreateDeliveryServiceNullableResponse instead
-type CreateDeliveryServiceResponse struct {
- Response []DeliveryService `json:"response"`
- Alerts
-}
-
// CreateDeliveryServiceNullableResponse ...
// Deprecated: Please only use the versioned structures.
type CreateDeliveryServiceNullableResponse struct {
@@ -84,13 +65,6 @@ type CreateDeliveryServiceNullableResponse struct {
Alerts
}
-// UpdateDeliveryServiceResponse ...
-// Deprecated: use UpdateDeliveryServiceNullableResponse instead
-type UpdateDeliveryServiceResponse struct {
- Response []DeliveryService `json:"response"`
- Alerts
-}
-
// UpdateDeliveryServiceNullableResponse ...
// Deprecated: Please only use the versioned structures.
type UpdateDeliveryServiceNullableResponse struct {
@@ -778,31 +752,6 @@ type DeliveryServiceMatch struct {
Pattern string `json:"pattern"`
}
-// DeliveryServiceStateResponse ...
-type DeliveryServiceStateResponse struct {
- Response DeliveryServiceState `json:"response"`
-}
-
-// DeliveryServiceState ...
-type DeliveryServiceState struct {
- Enabled bool `json:"enabled"`
- Failover DeliveryServiceFailover `json:"failover"`
-}
-
-// DeliveryServiceFailover ...
-type DeliveryServiceFailover struct {
- Locations []string `json:"locations"`
- Destination DeliveryServiceDestination `json:"destination"`
- Configured bool `json:"configured"`
- Enabled bool `json:"enabled"`
-}
-
-// DeliveryServiceDestination ...
-type DeliveryServiceDestination struct {
- Location string `json:"location"`
- Type string `json:"type"`
-}
-
// DeliveryServiceHealthResponse is the type of a response from Traffic Ops to
// a request for a Delivery Service's "health".
type DeliveryServiceHealthResponse struct {
@@ -838,36 +787,6 @@ type DeliveryServiceCapacity struct {
UtilizedPercent float64 `json:"utilizedPercent"`
MaintenancePercent float64 `json:"maintenancePercent"`
}
-
-type DeliveryServiceMatchesResp []DeliveryServicePatterns
-
-type DeliveryServicePatterns struct {
- Patterns []string `json:"patterns"`
- DSName DeliveryServiceName `json:"dsName"`
-}
-
-type DeliveryServiceMatchesResponse struct {
- Response []DeliveryServicePatterns `json:"response"`
-}
-
-// DeliveryServiceRoutingResponse ...
-type DeliveryServiceRoutingResponse struct {
- Response DeliveryServiceRouting `json:"response"`
-}
-
-// DeliveryServiceRouting ...
-type DeliveryServiceRouting struct {
- StaticRoute int `json:"staticRoute"`
- Miss int `json:"miss"`
- Geo float64 `json:"geo"`
- Err int `json:"err"`
- CZ float64 `json:"cz"`
- DSR float64 `json:"dsr"`
- Fed int `json:"fed"`
- RegionalAlternate int `json:"regionalAlternate"`
- RegionalDenied int `json:"regionalDenied"`
-}
-
type FederationDeliveryServiceNullable struct {
ID *int `json:"id" db:"id"`
CDN *string `json:"cdn" db:"cdn"`
@@ -893,10 +812,6 @@ type UserDeliveryServicePostResponse struct {
Response DeliveryServiceUserPost `json:"response"`
}
-type UserDeliveryServicesNullableResponse struct {
- Response []DeliveryServiceNullable `json:"response"`
-}
-
type DSServerIDs struct {
DeliveryServiceID *int `json:"dsId" db:"deliveryservice"`
ServerIDs []int `json:"servers"`
diff --git a/lib/go-tc/nullable_test.go b/lib/go-tc/nullable_test.go
index 442bc8e..bf1f23d 100644
--- a/lib/go-tc/nullable_test.go
+++ b/lib/go-tc/nullable_test.go
@@ -34,7 +34,6 @@ import (
func TestNullStructs(t *testing.T) {
compareWithNullable(t, ASN{}, ASNNullable{})
- compareWithNullable(t, CacheGroupFallback{}, CacheGroupFallbackNullable{})
compareWithNullable(t, CacheGroup{}, CacheGroupNullable{})
compareWithNullable(t, CDN{}, CDNNullable{})
compareWithNullable(t, Coordinate{}, CoordinateNullable{})
diff --git a/traffic_ops/traffic_ops_golang/cachegroupparameter/parameters_test.go b/traffic_ops/traffic_ops_golang/cachegroupparameter/parameters_test.go
index 72c513a..29776eb 100644
--- a/traffic_ops/traffic_ops_golang/cachegroupparameter/parameters_test.go
+++ b/traffic_ops/traffic_ops_golang/cachegroupparameter/parameters_test.go
@@ -151,8 +151,7 @@ func TestReadCacheGroupParameters(t *testing.T) {
},
}
toParameterReaders := map[string]api.Reader{
- "Unassigned Parameters": &TOCacheGroupUnassignedParameter{},
- "Parameters": &TOCacheGroupParameter{},
+ "Parameters": &TOCacheGroupParameter{},
}
for _, testCase := range testCases {
for toParameterKey, toParameterReader := range toParameterReaders {
diff --git a/traffic_ops/traffic_ops_golang/cachegroupparameter/unassigned_parameters.go b/traffic_ops/traffic_ops_golang/cachegroupparameter/unassigned_parameters.go
deleted file mode 100644
index 2f470ec..0000000
--- a/traffic_ops/traffic_ops_golang/cachegroupparameter/unassigned_parameters.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// Package cachegroupparameter is deprecated and will be removed with API v1-3.
-package cachegroupparameter
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import (
- "errors"
- "fmt"
- "github.com/apache/trafficcontrol/lib/go-log"
- "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/util/ims"
- "net/http"
- "strconv"
- "time"
-
- "github.com/apache/trafficcontrol/lib/go-tc"
- "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/auth"
- "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
- "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/parameter"
-)
-
-// TOCacheGroupUnassignedParameter Unassigned Parameter TO request
-type TOCacheGroupUnassignedParameter struct {
- api.APIInfoImpl `json:"-"`
- tc.CacheGroupParameterNullable
-}
-
-// ParamColumns Parameter Where Column definitions
-func (cgunparam *TOCacheGroupUnassignedParameter) ParamColumns() map[string]dbhelpers.WhereColumnInfo {
- return map[string]dbhelpers.WhereColumnInfo{
- ParameterIDQueryParam: dbhelpers.WhereColumnInfo{Column: "p.id", Checker: api.IsInt},
- }
-}
-
-// GetType Get type string
-func (cgunparam *TOCacheGroupUnassignedParameter) GetType() string {
- return "cachegroup_unassigned_params"
-}
-
-func (cgunparam *TOCacheGroupUnassignedParameter) Read(h http.Header, useIMS bool) ([]interface{}, error, error, int, *time.Time) {
- var maxTime time.Time
- var runSecond bool
- queryParamsToQueryCols := cgunparam.ParamColumns()
- parameters := cgunparam.APIInfo().Params
- where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(parameters, queryParamsToQueryCols)
- if len(errs) > 0 {
- return nil, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
- }
-
- if useIMS {
- runSecond, maxTime = ims.TryIfModifiedSinceQuery(cgunparam.APIInfo().Tx, h, queryValues, selectMaxLastUpdatedQuery(where))
- if !runSecond {
- log.Debugln("IMS HIT")
- return []interface{}{}, nil, nil, http.StatusNotModified, &maxTime
- }
- log.Debugln("IMS MISS")
- } else {
- log.Debugln("Non IMS request")
- }
-
- cgID, err := strconv.Atoi(parameters[CacheGroupIDQueryParam])
- if err != nil {
- return nil, errors.New("cache group id must be an integer"), nil, http.StatusBadRequest, nil
- }
-
- _, ok, err := dbhelpers.GetCacheGroupNameFromID(cgunparam.ReqInfo.Tx.Tx, cgID)
- if err != nil {
- return nil, nil, err, http.StatusInternalServerError, nil
- } else if !ok {
- return nil, errors.New("cachegroup does not exist"), nil, http.StatusNotFound, nil
- }
-
- // TODO: enhance build query to handle cols that are not in WHERE as well as appending to existing WHERE
- queryValues[CacheGroupIDQueryParam] = cgID
- if len(where) > 0 {
- where = fmt.Sprintf("\nAND%s", where[len(dbhelpers.BaseWhere):])
- }
-
- query := selectUnassignedParametersQuery() + where + orderBy + pagination
- rows, err := cgunparam.ReqInfo.Tx.NamedQuery(query, queryValues)
- if err != nil {
- return nil, nil, errors.New("querying " + cgunparam.GetType() + ": " + err.Error()), http.StatusInternalServerError, nil
- }
- defer rows.Close()
-
- params := []interface{}{}
- for rows.Next() {
- var p tc.CacheGroupParameterNullable
- if err = rows.StructScan(&p); err != nil {
- return nil, nil, errors.New("scanning " + cgunparam.GetType() + ": " + err.Error()), http.StatusInternalServerError, nil
- }
- if p.Secure != nil && *p.Secure && cgunparam.ReqInfo.User.PrivLevel < auth.PrivLevelAdmin {
- p.Value = ¶meter.HiddenField
- }
- params = append(params, p)
- }
-
- return params, nil, nil, http.StatusOK, &maxTime
-}
-
-func selectUnassignedParametersQuery() string {
-
- query := `SELECT
-p.config_file,
-p.id,
-p.last_updated,
-p.name,
-p.value,
-p.secure
-FROM parameter p
-WHERE p.id NOT IN (
- SELECT parameter
- FROM cachegroup_parameter as cgp
- WHERE cgp.cachegroup = :id
-)`
- return query
-}
diff --git a/traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/dsutil.go b/traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/dsutil.go
index cfc584f..5abe9e0 100644
--- a/traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/dsutil.go
+++ b/traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/dsutil.go
@@ -98,10 +98,10 @@ func putDeliveryServiceSSLKeysObj(key tc.DeliveryServiceSSLKeys, tx *sql.Tx, aut
return err
}
-func ping(tx *sql.Tx, authOpts *riak.AuthOptions, riakPort *uint) (tc.RiakPingResp, error) {
+func ping(tx *sql.Tx, authOpts *riak.AuthOptions, riakPort *uint) (tc.TrafficVaultPing, error) {
servers, err := getRiakServers(tx, riakPort)
if err != nil {
- return tc.RiakPingResp{}, errors.New("getting riak servers: " + err.Error())
+ return tc.TrafficVaultPing{}, errors.New("getting riak servers: " + err.Error())
}
for _, server := range servers {
cluster, err := getRiakStorageCluster([]ServerAddr{server}, authOpts)
@@ -123,9 +123,9 @@ func ping(tx *sql.Tx, authOpts *riak.AuthOptions, riakPort *uint) (tc.RiakPingRe
if err := cluster.Stop(); err != nil {
log.Errorln("stopping Riak cluster (after ping success): " + err.Error())
}
- return tc.RiakPingResp{Status: "OK", Server: server.FQDN + ":" + server.Port}, nil
+ return tc.TrafficVaultPing{Status: "OK", Server: server.FQDN + ":" + server.Port}, nil
}
- return tc.RiakPingResp{}, errors.New("failed to ping any Riak server")
+ return tc.TrafficVaultPing{}, errors.New("failed to ping any Riak server")
}
func getDNSSECKeys(cdnName string, tx *sql.Tx, authOpts *riak.AuthOptions, riakPort *uint) (tc.DNSSECKeysRiak, bool, error) {
diff --git a/traffic_ops/v2-client/dsuser.go b/traffic_ops/v2-client/dsuser.go
index 587af06..8c21b8f 100644
--- a/traffic_ops/v2-client/dsuser.go
+++ b/traffic_ops/v2-client/dsuser.go
@@ -22,7 +22,11 @@ import (
tc "github.com/apache/trafficcontrol/lib/go-tc"
)
-// SetUserDeliveryService associates the given delivery services with the given user.
+// SetUserDeliveryService associates the given Delivery Services with the given
+// user.
+//
+// Deprecated: This method doesn't work, as Traffic Ops API version 2 and later
+// do not actually provide this functionality.
func (to *Session) SetDeliveryServiceUser(userID int, dses []int, replace bool) (*tc.UserDeliveryServicePostResponse, error) {
uri := apiBase + `/deliveryservice_user`
ds := tc.DeliveryServiceUserPost{UserID: &userID, DeliveryServices: &dses, Replace: &replace}
@@ -38,7 +42,11 @@ func (to *Session) SetDeliveryServiceUser(userID int, dses []int, replace bool)
return &resp, nil
}
-// DeleteDeliveryServiceUser deletes the association between the given delivery service and user
+// DeleteDeliveryServiceUser deletes the association between the given Delivery
+// Service and user
+//
+// Deprecated: This method doesn't work, as Traffic Ops API version 2 and later
+// do not actually provide this functionality.
func (to *Session) DeleteDeliveryServiceUser(userID int, dsID int) (*tc.UserDeliveryServiceDeleteResponse, error) {
uri := apiBase + `/deliveryservice_user/` + strconv.Itoa(dsID) + `/` + strconv.Itoa(userID)
resp := tc.UserDeliveryServiceDeleteResponse{}