forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_operation_state_operation.go
47 lines (35 loc) · 1.06 KB
/
get_operation_state_operation.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
45
46
47
package ravendb
import (
"net/http"
)
type GetOperationStateOperation struct {
id int64
}
func (o *GetOperationStateOperation) GetCommand(conventions *DocumentConventions) *GetOperationStateCommand {
return NewGetOperationStateCommand(getDefaultConventions(), o.id)
}
type GetOperationStateCommand struct {
RavenCommandBase
conventions *DocumentConventions
id int64
Result map[string]interface{}
}
func NewGetOperationStateCommand(conventions *DocumentConventions, id int64) *GetOperationStateCommand {
cmd := &GetOperationStateCommand{
RavenCommandBase: NewRavenCommandBase(),
conventions: conventions,
id: id,
}
cmd.IsReadRequest = true
return cmd
}
func (c *GetOperationStateCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/operations/state?id=" + i64toa(c.id)
return newHttpGet(url)
}
func (c *GetOperationStateCommand) SetResponse(response []byte, fromCache bool) error {
if len(response) == 0 {
return nil
}
return jsonUnmarshal(response, &c.Result)
}