github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/get_next_operation_id_command.go (about) 1 package ravendb 2 3 import ( 4 "net/http" 5 ) 6 7 var ( 8 _ RavenCommand = &GetNextOperationIDCommand{} 9 ) 10 11 type _GetNextOperationIDCommandResponse struct { 12 ID int64 `json:"Id"` 13 } 14 15 // GetNextOperationIDCommand represents command for getting next 16 // id from the server 17 type GetNextOperationIDCommand struct { 18 RavenCommandBase 19 20 Result int64 21 } 22 23 // NewGetNextOperationIDCommand returns GetNextOperationIDCommand 24 func NewGetNextOperationIDCommand() *GetNextOperationIDCommand { 25 cmd := &GetNextOperationIDCommand{ 26 RavenCommandBase: NewRavenCommandBase(), 27 } 28 return cmd 29 } 30 31 func (c *GetNextOperationIDCommand) CreateRequest(node *ServerNode) (*http.Request, error) { 32 url := node.URL + "/databases/" + node.Database + "/operations/next-operation-id" 33 return newHttpGet(url) 34 } 35 36 func (c *GetNextOperationIDCommand) SetResponse(response []byte, fromCache bool) error { 37 var res _GetNextOperationIDCommandResponse 38 err := jsonUnmarshal(response, &res) 39 if err != nil { 40 return err 41 } 42 c.Result = res.ID 43 return nil 44 }