github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/put_client_configuration_operation.go (about) 1 package ravendb 2 3 import ( 4 "net/http" 5 ) 6 7 var _ IVoidMaintenanceOperation = &PutClientConfigurationOperation{} 8 9 type PutClientConfigurationOperation struct { 10 configuration *ClientConfiguration 11 Command *PutClientConfigurationCommand 12 } 13 14 func NewPutClientConfigurationOperation(configuration *ClientConfiguration) (*PutClientConfigurationOperation, error) { 15 if configuration == nil { 16 return nil, newIllegalArgumentError("Configuration cannot be null") 17 } 18 19 return &PutClientConfigurationOperation{ 20 configuration: configuration, 21 }, nil 22 } 23 24 func (o *PutClientConfigurationOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) { 25 var err error 26 o.Command, err = NewPutClientConfigurationCommand(conventions, o.configuration) 27 if err != nil { 28 return nil, err 29 } 30 return o.Command, nil 31 } 32 33 var ( 34 _ RavenCommand = &PutClientConfigurationCommand{} 35 ) 36 37 type PutClientConfigurationCommand struct { 38 RavenCommandBase 39 40 configuration []byte 41 } 42 43 func NewPutClientConfigurationCommand(conventions *DocumentConventions, configuration *ClientConfiguration) (*PutClientConfigurationCommand, error) { 44 if conventions == nil { 45 return nil, newIllegalArgumentError("conventions cannot be null") 46 } 47 if configuration == nil { 48 return nil, newIllegalArgumentError("configuration cannot be null") 49 } 50 51 d, err := jsonMarshal(configuration) 52 if err != nil { 53 return nil, err 54 } 55 cmd := &PutClientConfigurationCommand{ 56 RavenCommandBase: NewRavenCommandBase(), 57 58 configuration: d, 59 } 60 cmd.ResponseType = RavenCommandResponseTypeEmpty 61 return cmd, nil 62 } 63 64 func (c *PutClientConfigurationCommand) CreateRequest(node *ServerNode) (*http.Request, error) { 65 url := node.URL + "/databases/" + node.Database + "/admin/configuration/client" 66 return newHttpPut(url, c.configuration) 67 }