dangogh closed pull request #2689: Update Traffic Monitor to use TO Client v13
URL: https://github.com/apache/trafficcontrol/pull/2689
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 123734cce..b5022aebe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - Cachegroup-Coordinate Refactor: The Cachegroup API now creates/updates a 
Coordinate entity on Cachegroup creates/updates, and the `latitude` and 
`longitude` columns in the `cachegroup` table have been replaced with 
`coordinate` (a foreign key to Coordinate). Coordinates created from 
Cachegroups are given the name `from_cachegroup_\<cachegroup name\>`.
 - Geolocation-based Client Steering: two new steering target types are 
available to use for `CLIENT_STEERING` delivery services: `STEERING_GEO_ORDER` 
and `STEERING_GEO_WEIGHT`. When targets of these types have an Origin with a 
Coordinate, Traffic Router will order and prioritize them based upon the 
shortest total distance from client -> edge -> origin. Co-located targets are 
grouped together and can be weighted or ordered within the same location using 
`STEERING_GEO_WEIGHT` or `STEERING_GEO_ORDER`, respectively.
 - Tenancy is now the default behavior in Traffic Ops.  All database entries 
that reference a tenant now have a default of the root tenant.  This eliminates 
the need for the `use_tenancy` global parameter and will allow for code to be 
simplified as a result. If all user and delivery services reference the root 
tenant, then there will be no difference from having `use_tenancy` set to 0.
+- Traffic Monitor Client Update: Traffic Monitor is updated to use the Traffic 
Ops v13 client.
 
 ## [2.2.0] - 2018-06-07
 ### Added
