forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_revisions_operation.go
68 lines (53 loc) · 1.93 KB
/
configure_revisions_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ravendb
import (
"net/http"
)
var (
_ IMaintenanceOperation = &ConfigureRevisionsOperation{}
)
// ConfigureRevisionsOperation represents configure revisions operation
type ConfigureRevisionsOperation struct {
configuration *RevisionsConfiguration
Command *ConfigureRevisionsCommand
}
// NewConfigureRevisionsOperation returns new ConfigureRevisionsOperation
func NewConfigureRevisionsOperation(configuration *RevisionsConfiguration) *ConfigureRevisionsOperation {
return &ConfigureRevisionsOperation{
configuration: configuration,
}
}
// GetCommand returns new RavenCommand for this operation
func (o *ConfigureRevisionsOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) {
o.Command = NewConfigureRevisionsCommand(o.configuration)
return o.Command, nil
}
var _ RavenCommand = &ConfigureRevisionsCommand{}
// ConfigureRevisionsCommand represents configure revisions command
type ConfigureRevisionsCommand struct {
RavenCommandBase
configuration *RevisionsConfiguration
Result *ConfigureRevisionsOperationResult
}
// NewConfigureRevisionsCommand returns new ConfigureRevisionsCommand
func NewConfigureRevisionsCommand(configuration *RevisionsConfiguration) *ConfigureRevisionsCommand {
cmd := &ConfigureRevisionsCommand{
RavenCommandBase: NewRavenCommandBase(),
configuration: configuration,
}
return cmd
}
func (c *ConfigureRevisionsCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/admin/revisions/config"
d, err := jsonMarshal(c.configuration)
if err != nil {
return nil, err
}
return NewHttpPost(url, d)
}
func (c *ConfigureRevisionsCommand) SetResponse(response []byte, fromCache bool) error {
return jsonUnmarshal(response, &c.Result)
}
// ConfigureRevisionsOperationResult represents result of configure revisions operation
type ConfigureRevisionsOperationResult struct {
RaftCommandIndex int64 `json:"RaftCommandIndex"`
}