This is an automated email from the ASF dual-hosted git repository.
rawlin 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 96222fb Remove structs/funcs only used by the removed TO API version
1 (#6038)
96222fb is described below
commit 96222fbea59a80ac0bbafd2a12d6eeabf29b577c
Author: ocket8888 <[email protected]>
AuthorDate: Tue Jul 27 10:24:31 2021 -0600
Remove structs/funcs only used by the removed TO API version 1 (#6038)
* Remove a struct only used by the removed /profiles/trimmed TO API endpoint
* Remove APIv1 server structs
* Remove unused stats_summary-related structure
* Remove unused dsstats constants
* Remove unused User structs
* Remove legacy Snapshot handler now-unused since Perl/APIv1 removal
* Remove unused handler for monitoring configuration
* Remove handler for now-removed APIv1 /regions/name/{{name}} route
* Remove now-unused utility handler for routes not rewritten from Perl
* Remove now-unused helper function to get CDN ID from domain for SSL key
purposes
* Remove unused type definitions for hardware info
---
lib/go-tc/hardware.go | 31 ------
lib/go-tc/profiles.go | 5 -
lib/go-tc/servers.go | 110 ---------------------
lib/go-tc/stats_summary.go | 7 --
lib/go-tc/traffic_stats.go | 8 --
lib/go-tc/users.go | 40 +-------
traffic_ops/traffic_ops_golang/crconfig/handler.go | 22 -----
.../traffic_ops_golang/deliveryservice/keys.go | 12 ---
.../traffic_ops_golang/monitoring/monitoring.go | 13 ---
traffic_ops/traffic_ops_golang/region/name.go | 61 ------------
traffic_ops/traffic_ops_golang/routing/routes.go | 7 --
11 files changed, 4 insertions(+), 312 deletions(-)
diff --git a/lib/go-tc/hardware.go b/lib/go-tc/hardware.go
deleted file mode 100644
index 63414ac..0000000
--- a/lib/go-tc/hardware.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-
- Licensed 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.
-*/
-
-package tc
-
-// HardwareResponse ...
-type HardwareResponse struct {
- Limit int `json:"limit"`
- Response []Hardware `json:"response"`
-}
-
-// Hardware ...
-type Hardware struct {
- ID int `json:"serverId"`
- HostName string `json:"serverHostName"`
- LastUpdated string `json:"lastUpdated"`
- Value string `json:"val"`
- Description string `json:"description"`
-}
diff --git a/lib/go-tc/profiles.go b/lib/go-tc/profiles.go
index bfe689b..23b8362 100644
--- a/lib/go-tc/profiles.go
+++ b/lib/go-tc/profiles.go
@@ -90,11 +90,6 @@ type ProfileCopyResponse struct {
Alerts
}
-// ProfileTrimmed ...
-type ProfileTrimmed struct {
- Name string `json:"name"`
-}
-
// ProfileExportImportNullable is an object of the form used by Traffic Ops
// to represent exported and imported profiles.
type ProfileExportImportNullable struct {
diff --git a/lib/go-tc/servers.go b/lib/go-tc/servers.go
index e97d35d..dbf48d3 100644
--- a/lib/go-tc/servers.go
+++ b/lib/go-tc/servers.go
@@ -63,12 +63,6 @@ type ServersDetailResponse struct {
Alerts
}
-// ServersV1Response is a list of Servers for v1 as a response.
-type ServersV1Response struct {
- Response []ServerV1 `json:"response"`
- Alerts
-}
-
type ServerDetailV11 struct {
ServerDetail
LegacyInterfaceDetails
@@ -598,55 +592,6 @@ type Server struct {
XMPPPasswd string `json:"xmppPasswd"
db:"xmpp_passwd"`
}
-type ServerV1 struct {
- Cachegroup string `json:"cachegroup" db:"cachegroup"`
- CachegroupID int `json:"cachegroupId"
db:"cachegroup_id"`
- CDNID int `json:"cdnId" db:"cdn_id"`
- CDNName string `json:"cdnName" db:"cdn_name"`
- DeliveryServices map[string][]string `json:"deliveryServices,omitempty"`
- DomainName string `json:"domainName"
db:"domain_name"`
- FQDN *string `json:"fqdn,omitempty"`
- FqdnTime time.Time `json:"-"`
- GUID string `json:"guid" db:"guid"`
- HostName string `json:"hostName" db:"host_name"`
- HTTPSPort int `json:"httpsPort" db:"https_port"`
- ID int `json:"id" db:"id"`
- ILOIPAddress string `json:"iloIpAddress"
db:"ilo_ip_address"`
- ILOIPGateway string `json:"iloIpGateway"
db:"ilo_ip_gateway"`
- ILOIPNetmask string `json:"iloIpNetmask"
db:"ilo_ip_netmask"`
- ILOPassword string `json:"iloPassword"
db:"ilo_password"`
- ILOUsername string `json:"iloUsername"
db:"ilo_username"`
- InterfaceMtu int `json:"interfaceMtu"
db:"interface_mtu"`
- InterfaceName string `json:"interfaceName"
db:"interface_name"`
- IP6Address string `json:"ip6Address"
db:"ip6_address"`
- IP6Gateway string `json:"ip6Gateway"
db:"ip6_gateway"`
- IPAddress string `json:"ipAddress" db:"ip_address"`
- IPGateway string `json:"ipGateway" db:"ip_gateway"`
- IPNetmask string `json:"ipNetmask" db:"ip_netmask"`
- LastUpdated TimeNoMod `json:"lastUpdated"
db:"last_updated"`
- MgmtIPAddress string `json:"mgmtIpAddress"
db:"mgmt_ip_address"`
- MgmtIPGateway string `json:"mgmtIpGateway"
db:"mgmt_ip_gateway"`
- MgmtIPNetmask string `json:"mgmtIpNetmask"
db:"mgmt_ip_netmask"`
- OfflineReason string `json:"offlineReason"
db:"offline_reason"`
- PhysLocation string `json:"physLocation"
db:"phys_location"`
- PhysLocationID int `json:"physLocationId"
db:"phys_location_id"`
- Profile string `json:"profile" db:"profile"`
- ProfileDesc string `json:"profileDesc"
db:"profile_desc"`
- ProfileID int `json:"profileId" db:"profile_id"`
- Rack string `json:"rack" db:"rack"`
- RevalPending bool `json:"revalPending"
db:"reval_pending"`
- RouterHostName string `json:"routerHostName"
db:"router_host_name"`
- RouterPortName string `json:"routerPortName"
db:"router_port_name"`
- Status string `json:"status" db:"status"`
- StatusID int `json:"statusId" db:"status_id"`
- TCPPort int `json:"tcpPort" db:"tcp_port"`
- Type string `json:"type" db:"server_type"`
- TypeID int `json:"typeId" db:"server_type_id"`
- UpdPending bool `json:"updPending"
db:"upd_pending"`
- XMPPID string `json:"xmppId" db:"xmpp_id"`
- XMPPPasswd string `json:"xmppPasswd"
db:"xmpp_passwd"`
-}
-
// CommonServerProperties is just the collection of properties which are
// shared by all servers across API versions.
type CommonServerProperties struct {
@@ -773,61 +718,6 @@ func (s Server) ToNullable() ServerNullableV2 {
}
}
-func (s ServerV1) ToNullable() ServerNullableV11 {
- return ServerNullableV11{
- CommonServerProperties: CommonServerProperties{
- Cachegroup: &s.Cachegroup,
- CachegroupID: &s.CachegroupID,
- CDNID: &s.CDNID,
- CDNName: &s.CDNName,
- DeliveryServices: &s.DeliveryServices,
- DomainName: &s.DomainName,
- FQDN: s.FQDN,
- FqdnTime: s.FqdnTime,
- GUID: &s.GUID,
- HostName: &s.HostName,
- HTTPSPort: &s.HTTPSPort,
- ID: &s.ID,
- ILOIPAddress: &s.ILOIPAddress,
- ILOIPGateway: &s.ILOIPGateway,
- ILOIPNetmask: &s.ILOIPNetmask,
- ILOPassword: &s.ILOPassword,
- ILOUsername: &s.ILOUsername,
- LastUpdated: &s.LastUpdated,
- MgmtIPAddress: &s.MgmtIPAddress,
- MgmtIPGateway: &s.MgmtIPGateway,
- MgmtIPNetmask: &s.MgmtIPNetmask,
- OfflineReason: &s.OfflineReason,
- PhysLocation: &s.PhysLocation,
- PhysLocationID: &s.PhysLocationID,
- Profile: &s.Profile,
- ProfileDesc: &s.ProfileDesc,
- ProfileID: &s.ProfileID,
- Rack: &s.Rack,
- RevalPending: &s.RevalPending,
- Status: &s.Status,
- StatusID: &s.StatusID,
- TCPPort: &s.TCPPort,
- Type: s.Type,
- TypeID: &s.TypeID,
- UpdPending: &s.UpdPending,
- XMPPID: &s.XMPPID,
- XMPPPasswd: &s.XMPPPasswd,
- },
- LegacyInterfaceDetails: LegacyInterfaceDetails{
- InterfaceMtu: &s.InterfaceMtu,
- InterfaceName: &s.InterfaceName,
- IPAddress: &s.IPAddress,
- IPGateway: &s.IPGateway,
- IPNetmask: &s.IPNetmask,
- IP6Address: &s.IP6Address,
- IP6Gateway: &s.IP6Gateway,
- },
- RouterHostName: &s.RouterHostName,
- RouterPortName: &s.RouterPortName,
- }
-}
-
func coerceBool(b *bool) bool {
if b == nil {
return false
diff --git a/lib/go-tc/stats_summary.go b/lib/go-tc/stats_summary.go
index 6f3231b..d2bcf6a 100644
--- a/lib/go-tc/stats_summary.go
+++ b/lib/go-tc/stats_summary.go
@@ -153,13 +153,6 @@ func (ss *StatsSummaryLastUpdated) UnmarshalJSON(data
[]byte) error {
return nil
}
-type LastUpdated struct {
- Version string `json:"version"`
- Response struct {
- SummaryTime string `json:"summaryTime"`
- } `json:"response"`
-}
-
type StatsSummaryLastUpdatedResponse struct {
Version string `json:"version"`
Response StatsSummaryLastUpdated `json:"response"`
diff --git a/lib/go-tc/traffic_stats.go b/lib/go-tc/traffic_stats.go
index d91f1f0..05e8a67 100644
--- a/lib/go-tc/traffic_stats.go
+++ b/lib/go-tc/traffic_stats.go
@@ -33,14 +33,6 @@ import (
influx "github.com/influxdata/influxdb/client/v2"
)
-// TRAFFIC_STATS_VERSION was supposed to be the "API version", but actually
the plugin (this route
-// used to be a plugin in Perl) always returned this static value
-const TRAFFIC_STATS_VERSION = "1.2"
-
-// TRAFFIC_STATS_SOURCE is the value of the "source" field in an API response.
Perl always returned
-// source="TrafficStats", so we do too
-const TRAFFIC_STATS_SOURCE = "TrafficStats"
-
// TrafficStatsDurationPattern reflects all the possible durations that can be
requested via the
// deliveryservice_stats endpoint
var TrafficStatsDurationPattern = regexp.MustCompile(`^\d+[mhdw]$`)
diff --git a/lib/go-tc/users.go b/lib/go-tc/users.go
index 1bf0388..12d16ad 100644
--- a/lib/go-tc/users.go
+++ b/lib/go-tc/users.go
@@ -29,47 +29,22 @@ import (
"github.com/apache/trafficcontrol/lib/go-rfc"
"github.com/apache/trafficcontrol/lib/go-util"
- "github.com/go-ozzo/ozzo-validation"
+ validation "github.com/go-ozzo/ozzo-validation"
"github.com/go-ozzo/ozzo-validation/is"
)
-// UserCredentials contains Traffic Ops login credentials
+// UserCredentials contains Traffic Ops login credentials.
type UserCredentials struct {
Username string `json:"u"`
Password string `json:"p"`
}
-// UserToken represents a request payload containing a UUID token for
authentication
+// UserToken represents a request payload containing a UUID token for
+// authentication.
type UserToken struct {
Token string `json:"t"`
}
-// UserV13 contains non-nullable TO user information
-type UserV13 struct {
- Username string `json:"username"`
- PublicSSHKey string `json:"publicSshKey"`
- Role int `json:"role"`
- RoleName string `json:"rolename"`
- ID int `json:"id"`
- UID int `json:"uid"`
- GID int `json:"gid"`
- Company string `json:"company"`
- Email string `json:"email"`
- FullName string `json:"fullName"`
- NewUser bool `json:"newUser"`
- LastUpdated string `json:"lastUpdated"`
- AddressLine1 string `json:"addressLine1"`
- AddressLine2 string `json:"addressLine2"`
- City string `json:"city"`
- Country string `json:"country"`
- PhoneNumber string `json:"phoneNumber"`
- PostalCode string `json:"postalCode"`
- RegistrationSent TimeNoMod `json:"registrationSent"`
- StateOrProvince string `json:"stateOrProvince"`
- Tenant string `json:"tenant"`
- TenantID int `json:"tenantId"`
-}
-
// commonUserFields is unexported, but its contents are still visible when it
is embedded
// LastUpdated is a new field for some structs
type commonUserFields struct {
@@ -297,13 +272,6 @@ func (u *CurrentUserUpdateRequestUser)
UnmarshalAndValidate(user *User) error {
// The client's use of these will eventually be deprecated //
// --------------------------------------------------------- //
-// UsersResponseV13 is the Traffic Ops API version 1.3 variant of UserResponse.
-// It is unused.
-type UsersResponseV13 struct {
- Response []UserV13 `json:"response"`
- Alerts
-}
-
// UsersResponse can hold a Traffic Ops API response to a request to get a
list of users.
type UsersResponse struct {
Response []User `json:"response"`
diff --git a/traffic_ops/traffic_ops_golang/crconfig/handler.go
b/traffic_ops/traffic_ops_golang/crconfig/handler.go
index 712ec69..6b7a435 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/handler.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/handler.go
@@ -136,28 +136,6 @@ func SnapshotGetMonitoringHandler(w http.ResponseWriter, r
*http.Request) {
api.WriteAndLogErr(w, r, []byte(`{"response":`+snapshot+`}`))
}
-// SnapshotOldGetHandler gets and serves the CRConfig from the snapshot table,
not wrapped in response to match the old non-API CRConfig-Snapshots endpoint
-func SnapshotOldGetHandler(w http.ResponseWriter, r *http.Request) {
- inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"cdn"}, nil)
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
- return
- }
- defer inf.Close()
-
- snapshot, cdnExists, err := GetSnapshot(inf.Tx.Tx, inf.Params["cdn"])
- if err != nil {
- api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, errors.New("getting snapshot: "+err.Error()))
- return
- }
- if !cdnExists {
- api.HandleErr(w, r, inf.Tx.Tx, http.StatusNotFound,
errors.New("CDN not found"), nil)
- return
- }
- w.Header().Set(rfc.ContentType, rfc.ApplicationJSON)
- api.WriteAndLogErr(w, r, []byte(snapshot))
-}
-
// SnapshotHandler creates the CRConfig JSON and writes it to the snapshot
table in the database.
func SnapshotHandler(w http.ResponseWriter, r *http.Request) {
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, []string{"id",
"cdnID"})
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
b/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
index ea3b08e..c7b7d8f 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
@@ -283,18 +283,6 @@ func updateSSLKeyVersion(xmlID string, version int64, tx
*sql.Tx) error {
return nil
}
-// returns the cdn_id found by domainname.
-func getCDNIDByDomainname(domainName string, tx *sql.Tx) (int64, bool, error) {
- cdnID := int64(0)
- if err := tx.QueryRow(`SELECT id from cdn WHERE domain_name = $1`,
domainName).Scan(&cdnID); err != nil {
- if err == sql.ErrNoRows {
- return 0, false, nil
- }
- return 0, false, err
- }
- return cdnID, true, nil
-}
-
// getDSIDFromName loads the DeliveryService's ID from the database, from the
xml_id. Returns whether the delivery service was found, and any error.
func getDSIDFromName(tx *sql.Tx, xmlID string) (int, bool, error) {
id := 0
diff --git a/traffic_ops/traffic_ops_golang/monitoring/monitoring.go
b/traffic_ops/traffic_ops_golang/monitoring/monitoring.go
index d118218..27f5bb5 100644
--- a/traffic_ops/traffic_ops_golang/monitoring/monitoring.go
+++ b/traffic_ops/traffic_ops_golang/monitoring/monitoring.go
@@ -24,15 +24,12 @@ package monitoring
import (
"database/sql"
"fmt"
- "net/http"
"strconv"
"strings"
"github.com/apache/trafficcontrol/lib/go-log"
"github.com/apache/trafficcontrol/lib/go-tc"
- "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
-
"github.com/lib/pq"
)
@@ -135,16 +132,6 @@ type DeliveryService struct {
TotalKBPSThreshold float64 `json:"totalKbpsThreshold"`
}
-func Get(w http.ResponseWriter, r *http.Request) {
- inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"cdn"}, nil)
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
- return
- }
- defer inf.Close()
- api.RespWriter(w, r, inf.Tx.Tx)(GetMonitoringJSON(inf.Tx.Tx,
inf.Params["cdn"]))
-}
-
func GetMonitoringJSON(tx *sql.Tx, cdnName string) (*Monitoring, error) {
monitors, caches, routers, err := getMonitoringServers(tx, cdnName)
if err != nil {
diff --git a/traffic_ops/traffic_ops_golang/region/name.go
b/traffic_ops/traffic_ops_golang/region/name.go
deleted file mode 100644
index c7f8109..0000000
--- a/traffic_ops/traffic_ops_golang/region/name.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package region
-
-/*
- * 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 (
- "database/sql"
- "errors"
- "net/http"
-
- "github.com/apache/trafficcontrol/lib/go-tc"
- "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
-)
-
-func GetName(w http.ResponseWriter, r *http.Request) {
- inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"name"}, nil)
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
- return
- }
- defer inf.Close()
- regionNames, err := getName(inf.Tx.Tx, inf.Params["name"])
-
- deprecationMessage := "GET /regions?name={{name}}"
- alerts := api.CreateDeprecationAlerts(&deprecationMessage)
- if err != nil {
- alerts.AddNewAlert(tc.ErrorLevel, err.Error())
- api.WriteAlerts(w, r, http.StatusInternalServerError, alerts)
- return
- }
- api.WriteAlertsObj(w, r, http.StatusOK, alerts, regionNames)
-}
-
-// getName returns a slice, even though only 1 region will ever be returned,
because that's what the 1.x API responds with.
-func getName(tx *sql.Tx, name string) ([]tc.RegionName, error) {
- r := tc.RegionName{Name: name}
- err := tx.QueryRow(`SELECT r.id, d.id, d.name FROM region as r JOIN
division as d ON r.division = d.id WHERE r.name = $1`, name).Scan(&r.ID,
&r.Division.ID, &r.Division.Name)
- if err != nil {
- if err == sql.ErrNoRows {
- return []tc.RegionName{}, nil
- }
- return nil, errors.New("querying region by name: " +
err.Error())
- }
- return []tc.RegionName{r}, nil
-}
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go
b/traffic_ops/traffic_ops_golang/routing/routes.go
index e7ca739..9ae855b 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -1359,13 +1359,6 @@ func rootHandler(d ServerData) http.Handler {
return root{}
}
-// notImplementedHandler returns a 501 Not Implemented to the client. This
should be used very rarely, and primarily for old API Perl routes which were
broken long ago, which we don't have the resources to rewrite in Go for the
time being.
-func notImplementedHandler(w http.ResponseWriter, r *http.Request) {
- code := http.StatusNotImplemented
- w.WriteHeader(code)
- api.WriteAndLogErr(w, r, []byte(http.StatusText(code)))
-}
-
//CreateThrottledHandler takes a handler, and a max and uses a channel to
insure the handler is used concurrently by only max number of routines
func CreateThrottledHandler(handler http.Handler, maxConcurrentCalls int)
ThrottledHandler {
return ThrottledHandler{handler, make(chan struct{},
maxConcurrentCalls)}