@@ -75,6 +75,12 @@ type LKEVersion struct {
7575 ID string `json:"id"`
7676}
7777
78+ // LKEClusterRegenerateOptions fields are those accepted by RegenerateLKECluster
79+ type LKEClusterRegenerateOptions struct {
80+ KubeConfig bool `json:"kubeconfig"`
81+ ServiceToken bool `json:"servicetoken"`
82+ }
83+
7884// UnmarshalJSON implements the json.Unmarshaler interface
7985func (i * LKECluster ) UnmarshalJSON (b []byte ) error {
8086 type Mask LKECluster
@@ -322,3 +328,26 @@ func (c *Client) RecycleLKEClusterNodes(ctx context.Context, clusterID int) erro
322328 _ , err := coupleAPIErrors (c .R (ctx ).Post (e ))
323329 return err
324330}
331+
332+ // RegenerateLKECluster regenerates the Kubeconfig file and/or the service account token for the specified LKE Cluster.
333+ func (c * Client ) RegenerateLKECluster (ctx context.Context , clusterID int , opts LKEClusterRegenerateOptions ) (* LKECluster , error ) {
334+ body , err := json .Marshal (opts )
335+ if err != nil {
336+ return nil , err
337+ }
338+
339+ e := fmt .Sprintf ("lke/clusters/%d/regenerate" , clusterID )
340+ req := c .R (ctx ).SetResult (& LKECluster {}).SetBody (string (body ))
341+ r , err := coupleAPIErrors (req .Post (e ))
342+ if err != nil {
343+ return nil , err
344+ }
345+ return r .Result ().(* LKECluster ), nil
346+ }
347+
348+ // DeleteLKEClusterServiceToken deletes and regenerate the service account token for a Cluster.
349+ func (c * Client ) DeleteLKEClusterServiceToken (ctx context.Context , clusterID int ) error {
350+ e := fmt .Sprintf ("lke/clusters/%d/servicetoken" , clusterID )
351+ _ , err := coupleAPIErrors (c .R (ctx ).Delete (e ))
352+ return err
353+ }
0 commit comments