-
Notifications
You must be signed in to change notification settings - Fork 20
/
account_service.go
136 lines (119 loc) · 4.66 KB
/
account_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*******************************************************************************
* IBM Confidential
* OCO Source Materials
* IBM Cloud Container Service, 5737-D43
* (C) Copyright IBM Corp. 2018 All Rights Reserved.
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with
* the U.S. Copyright Office.
******************************************************************************/
package backend
import (
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
)
// AccountService is a wrapping interface for the softlayer-go API's AccountService
//go:generate counterfeiter -o fakes/account_service.go --fake-name AccountService . AccountService
type AccountService interface {
Filter(string) AccountService
Mask(string) AccountService
ID(int) AccountService
Limit(int) AccountService
Offset(int) AccountService
GetBlockDeviceTemplateGroups() ([]datatypes.Virtual_Guest_Block_Device_Template_Group, error)
GetCurrentUser() (datatypes.User_Customer, error)
GetHardware() ([]datatypes.Hardware, error)
GetObject() (datatypes.Account, error)
GetOrders() ([]datatypes.Billing_Order, error)
GetSubnets() ([]datatypes.Network_Subnet, error)
GetNetworkStorage() (resp []datatypes.Network_Storage, err error)
}
// AccountServiceSL is a softlayer implementation of the AccountService interface.
// All functions pass directly to the equivalent SL function
type AccountServiceSL struct {
accountService services.Account
}
// ID pass-through for AccountService.Id
func (as *AccountServiceSL) ID(id int) AccountService {
return &AccountServiceSL{accountService: as.accountService.Id(id)}
}
// Mask pass-through for AccountService.Mask
func (as *AccountServiceSL) Mask(mask string) AccountService {
return &AccountServiceSL{accountService: as.accountService.Mask(mask)}
}
// Filter pass-through for AccountService.Filter
func (as *AccountServiceSL) Filter(filter string) AccountService {
return &AccountServiceSL{accountService: as.accountService.Filter(filter)}
}
// Limit pass-through for AccountService.Limit
func (as *AccountServiceSL) Limit(limit int) AccountService {
return &AccountServiceSL{accountService: as.accountService.Limit(limit)}
}
// Offset pass-through for AccountService.Offset
func (as *AccountServiceSL) Offset(offset int) AccountService {
return &AccountServiceSL{accountService: as.accountService.Offset(offset)}
}
// GetBlockDeviceTemplateGroups pass-through for AccountService.GetBlockDeviceTemplateGroups
func (as *AccountServiceSL) GetBlockDeviceTemplateGroups() ([]datatypes.Virtual_Guest_Block_Device_Template_Group, error) {
return as.accountService.GetBlockDeviceTemplateGroups()
}
// GetCurrentUser pass-through for AccountService.GetCurrentUser
func (as *AccountServiceSL) GetCurrentUser() (datatypes.User_Customer, error) {
var usrCustomer datatypes.User_Customer
var usrError error
usrError = retry(func() error {
usrCustomer, usrError = as.accountService.GetCurrentUser()
return usrError
})
return usrCustomer, usrError
//return as.accountService.GetCurrentUser()
}
// GetHardware pass-through for AccountService.GetHardware
func (as *AccountServiceSL) GetHardware() ([]datatypes.Hardware, error) {
var hrdWare []datatypes.Hardware
var hrdError error
hrdError = retry(func() error {
hrdWare, hrdError = as.accountService.GetHardware()
return hrdError
})
return hrdWare, hrdError
}
// GetObject pass-through for AccountService.GetObject
func (as *AccountServiceSL) GetObject() (datatypes.Account, error) {
var actInfo datatypes.Account
var actError error
actError = retry(func() error {
actInfo, actError = as.accountService.GetObject()
return actError
})
return actInfo, actError
}
//GetOrders pass-through for AccountService.GetOrders
func (as *AccountServiceSL) GetOrders() ([]datatypes.Billing_Order, error) {
var blOrder []datatypes.Billing_Order
var blError error
blError = retry(func() error {
blOrder, blError = as.accountService.GetOrders()
return blError
})
return blOrder, blError
}
// GetSubnets pass-through for AccountService.GetSubnets
func (as *AccountServiceSL) GetSubnets() ([]datatypes.Network_Subnet, error) {
var ntwSubnet []datatypes.Network_Subnet
var subError error
subError = retry(func() error {
ntwSubnet, subError = as.accountService.GetSubnets()
return subError
})
return ntwSubnet, subError
}
func (as *AccountServiceSL) GetNetworkStorage() (resp []datatypes.Network_Storage, err error) {
var ntwStorage []datatypes.Network_Storage
var stgError error
stgError = retry(func() error {
ntwStorage, stgError = as.accountService.GetNetworkStorage()
return stgError
})
return ntwStorage, stgError
}