github.com/altipla-consulting/ravendb-go-client@v0.1.3/create_sample_data_operation.go (about) 1 package ravendb 2 3 import ( 4 "net/http" 5 ) 6 7 // Note: this is only used for tests but a RavenCommand cannot be implemented outside 8 // of ravendb package 9 10 var ( 11 _ IVoidMaintenanceOperation = &CreateSampleDataOperation{} 12 ) 13 14 // CreateSampleDataOperation represents operation to create sample data 15 type CreateSampleDataOperation struct { 16 Command *CreateSampleDataCommand 17 } 18 19 // NewCreateSampleDataOperation 20 func NewCreateSampleDataOperation() *CreateSampleDataOperation { 21 return &CreateSampleDataOperation{} 22 } 23 24 // GetCommand returns a comman 25 func (o *CreateSampleDataOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) { 26 o.Command = NewCreateSampleDataCommand(conventions) 27 return o.Command, nil 28 } 29 30 var _ RavenCommand = &CreateSampleDataCommand{} 31 32 // CreateSampleDataCommand represents command for creating sample data 33 type CreateSampleDataCommand struct { 34 RavenCommandBase 35 } 36 37 // NewCreateSampleDataCommand returns new CreateSampleDataCommand 38 func NewCreateSampleDataCommand(conventions *DocumentConventions) *CreateSampleDataCommand { 39 cmd := &CreateSampleDataCommand{ 40 RavenCommandBase: NewRavenCommandBase(), 41 } 42 cmd.RavenCommandBase.ResponseType = RavenCommandResponseTypeEmpty 43 return cmd 44 } 45 46 func (c *CreateSampleDataCommand) createRequest(node *ServerNode) (*http.Request, error) { 47 url := node.URL + "/databases/" + node.Database + "/studio/sample-data" 48 49 return newHttpPost(url, nil) 50 }