@@ -15,9 +15,9 @@ import (
15
15
16
16
const (
17
17
// BasePath The base endpoint for the clusters enablement configuration API
18
- BasePath = settings .BasePath + "/%s/enablement"
19
- Configuration = BasePath + "/configuration"
20
- Transition = Configuration + "/transition"
18
+ BasePath = settings .BasePath + "/%s/enablement"
19
+ ConfigurationPath = BasePath + "/configuration"
20
+ TransitionPath = ConfigurationPath + "/transition"
21
21
)
22
22
23
23
type FileSpec struct {
@@ -41,7 +41,7 @@ func NewManager(client *rest.Client) *Manager {
41
41
// Returns a task identifier and an error
42
42
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
43
43
func (c * Manager ) EnableClusterConfiguration (clusterId string ) (string , error ) {
44
- path := c .getBaseTransitionUrl (clusterId , "enable" )
44
+ path := c .getUrlWithActionAndTask (clusterId , "enable" )
45
45
req := path .Request (http .MethodPost , nil )
46
46
var res string
47
47
return res , c .Do (context .Background (), req , & res )
@@ -51,7 +51,7 @@ func (c *Manager) EnableClusterConfiguration(clusterId string) (string, error) {
51
51
// Returns a task identifier and an error
52
52
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
53
53
func (c * Manager ) ImportFromReferenceHost (clusterId , hostId string ) (string , error ) {
54
- path := c .getBaseTransitionUrl (clusterId , "importFromHost" )
54
+ path := c .getUrlWithActionAndTask (clusterId , "importFromHost" )
55
55
req := path .Request (http .MethodPost , hostId )
56
56
var res string
57
57
return res , c .Do (context .Background (), req , & res )
@@ -61,7 +61,7 @@ func (c *Manager) ImportFromReferenceHost(clusterId, hostId string) (string, err
61
61
// Returns a task identifier and an error
62
62
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
63
63
func (c * Manager ) ImportFromFile (clusterId string , spec FileSpec ) (string , error ) {
64
- path := c .getBaseTransitionUrl (clusterId , "importFromFile" )
64
+ path := c .getUrlWithActionAndTask (clusterId , "importFromFile" )
65
65
req := path .Request (http .MethodPost , spec )
66
66
var res string
67
67
return res , c .Do (context .Background (), req , & res )
@@ -71,7 +71,7 @@ func (c *Manager) ImportFromFile(clusterId string, spec FileSpec) (string, error
71
71
// Returns a task identifier and an error
72
72
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
73
73
func (c * Manager ) ValidateConfiguration (clusterId string ) (string , error ) {
74
- path := c .getBaseTransitionUrl (clusterId , "validateConfig" )
74
+ path := c .getUrlWithActionAndTask (clusterId , "validateConfig" )
75
75
req := path .Request (http .MethodPost , nil )
76
76
var res string
77
77
return res , c .Do (context .Background (), req , & res )
@@ -81,7 +81,7 @@ func (c *Manager) ValidateConfiguration(clusterId string) (string, error) {
81
81
// Returns a task identifier and an error
82
82
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
83
83
func (c * Manager ) CheckEligibility (clusterId string ) (string , error ) {
84
- path := c .getBaseTransitionUrl (clusterId , "checkEligibility" )
84
+ path := c .getUrlWithActionAndTask (clusterId , "checkEligibility" )
85
85
req := path .Request (http .MethodPost , nil )
86
86
var res string
87
87
return res , c .Do (context .Background (), req , & res )
@@ -91,7 +91,7 @@ func (c *Manager) CheckEligibility(clusterId string) (string, error) {
91
91
// Returns a task identifier and an error
92
92
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
93
93
func (c * Manager ) RunPrecheck (clusterId string ) (string , error ) {
94
- path := c .getBaseTransitionUrl (clusterId , "precheck" )
94
+ path := c .getUrlWithActionAndTask (clusterId , "precheck" )
95
95
req := path .Request (http .MethodPost , nil )
96
96
var res string
97
97
return res , c .Do (context .Background (), req , & res )
@@ -101,7 +101,7 @@ func (c *Manager) RunPrecheck(clusterId string) (string, error) {
101
101
// Returns a task identifier and an error
102
102
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
103
103
func (c * Manager ) Cancel (clusterId string ) (string , error ) {
104
- path := c .Resource (fmt .Sprintf (Transition , clusterId )).WithParam ("action" , "cancel" )
104
+ path := c .Resource (fmt .Sprintf (TransitionPath , clusterId )).WithParam ("action" , "cancel" )
105
105
req := path .Request (http .MethodPost , nil )
106
106
var res string
107
107
return res , c .Do (context .Background (), req , & res )
@@ -111,12 +111,12 @@ func (c *Manager) Cancel(clusterId string) (string, error) {
111
111
// Returns the config status and an error
112
112
// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
113
113
func (c * Manager ) GetClusterConfigurationStatus (clusterId string ) (string , error ) {
114
- path := c .Resource (fmt .Sprintf (Transition , clusterId ))
114
+ path := c .Resource (fmt .Sprintf (TransitionPath , clusterId ))
115
115
req := path .Request (http .MethodGet )
116
116
var res string
117
117
return res , c .Do (context .Background (), req , & res )
118
118
}
119
119
120
- func (c * Manager ) getBaseTransitionUrl (clusterId , action string ) * rest.Resource {
121
- return c .Resource (fmt .Sprintf (Transition , clusterId )).WithParam ("action" , action ).WithParam ("vmw-task" , "true" )
120
+ func (c * Manager ) getUrlWithActionAndTask (clusterId , action string ) * rest.Resource {
121
+ return c .Resource (fmt .Sprintf (TransitionPath , clusterId )).WithParam ("action" , action ).WithParam ("vmw-task" , "true" )
122
122
}
0 commit comments