forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_sample_data_operation.go
50 lines (39 loc) · 1.38 KB
/
create_sample_data_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
package ravendb
import (
"net/http"
)
// Note: this is only used for tests but a RavenCommand cannot be implemented outside
// of ravendb package
var (
_ IVoidMaintenanceOperation = &CreateSampleDataOperation{}
)
// CreateSampleDataOperation represents operation to create sample data
type CreateSampleDataOperation struct {
Command *CreateSampleDataCommand
}
// NewCreateSampleDataOperation
func NewCreateSampleDataOperation() *CreateSampleDataOperation {
return &CreateSampleDataOperation{}
}
// GetCommand returns a comman
func (o *CreateSampleDataOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) {
o.Command = NewCreateSampleDataCommand(conventions)
return o.Command, nil
}
var _ RavenCommand = &CreateSampleDataCommand{}
// CreateSampleDataCommand represents command for creating sample data
type CreateSampleDataCommand struct {
RavenCommandBase
}
// NewCreateSampleDataCommand returns new CreateSampleDataCommand
func NewCreateSampleDataCommand(conventions *DocumentConventions) *CreateSampleDataCommand {
cmd := &CreateSampleDataCommand{
RavenCommandBase: NewRavenCommandBase(),
}
cmd.RavenCommandBase.ResponseType = RavenCommandResponseTypeEmpty
return cmd
}
func (c *CreateSampleDataCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/studio/sample-data"
return NewHttpPost(url, nil)
}