github.com/altipla-consulting/ravendb-go-client@v0.1.3/stop_index_operation.go (about) 1 package ravendb 2 3 import ( 4 "net/http" 5 ) 6 7 var _ IVoidMaintenanceOperation = &StopIndexOperation{} 8 9 type StopIndexOperation struct { 10 indexName string 11 12 Command *StopIndexCommand 13 } 14 15 func NewStopIndexOperation(indexName string) (*StopIndexOperation, error) { 16 if indexName == "" { 17 return nil, newIllegalArgumentError("Index name connot be empty") 18 } 19 return &StopIndexOperation{ 20 indexName: indexName, 21 }, nil 22 } 23 24 func (o *StopIndexOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) { 25 var err error 26 o.Command, err = NewStopIndexCommand(o.indexName) 27 if err != nil { 28 return nil, err 29 } 30 return o.Command, nil 31 } 32 33 var ( 34 _ RavenCommand = &StopIndexCommand{} 35 ) 36 37 type StopIndexCommand struct { 38 RavenCommandBase 39 40 indexName string 41 } 42 43 func NewStopIndexCommand(indexName string) (*StopIndexCommand, error) { 44 if indexName == "" { 45 return nil, newIllegalArgumentError("Index name connot be empty") 46 } 47 48 cmd := &StopIndexCommand{ 49 RavenCommandBase: NewRavenCommandBase(), 50 51 indexName: indexName, 52 } 53 cmd.ResponseType = RavenCommandResponseTypeEmpty 54 return cmd, nil 55 } 56 57 func (c *StopIndexCommand) createRequest(node *ServerNode) (*http.Request, error) { 58 url := node.URL + "/databases/" + node.Database + "/admin/indexes/stop?name=" + urlUtilsEscapeDataString(c.indexName) 59 60 return newHttpPost(url, nil) 61 }