diff --git a/traffic_monitor/manager/opsconfig.go 
b/traffic_monitor/manager/opsconfig.go
index 80578c64a..4674c6ce2 100644
--- a/traffic_monitor/manager/opsconfig.go
+++ b/traffic_monitor/manager/opsconfig.go
@@ -37,7 +37,7 @@ import (
        "github.com/apache/trafficcontrol/traffic_monitor/threadsafe"
        "github.com/apache/trafficcontrol/traffic_monitor/todata"
        "github.com/apache/trafficcontrol/traffic_monitor/towrap"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 // StartOpsConfigManager starts the ops config manager goroutine, returning 
the (threadsafe) variables which it sets.
@@ -178,7 +178,7 @@ func StartOpsConfigManager(
 // getMonitorCDN returns the CDN of a given Traffic Monitor.
 // TODO change to get by name, when Traffic Ops supports querying a single 
server.
 func getMonitorCDN(toc *to.Session, monitorHostname string) (string, error) {
-       servers, err := toc.Servers()
+       servers, _, err := toc.GetServers()
        if err != nil {
                return "", fmt.Errorf("getting monitor %s CDN: %v", 
monitorHostname, err)
        }
diff --git a/traffic_monitor/tmcheck/dsstats.go 
b/traffic_monitor/tmcheck/dsstats.go
index 8241f695e..b914f361f 100644
--- a/traffic_monitor/tmcheck/dsstats.go
+++ b/traffic_monitor/tmcheck/dsstats.go
@@ -26,7 +26,7 @@ import (
 
        "github.com/apache/trafficcontrol/lib/go-tc"
        "github.com/apache/trafficcontrol/traffic_monitor/dsdata"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 // ValidateDSStates validates that all Delivery Services in the CRConfig exist 
in given Traffic Monitor's DSStats.
@@ -41,7 +41,7 @@ func ValidateDSStats(tmURI string, toClient *to.Session) 
error {
 
 // ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves 
an additional query if the Traffic Monitor's CDN is known.
 func ValidateDSStatsWithCDN(tmURI string, tmCDN string, toClient *to.Session) 
error {
-       crConfigBytes, err := toClient.CRConfigRaw(tmCDN)
+       crConfigBytes, _, err := toClient.GetCRConfig(tmCDN)
        if err != nil {
                return fmt.Errorf("getting CRConfig: %v", err)
        }
diff --git a/traffic_monitor/tmcheck/offlinestates.go 
b/traffic_monitor/tmcheck/offlinestates.go
index c1f1ae855..95a1ed92f 100644
--- a/traffic_monitor/tmcheck/offlinestates.go
+++ b/traffic_monitor/tmcheck/offlinestates.go
@@ -25,7 +25,7 @@ import (
        "time"
 
        "github.com/apache/trafficcontrol/lib/go-tc"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 // ValidateOfflineStates validates that no OFFLINE or ADMIN_DOWN caches in the 
given Traffic Ops' CRConfig are marked Available in the given Traffic Monitor's 
CRStates.
@@ -39,7 +39,7 @@ func ValidateOfflineStates(tmURI string, toClient 
*to.Session) error {
 
 // ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves 
an additional query if the Traffic Monitor's CDN is known.
 func ValidateOfflineStatesWithCDN(tmURI string, tmCDN string, toClient 
*to.Session) error {
-       crConfigBytes, err := toClient.CRConfigRaw(tmCDN)
+       crConfigBytes, _, err := toClient.GetCRConfig(tmCDN)
        if err != nil {
                return fmt.Errorf("getting CRConfig: %v", err)
        }
diff --git a/traffic_monitor/tmcheck/peerpoller.go 
b/traffic_monitor/tmcheck/peerpoller.go
index 5cad707d0..54927d420 100644
--- a/traffic_monitor/tmcheck/peerpoller.go
+++ b/traffic_monitor/tmcheck/peerpoller.go
@@ -22,7 +22,7 @@ package tmcheck
 import (
        "fmt"
        "github.com/apache/trafficcontrol/lib/go-tc"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
        "time"
 )
 
diff --git a/traffic_monitor/tmcheck/queryinterval.go 
b/traffic_monitor/tmcheck/queryinterval.go
index bdcf678e9..f2c06cafa 100644
--- a/traffic_monitor/tmcheck/queryinterval.go
+++ b/traffic_monitor/tmcheck/queryinterval.go
@@ -24,7 +24,7 @@ import (
        "time"
 
        "github.com/apache/trafficcontrol/lib/go-tc"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const QueryIntervalMax = time.Duration(10) * time.Second
diff --git a/traffic_monitor/tmcheck/tmcheck.go 
b/traffic_monitor/tmcheck/tmcheck.go
index 45c02d2ce..d703651d3 100644
--- a/traffic_monitor/tmcheck/tmcheck.go
+++ b/traffic_monitor/tmcheck/tmcheck.go
@@ -29,9 +29,10 @@ import (
        "time"
 
        "github.com/apache/trafficcontrol/lib/go-tc"
+       "github.com/apache/trafficcontrol/lib/go-tc/v13"
        "github.com/apache/trafficcontrol/traffic_monitor/datareq"
        "github.com/apache/trafficcontrol/traffic_monitor/dsdata"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const RequestTimeout = time.Second * time.Duration(30)
@@ -194,10 +195,10 @@ type CRConfigOrError struct {
        Err      error
 }
 
-func GetMonitors(toClient *to.Session, includeOffline bool) ([]tc.Server, 
error) {
+func GetMonitors(toClient *to.Session, includeOffline bool) ([]v13.Server, 
error) {
        trafficMonitorType := "RASCAL"
        monitorTypeQuery := map[string][]string{"type": 
[]string{trafficMonitorType}}
-       servers, err := toClient.ServersByType(monitorTypeQuery)
+       servers, _, err := toClient.GetServersByType(monitorTypeQuery)
        if err != nil {
                return nil, fmt.Errorf("getting monitors from Traffic Ops: %v", 
err)
        }
@@ -260,8 +261,8 @@ func AllValidator(
 }
 
 // FilterOfflines returns only servers which are REPORTED or ONLINE
-func FilterOfflines(servers []tc.Server) []tc.Server {
-       onlineServers := []tc.Server{}
+func FilterOfflines(servers []v13.Server) []v13.Server {
+       onlineServers := []v13.Server{}
        for _, server := range servers {
                status := tc.CacheStatusFromString(server.Status)
                if status != tc.CacheStatusOnline && status != 
tc.CacheStatusReported {
@@ -272,7 +273,7 @@ func FilterOfflines(servers []tc.Server) []tc.Server {
        return onlineServers
 }
 
-func GetCDNs(servers []tc.Server) map[tc.CDNName]struct{} {
+func GetCDNs(servers []v13.Server) map[tc.CDNName]struct{} {
        cdns := map[tc.CDNName]struct{}{}
        for _, server := range servers {
                cdns[tc.CDNName(server.CDNName)] = struct{}{}
@@ -283,7 +284,7 @@ func GetCDNs(servers []tc.Server) map[tc.CDNName]struct{} {
 func GetCRConfigs(cdns map[tc.CDNName]struct{}, toClient *to.Session) 
map[tc.CDNName]CRConfigOrError {
        crConfigs := map[tc.CDNName]CRConfigOrError{}
        for cdn, _ := range cdns {
-               crConfigBytes, err := toClient.CRConfigRaw(string(cdn))
+               crConfigBytes, _, err := toClient.GetCRConfig(string(cdn))
                if err != nil {
                        crConfigs[cdn] = CRConfigOrError{Err: 
fmt.Errorf("getting CRConfig: %v", err)}
                        continue
diff --git 
a/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
 
b/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
index 5d61aa824..164cd1fa0 100644
--- 
a/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
+++ 
b/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
@@ -25,7 +25,7 @@ import (
 
        "github.com/apache/trafficcontrol/lib/go-nagios"
        "github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const UserAgent = "tm-offline-validator/0.1"
diff --git 
a/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go 
b/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
index afe1cbe5b..a4fd2becc 100644
--- a/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
+++ b/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
@@ -25,7 +25,7 @@ import (
 
        "github.com/apache/trafficcontrol/lib/go-nagios"
        "github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const UserAgent = "tm-offline-validator/0.1"
diff --git 
a/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
 
b/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
index c52e946a8..4a6716464 100644
--- 
a/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
+++ 
b/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
@@ -24,7 +24,7 @@ import (
        "fmt"
        "github.com/apache/trafficcontrol/lib/go-nagios"
        "github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const UserAgent = "tm-peerpoller-validator/0.1"
diff --git 
a/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
 
b/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
index 90bf3ecc4..178a885af 100644
--- 
a/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
+++ 
b/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
@@ -24,7 +24,7 @@ import (
        "fmt"
        "github.com/apache/trafficcontrol/lib/go-nagios"
        "github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 const UserAgent = "tm-queryinterval-validator/0.1"
diff --git a/traffic_monitor/tools/validator-service/validator-service.go 
b/traffic_monitor/tools/validator-service/validator-service.go
index 584f20025..a20f8492a 100644
--- a/traffic_monitor/tools/validator-service/validator-service.go
+++ b/traffic_monitor/tools/validator-service/validator-service.go
@@ -26,7 +26,7 @@ import (
        "fmt"
        "github.com/apache/trafficcontrol/lib/go-tc"
        "github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
-       to "github.com/apache/trafficcontrol/traffic_ops/client"
+       to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
        "io"
        "net/http"
        "sort"
diff --git a/traffic_monitor/towrap/towrap.go b/traffic_monitor/towrap/towrap.go
index c93fc5096..e047f4f88 100644
--- a/traffic_monitor/towrap/towrap.go
+++ b/traffic_monitor/towrap/towrap.go
@@ -30,7 +30,7 @@ import (
        "github.com/apache/trafficcontrol/lib/go-log"
        "github.com/apache/trafficcontrol/lib/go-tc"
        "github.com/apache/trafficcontrol/lib/go-tc/v13"
-       "github.com/apache/trafficcontrol/traffic_ops/client"
+       client "github.com/apache/trafficcontrol/traffic_ops/client/v13"
 )
 
 // ITrafficOpsSession provides an interface to the Traffic Ops client, so it 
may be wrapped or mocked.
@@ -41,11 +41,11 @@ type ITrafficOpsSession interface {
        Set(session *client.Session)
        URL() (string, error)
        User() (string, error)
-       Servers() ([]tc.Server, error)
-       Profiles() ([]tc.Profile, error)
+       Servers() ([]v13.Server, error)
+       Profiles() ([]v13.Profile, error)
        Parameters(profileName string) ([]tc.Parameter, error)
-       DeliveryServices() ([]tc.DeliveryService, error)
-       CacheGroups() ([]v13.CacheGroup, error)
+       DeliveryServices() ([]tc.DeliveryServiceV13, error)
+       CacheGroups() ([]v13.CacheGroupNullable, error)
        CRConfigHistory() []CRConfigStat
 }
 
@@ -267,7 +267,8 @@ func (s TrafficOpsSessionThreadsafe) 
trafficMonitorConfigMapRaw(cdn string) (*tc
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.TrafficMonitorConfigMap(cdn)
+       configMap, _, error := ss.GetTrafficMonitorConfigMap(cdn)
+       return configMap, error
 }
 
 // TrafficMonitorConfigMap returns the Traffic Monitor config map from the 
Traffic Ops. This is safe for multiple goroutines.
@@ -418,20 +419,22 @@ func CreateMonitorConfig(crConfig tc.CRConfig, mc 
*tc.TrafficMonitorConfigMap) (
        return mc, nil
 }
 
-func (s TrafficOpsSessionThreadsafe) Servers() ([]tc.Server, error) {
+func (s TrafficOpsSessionThreadsafe) Servers() ([]v13.Server, error) {
        ss := s.get()
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.Servers()
+       servers, _, error := ss.GetServers()
+       return servers, error
 }
 
-func (s TrafficOpsSessionThreadsafe) Profiles() ([]tc.Profile, error) {
+func (s TrafficOpsSessionThreadsafe) Profiles() ([]v13.Profile, error) {
        ss := s.get()
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.Profiles()
+       profiles, _, error := ss.GetProfiles()
+       return profiles, error
 }
 
 func (s TrafficOpsSessionThreadsafe) Parameters(profileName string) 
([]tc.Parameter, error) {
@@ -439,21 +442,24 @@ func (s TrafficOpsSessionThreadsafe) 
Parameters(profileName string) ([]tc.Parame
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.Parameters(profileName)
+       parameters, _, error := ss.GetParametersByProfileName(profileName)
+       return parameters, error
 }
 
-func (s TrafficOpsSessionThreadsafe) DeliveryServices() ([]tc.DeliveryService, 
error) {
+func (s TrafficOpsSessionThreadsafe) DeliveryServices() 
([]tc.DeliveryServiceV13, error) {
        ss := s.get()
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.DeliveryServices()
+       deliveryServices, _, error := ss.GetDeliveryServices()
+       return deliveryServices, error
 }
 
-func (s TrafficOpsSessionThreadsafe) CacheGroups() ([]v13.CacheGroup, error) {
+func (s TrafficOpsSessionThreadsafe) CacheGroups() ([]v13.CacheGroupNullable, 
error) {
        ss := s.get()
        if ss == nil {
                return nil, ErrNilSession
        }
-       return ss.CacheGroups()
+       cacheGroups, _, error := ss.GetCacheGroupsNullable()
+       return cacheGroups, error
 }
diff --git a/traffic_ops/client/v13/crconfig.go 
b/traffic_ops/client/v13/crconfig.go
new file mode 100644
index 000000000..ef8356a01
--- /dev/null
+++ b/traffic_ops/client/v13/crconfig.go
@@ -0,0 +1,24 @@
+/*
+
+   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 v13
+
+import "fmt"
+
+// GetCRConfig returns the raw JSON bytes of the CRConfig from Traffic Ops, 
and whether the bytes were from the client's internal cache.
+func (to *Session) GetCRConfig(cdn string) ([]byte, ReqInf, error) {
+       url := fmt.Sprintf("/CRConfig-Snapshots/%s/CRConfig.json", cdn)
+       return to.getBytesWithTTL(url, tmPollingInterval)
+}
diff --git a/traffic_ops/client/v13/parameter.go 
b/traffic_ops/client/v13/parameter.go
index ec760763c..34e94ab12 100644
--- a/traffic_ops/client/v13/parameter.go
+++ b/traffic_ops/client/v13/parameter.go
@@ -82,6 +82,23 @@ func (to *Session) GetParameters() ([]tc.Parameter, ReqInf, 
error) {
        return data.Response, reqInf, nil
 }
 
+func (to *Session) GetParametersByProfileName(profileName string) 
([]tc.Parameter, ReqInf, error) {
+       url := fmt.Sprintf(API_v13_Parameters + "/profile/%s.json", profileName)
+       resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data tc.ParametersResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return data.Response, reqInf, nil
+}
+
 // GET a Parameter by the Parameter ID
 func (to *Session) GetParameterByID(id int) ([]tc.Parameter, ReqInf, error) {
        route := fmt.Sprintf("%s/%d", API_v13_Parameters, id)
diff --git a/traffic_ops/client/v13/server.go b/traffic_ops/client/v13/server.go
index 89864f011..74b0f5a89 100644
--- a/traffic_ops/client/v13/server.go
+++ b/traffic_ops/client/v13/server.go
@@ -23,6 +23,7 @@ import (
 
        "github.com/apache/trafficcontrol/lib/go-tc"
        "github.com/apache/trafficcontrol/lib/go-tc/v13"
+       "net/url"
 )
 
 const (
@@ -131,3 +132,20 @@ func (to *Session) DeleteServerByID(id int) (tc.Alerts, 
ReqInf, error) {
        err = json.NewDecoder(resp.Body).Decode(&alerts)
        return alerts, reqInf, nil
 }
+
+func (to *Session) GetServersByType(qparams url.Values) ([]v13.Server, ReqInf, 
error) {
+       url := fmt.Sprintf("%s.json?%s", API_v13_Servers, qparams.Encode())
+       resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data v13.ServersResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return data.Response, reqInf, nil
+}
diff --git a/traffic_ops/client/v13/session.go 
b/traffic_ops/client/v13/session.go
index c409ac040..7634941fe 100644
--- a/traffic_ops/client/v13/session.go
+++ b/traffic_ops/client/v13/session.go
@@ -114,7 +114,7 @@ func (to *Session) login() (net.Addr, error) {
                return nil, errors.New("creating login credentials: " + 
err.Error())
        }
 
-       path := "/api/1.2/user/login"
+       path := apiBase + "/user/login"
        resp, remoteAddr, err := to.rawRequest("POST", path, credentials)
        resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
        if err != nil {
@@ -149,7 +149,7 @@ func (to *Session) logout() (net.Addr, error) {
                return nil, errors.New("creating login credentials: " + 
err.Error())
        }
 
-       path := "/api/1.2/user/logout"
+       path := apiBase + "/user/logout"
        resp, remoteAddr, err := to.rawRequest("POST", path, credentials)
        resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
        if err != nil {
diff --git a/traffic_ops/client/v13/traffic_monitor.go 
b/traffic_ops/client/v13/traffic_monitor.go
new file mode 100644
index 000000000..dc97a44e6
--- /dev/null
+++ b/traffic_ops/client/v13/traffic_monitor.go
@@ -0,0 +1,55 @@
+package v13
+
+import (
+       "encoding/json"
+       "fmt"
+       "github.com/apache/trafficcontrol/lib/go-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.
+ */
+
+func (to *Session) GetTrafficMonitorConfigMap(cdn string) 
(*tc.TrafficMonitorConfigMap, ReqInf, error) {
+       tmConfig, reqInf, err := to.GetTrafficMonitorConfig(cdn)
+       if err != nil {
+               return nil, reqInf, err
+       }
+       tmConfigMap, err := tc.TrafficMonitorTransformToMap(tmConfig)
+       if err != nil {
+               return nil, reqInf, err
+       }
+       return tmConfigMap, reqInf, nil
+}
+
+func (to *Session) GetTrafficMonitorConfig(cdn string) 
(*tc.TrafficMonitorConfig, ReqInf, error) {
+       url := fmt.Sprintf("/api/1.3/cdns/%s/configs/monitoring.json", cdn)
+       resp, remoteAddr, err := to.request("GET", url, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data tc.TMConfigResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return &data.Response, reqInf, nil
+}
diff --git a/traffic_ops/client/v13/user.go b/traffic_ops/client/v13/user.go
index 01024988a..33095242e 100644
--- a/traffic_ops/client/v13/user.go
+++ b/traffic_ops/client/v13/user.go
@@ -29,7 +29,7 @@ func (to *Session) Users() ([]tc.User, error) {
 }
 
 func (to *Session) GetUsers() ([]tc.User, ReqInf, error) {
-       url := "/api/1.2/users.json"
+       url := apiBase + "/users.json"
        resp, remoteAddr, err := to.request("GET", url, nil)
        reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
        if err != nil {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to