Skip to content

Commit

Permalink
refactor!: use int64 for all IDs
Browse files Browse the repository at this point in the history
Future-proof IDs by making them int64.
  • Loading branch information
raul-te committed Jul 13, 2022
1 parent d967c63 commit 9402af1
Show file tree
Hide file tree
Showing 36 changed files with 150 additions and 150 deletions.
4 changes: 2 additions & 2 deletions account_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ type AccountGroups []AccountGroup
// AccountGroup - An account within a ThousandEyes organization
type AccountGroup struct {
AccountGroupName *string `json:"accountGroupName,omitempty"`
AID *int `json:"aid,omitempty"`
AID *int64 `json:"aid,omitempty"`
}

// SharedWithAccount describes accounts with which a resource is shared.
// This is separate from the AccountGroup above only due to the difference
// in JSON object names.
type SharedWithAccount struct {
AccountGroupName *string `json:"name,omitempty"`
AID *int `json:"aid,omitempty"`
AID *int64 `json:"aid,omitempty"`
}

// GetAccountGroups - Get third party and webhook integrations
Expand Down
2 changes: 1 addition & 1 deletion account_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestClient_GetAccountGroups(t *testing.T) {
expected := []SharedWithAccount{
{
AccountGroupName: String("Test Account"),
AID: Int(1),
AID: Int64(1),
},
}

Expand Down
4 changes: 2 additions & 2 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Agents []Agent

// Agent - Agent struct
type Agent struct {
AgentID *int `json:"agentId,omitempty"`
AgentID *int64 `json:"agentId,omitempty"`
AgentName *string `json:"agentName,omitempty"`
AgentType *string `json:"agentType,omitempty"`
CountryID *string `json:"countryId,omitempty"`
Expand All @@ -35,7 +35,7 @@ type Agent struct {

//ClusterMember - ClusterMember struct
type ClusterMember struct {
MemberID *int `json:"memberId,omitempty"`
MemberID *int64 `json:"memberId,omitempty"`
Name *string `json:"name,omitempty"`
IPAddresses *[]string `json:"IPAddresses,omitempty"`
PublicIPAddresses *[]string `json:"PublicIPAddresses,omitempty"`
Expand Down
12 changes: 6 additions & 6 deletions agent_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type AgentAgent struct {
BGPMonitors *[]BGPMonitor `json:"bgpMonitors,omitempty"`
Direction *string `json:"direction,omitempty"`
DSCP *string `json:"dscp,omitempty"`
DSCPID *int `json:"dscpId"`
DSCPID *int64 `json:"dscpId"`
Interval *int `json:"interval,omitempty"`
MSS *int `json:"mss,omitempty"`
NetworkMeasurements *bool `json:"networkMeasurements,omitempty" te:"int-bool"`
Expand All @@ -40,7 +40,7 @@ type AgentAgent struct {
PathTraceMode *string `json:"pathTraceMode,omitempty"`
Port *int `json:"port,omitempty"`
Protocol *string `json:"protocol,omitempty"`
TargetAgentID *int `json:"targetAgentId,omitempty"`
TargetAgentID *int64 `json:"targetAgentId,omitempty"`
ThroughputDuration *int `json:"throughputDuration,omitempty"`
ThroughputMeasurements *bool `json:"throughputMeasurements,omitempty" te:"int-bool"`
ThroughputRate *int `json:"throughputRate,omitempty"`
Expand Down Expand Up @@ -77,14 +77,14 @@ func (t *AgentAgent) UnmarshalJSON(data []byte) error {
}

// AddAgent - Adds an agent to agent test
func (t *AgentAgent) AddAgent(id int) {
agent := Agent{AgentID: Int(id)}
func (t *AgentAgent) AddAgent(id int64) {
agent := Agent{AgentID: Int64(id)}
*t.Agents = append(*t.Agents, agent)
}

// AddAlertRule - Adds an alert to agent test
func (t *AgentAgent) AddAlertRule(id int) {
alertRule := AlertRule{RuleID: Int(id)}
func (t *AgentAgent) AddAlertRule(id int64) {
alertRule := AlertRule{RuleID: Int64(id)}
*t.AlertRules = append(*t.AlertRules, alertRule)
}

Expand Down
6 changes: 3 additions & 3 deletions agent_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (

func TestClient_AddAgentAgentAlertRule(t *testing.T) {
test := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}

func TestClient_AgentAgentAddAgent(t *testing.T) {
test := AgentAgent{TestName: String("test"), Agents: &[]Agent{}}
expected := AgentAgent{TestName: String("test"), Agents: &[]Agent{{AgentID: Int(1)}}}
expected := AgentAgent{TestName: String("test"), Agents: &[]Agent{{AgentID: Int64(1)}}}
test.AddAgent(1)
assert.Equal(t, expected, test)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestClient_GetAgentAgentJsonError(t *testing.T) {

func TestClient_AddAlertRule(t *testing.T) {
test := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := AgentAgent{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}
Expand Down
8 changes: 4 additions & 4 deletions agent_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ func extractPort(test AgentServer) (AgentServer, error) {
}

// AddAgent - Add agent to server test
func (t *AgentServer) AddAgent(id int) {
agent := Agent{AgentID: Int(id)}
func (t *AgentServer) AddAgent(id int64) {
agent := Agent{AgentID: Int64(id)}
*t.Agents = append(*t.Agents, agent)
}

// AddAlertRule - Adds an alert to agent test
func (t *AgentServer) AddAlertRule(id int) {
alertRule := AlertRule{RuleID: Int(id)}
func (t *AgentServer) AddAlertRule(id int64) {
alertRule := AlertRule{RuleID: Int64(id)}
*t.AlertRules = append(*t.AlertRules, alertRule)
}

Expand Down
8 changes: 4 additions & 4 deletions agent_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (

func TestClient_AddAgentSeverAlertRule(t *testing.T) {
test := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}

func TestClient_AgentServerAddAgent(t *testing.T) {
test := AgentServer{TestName: String("test"), Agents: &[]Agent{}}
expected := AgentServer{TestName: String("test"), Agents: &[]Agent{{AgentID: Int(1)}}}
expected := AgentServer{TestName: String("test"), Agents: &[]Agent{{AgentID: Int64(1)}}}
test.AddAgent(1)
assert.Equal(t, expected, test)
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestClient_CreateAgentServer(t *testing.T) {

func TestClient_AddAgentServerAlertRule(t *testing.T) {
test := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := AgentServer{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestExtractPort(t *testing.T) {
test := AgentServer{
Agents: &[]Agent{
{
AgentID: Int(75),
AgentID: Int64(75),
},
},
Interval: Int(3600),
Expand Down
14 changes: 7 additions & 7 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func TestClient_GetAgents(t *testing.T) {
// Define expected values from the API (based on the JSON we print out above)
expected := Agents{
Agent{
AgentID: Int(1),
AgentID: Int64(1),
Enabled: Bool(true),
},
Agent{
AgentID: Int(2),
AgentID: Int64(2),
Enabled: Bool(false),
},
}
Expand All @@ -41,7 +41,7 @@ func TestClient_GetAgent(t *testing.T) {
assert.Equal(t, "GET", r.Method)
_, _ = w.Write([]byte(out))
})
expected := Agent{AgentID: Int(1), Enabled: Bool(true)}
expected := Agent{AgentID: Int64(1), Enabled: Bool(true)}
res, err := client.GetAgent(1)
teardown()
assert.Nil(t, err)
Expand Down Expand Up @@ -184,11 +184,11 @@ func TestClient_RemoveAgentFromCluster(t *testing.T) {
res, _ := client.RemoveAgentsFromCluster(1, []int{8001})
exp := []Agent{
{
AgentID: Int(1),
AgentID: Int64(1),
AgentName: String("test"),
ClusterMembers: &[]ClusterMember{
{
MemberID: Int(80002),
MemberID: Int64(80002),
Name: String("test"),
},
},
Expand All @@ -208,11 +208,11 @@ func TestClient_AddAgentToCluster(t *testing.T) {
res, _ := client.AddAgentsToCluster(1, []int{8002})
exp := []Agent{
{
AgentID: Int(1),
AgentID: Int64(1),
AgentName: String("test"),
ClusterMembers: &[]ClusterMember{
{
MemberID: Int(80002),
MemberID: Int64(80002),
Name: String("test"),
},
},
Expand Down
6 changes: 3 additions & 3 deletions alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestClient_GetAlertRule(t *testing.T) {

// Define expected values from the API (based on the JSON we print out above)
expected := AlertRules{
AlertRule{RuleID: Int(1), RuleName: String("test")},
AlertRule{RuleID: Int64(1), RuleName: String("test")},
}

res, err := client.GetAlertRules()
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestClient_UpdateAlertRule(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expected := AlertRule{RuleID: Int(1), RuleName: String("test"), RoundsViolatingOutOf: Int(2), RoundsViolatingRequired: Int(1)}
expected := AlertRule{RuleID: Int64(1), RuleName: String("test"), RoundsViolatingOutOf: Int(2), RoundsViolatingRequired: Int(1)}
assert.Equal(t, &expected, res)
}

Expand All @@ -91,7 +91,7 @@ func TestClient_CreateAlertRule(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expected := AlertRule{RuleID: Int(1), RuleName: String("test"), RoundsViolatingOutOf: Int(2), RoundsViolatingRequired: Int(1)}
expected := AlertRule{RuleID: Int64(1), RuleName: String("test"), RoundsViolatingOutOf: Int(2), RoundsViolatingRequired: Int(1)}
assert.Equal(t, &expected, res)
}

Expand Down
6 changes: 3 additions & 3 deletions alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Alerts []Alert

// Alert - An alert
type Alert struct {
AlertID *int `json:"alertId,omitempty"`
AlertID *int64 `json:"alertId,omitempty"`
TestID *int64 `json:"testId,omitempty"`
TestName *string `json:"testName,omitempty"`
Active *int `json:"active,omitempty"`
Expand Down Expand Up @@ -43,7 +43,7 @@ type Notification struct {

// AlertRule - An alert rule
type AlertRule struct {
AlertRuleID *int `json:"alertRuleId,omitempty"`
AlertRuleID *int64 `json:"alertRuleId,omitempty"`
AlertType *string `json:"alertType,omitempty"`
Default *bool `json:"default,omitempty" te:"int-bool"`
Direction *string `json:"direction,omitempty"`
Expand All @@ -55,7 +55,7 @@ type AlertRule struct {
RoundsViolatingMode *string `json:"roundsViolatingMode,omitempty"`
RoundsViolatingOutOf *int `json:"roundsViolatingOutOf,omitempty"`
RoundsViolatingRequired *int `json:"roundsViolatingRequired,omitempty"`
RuleID *int `json:"ruleId,omitempty"`
RuleID *int64 `json:"ruleId,omitempty"`
RuleName *string `json:"ruleName,omitempty"`
TestIds *[]int `json:"testIds,omitempty"`
Notifications *Notification `json:"notifications,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (t *BGP) UnmarshalJSON(data []byte) error {
}

// AddAlertRule - Adds an alert to agent test
func (t *BGP) AddAlertRule(id int) {
alertRule := AlertRule{RuleID: Int(id)}
func (t *BGP) AddAlertRule(id int64) {
alertRule := AlertRule{RuleID: Int64(id)}
*t.AlertRules = append(*t.AlertRules, alertRule)
}

Expand Down
2 changes: 1 addition & 1 deletion bgp_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type BGPMonitors []BGPMonitor

// BGPMonitor - BGPMonitor struct
type BGPMonitor struct {
MonitorID *int `json:"monitorId,omitempty"`
MonitorID *int64 `json:"monitorId,omitempty"`
IPAddress *string `json:"ipAddress,omitempty"`
Network *string `json:"network,omitempty"`
MonitorType *string `json:"monitorType,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion bgp_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestClient_GetBGPMonitors(t *testing.T) {

// Define expected values from the API (based on the JSON we print out above)
expected := BGPMonitors{
BGPMonitor{MonitorID: Int(1), MonitorName: String("test"), MonitorType: String("bgp"), IPAddress: String("1.2.3.4")},
BGPMonitor{MonitorID: Int64(1), MonitorName: String("test"), MonitorType: String("bgp"), IPAddress: String("1.2.3.4")},
}

res, err := client.GetBPGMonitors()
Expand Down
6 changes: 3 additions & 3 deletions bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestClient_AddBGPAlertRule(t *testing.T) {
test := BGP{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := BGP{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := BGP{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}
Expand Down Expand Up @@ -37,7 +37,7 @@ func TestClient_GetBGP(t *testing.T) {
Prefix: String("1.2.3.0/20"),
SharedWithAccounts: &[]SharedWithAccount{
{
AID: Int(176592),
AID: Int64(176592),
AccountGroupName: String("Cloudreach"),
},
},
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestClient_CreateBGP(t *testing.T) {
AlertsEnabled: Bool(true),
SharedWithAccounts: &[]SharedWithAccount{
{
AID: Int(176592),
AID: Int64(176592),
AccountGroupName: String("Cloudreach"),
},
},
Expand Down
8 changes: 4 additions & 4 deletions dns_dnssec.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func (t *DNSSec) UnmarshalJSON(data []byte) error {
}

// AddAgent - Add agent to DNSSec test
func (t *DNSSec) AddAgent(id int) {
agent := Agent{AgentID: Int(id)}
func (t *DNSSec) AddAgent(id int64) {
agent := Agent{AgentID: Int64(id)}
*t.Agents = append(*t.Agents, agent)
}

// AddAlertRule - Adds an alert to agent test
func (t *DNSSec) AddAlertRule(id int) {
alertRule := AlertRule{RuleID: Int(id)}
func (t *DNSSec) AddAlertRule(id int64) {
alertRule := AlertRule{RuleID: Int64(id)}
*t.AlertRules = append(*t.AlertRules, alertRule)
}

Expand Down
12 changes: 6 additions & 6 deletions dns_dnssec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestClient_GetDNSSec(t *testing.T) {
Domain: String("webex.com"),
Agents: &[]Agent{
{
AgentID: Int(48620),
AgentID: Int64(48620),
AgentType: String("Cloud"),
AgentName: String("Seattle, WA (Trial) - IPv6"),
CountryID: String("US"),
Expand All @@ -42,7 +42,7 @@ func TestClient_GetDNSSec(t *testing.T) {
},
SharedWithAccounts: &[]SharedWithAccount{
{
AID: Int(176592),
AID: Int64(176592),
AccountGroupName: String("Cloudreach"),
},
},
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestClient_CreateDNSSec(t *testing.T) {
Domain: String("webex.com"),
Agents: &[]Agent{
{
AgentID: Int(48620),
AgentID: Int64(48620),
AgentType: String("Cloud"),
AgentName: String("Seattle, WA (Trial) - IPv6"),
CountryID: String("US"),
Expand All @@ -125,7 +125,7 @@ func TestClient_CreateDNSSec(t *testing.T) {
},
SharedWithAccounts: &[]SharedWithAccount{
{
AID: Int(176592),
AID: Int64(176592),
AccountGroupName: String("Cloudreach"),
},
},
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestClient_DeleteDNSSec(t *testing.T) {

func TestClient_AddDNSSecAlertRule(t *testing.T) {
test := DNSSec{TestName: String("test"), AlertRules: &[]AlertRule{}}
expected := DNSSec{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int(1)}}}
expected := DNSSec{TestName: String("test"), AlertRules: &[]AlertRule{{RuleID: Int64(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}
Expand All @@ -209,7 +209,7 @@ func TestClient_UpdateDNSSec(t *testing.T) {

func TestDNSSec_AddAgent(t *testing.T) {
test := DNSSec{TestName: String("test"), Agents: &[]Agent{}}
expected := DNSSec{TestName: String("test"), Agents: &[]Agent{{AgentID: Int(1)}}}
expected := DNSSec{TestName: String("test"), Agents: &[]Agent{{AgentID: Int64(1)}}}
test.AddAgent(1)
assert.Equal(t, expected, test)
}
Expand Down
Loading

0 comments on commit 9402af1

Please sign in to comment.