github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/resetstate/requests.go (about)

     1  package resetstate
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  // ServerState refers to the states usable in ResetState Action
     8  type ServerState string
     9  
    10  const (
    11  	// StateActive returns the state of the server as active
    12  	StateActive ServerState = "active"
    13  
    14  	// StateError returns the state of the server as error
    15  	StateError ServerState = "error"
    16  )
    17  
    18  // ResetState will reset the state of a server
    19  func ResetState(client *golangsdk.ServiceClient, id string, state ServerState) (r ResetResult) {
    20  	stateMap := map[string]interface{}{"state": state}
    21  	_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-resetState": stateMap}, nil, nil)
    22  	return
    23  }