@@ -15,9 +15,9 @@ import (
1515
1616const (
1717 // 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"
2121)
2222
2323type FileSpec struct {
@@ -41,7 +41,7 @@ func NewManager(client *rest.Client) *Manager {
4141// Returns a task identifier and an error
4242// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
4343func (c * Manager ) EnableClusterConfiguration (clusterId string ) (string , error ) {
44- path := c .getBaseTransitionUrl (clusterId , "enable" )
44+ path := c .getUrlWithActionAndTask (clusterId , "enable" )
4545 req := path .Request (http .MethodPost , nil )
4646 var res string
4747 return res , c .Do (context .Background (), req , & res )
@@ -51,7 +51,7 @@ func (c *Manager) EnableClusterConfiguration(clusterId string) (string, error) {
5151// Returns a task identifier and an error
5252// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
5353func (c * Manager ) ImportFromReferenceHost (clusterId , hostId string ) (string , error ) {
54- path := c .getBaseTransitionUrl (clusterId , "importFromHost" )
54+ path := c .getUrlWithActionAndTask (clusterId , "importFromHost" )
5555 req := path .Request (http .MethodPost , hostId )
5656 var res string
5757 return res , c .Do (context .Background (), req , & res )
@@ -61,7 +61,7 @@ func (c *Manager) ImportFromReferenceHost(clusterId, hostId string) (string, err
6161// Returns a task identifier and an error
6262// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
6363func (c * Manager ) ImportFromFile (clusterId string , spec FileSpec ) (string , error ) {
64- path := c .getBaseTransitionUrl (clusterId , "importFromFile" )
64+ path := c .getUrlWithActionAndTask (clusterId , "importFromFile" )
6565 req := path .Request (http .MethodPost , spec )
6666 var res string
6767 return res , c .Do (context .Background (), req , & res )
@@ -71,7 +71,7 @@ func (c *Manager) ImportFromFile(clusterId string, spec FileSpec) (string, error
7171// Returns a task identifier and an error
7272// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
7373func (c * Manager ) ValidateConfiguration (clusterId string ) (string , error ) {
74- path := c .getBaseTransitionUrl (clusterId , "validateConfig" )
74+ path := c .getUrlWithActionAndTask (clusterId , "validateConfig" )
7575 req := path .Request (http .MethodPost , nil )
7676 var res string
7777 return res , c .Do (context .Background (), req , & res )
@@ -81,7 +81,7 @@ func (c *Manager) ValidateConfiguration(clusterId string) (string, error) {
8181// Returns a task identifier and an error
8282// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
8383func (c * Manager ) CheckEligibility (clusterId string ) (string , error ) {
84- path := c .getBaseTransitionUrl (clusterId , "checkEligibility" )
84+ path := c .getUrlWithActionAndTask (clusterId , "checkEligibility" )
8585 req := path .Request (http .MethodPost , nil )
8686 var res string
8787 return res , c .Do (context .Background (), req , & res )
@@ -91,7 +91,7 @@ func (c *Manager) CheckEligibility(clusterId string) (string, error) {
9191// Returns a task identifier and an error
9292// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
9393func (c * Manager ) RunPrecheck (clusterId string ) (string , error ) {
94- path := c .getBaseTransitionUrl (clusterId , "precheck" )
94+ path := c .getUrlWithActionAndTask (clusterId , "precheck" )
9595 req := path .Request (http .MethodPost , nil )
9696 var res string
9797 return res , c .Do (context .Background (), req , & res )
@@ -101,7 +101,7 @@ func (c *Manager) RunPrecheck(clusterId string) (string, error) {
101101// Returns a task identifier and an error
102102// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
103103func (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" )
105105 req := path .Request (http .MethodPost , nil )
106106 var res string
107107 return res , c .Do (context .Background (), req , & res )
@@ -111,12 +111,12 @@ func (c *Manager) Cancel(clusterId string) (string, error) {
111111// Returns the config status and an error
112112// https://developer.broadcom.com/xapis/vsphere-automation-api/latest/api/esx/settings/clusters/cluster/enablement/configuration/transition
113113func (c * Manager ) GetClusterConfigurationStatus (clusterId string ) (string , error ) {
114- path := c .Resource (fmt .Sprintf (Transition , clusterId ))
114+ path := c .Resource (fmt .Sprintf (TransitionPath , clusterId ))
115115 req := path .Request (http .MethodGet )
116116 var res string
117117 return res , c .Do (context .Background (), req , & res )
118118}
119119
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" )
122122}
0 commit comments