github.com/altipla-consulting/ravendb-go-client@v0.1.3/get_client_configuration_operation.go (about)

     1  package ravendb
     2  
     3  import (
     4  	"net/http"
     5  )
     6  
     7  var (
     8  	// make sure GetClientConfigurationOperation implements IMaintenanceOperation
     9  	_ IMaintenanceOperation = &GetClientConfigurationOperation{}
    10  )
    11  
    12  type GetClientConfigurationOperation struct {
    13  	Command *GetClientConfigurationCommand
    14  }
    15  
    16  func NewGetClientConfigurationOperation() *GetClientConfigurationOperation {
    17  	return &GetClientConfigurationOperation{}
    18  }
    19  
    20  func (o *GetClientConfigurationOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) {
    21  	o.Command = NewGetClientConfigurationCommand()
    22  	return o.Command, nil
    23  }
    24  
    25  type GetClientConfigurationCommand struct {
    26  	RavenCommandBase
    27  
    28  	Result *GetClientConfigurationCommandResult
    29  }
    30  
    31  func NewGetClientConfigurationCommand() *GetClientConfigurationCommand {
    32  	cmd := &GetClientConfigurationCommand{
    33  		RavenCommandBase: NewRavenCommandBase(),
    34  	}
    35  	return cmd
    36  }
    37  
    38  func (c *GetClientConfigurationCommand) createRequest(node *ServerNode) (*http.Request, error) {
    39  
    40  	url := node.URL + "/databases/" + node.Database + "/configuration/client"
    41  
    42  	return newHttpGet(url)
    43  }
    44  
    45  func (c *GetClientConfigurationCommand) setResponse(response []byte, fromCache bool) error {
    46  	if len(response) == 0 {
    47  		return nil
    48  	}
    49  
    50  	return jsonUnmarshal(response, &c.Result)
    51  }
    52  
    53  type GetClientConfigurationCommandResult struct {
    54  	Etag          int64                `json:"Etag"`
    55  	Configuration *ClientConfiguration `json:"Configuration"`
    56  }