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