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

     1  package ravendb
     2  
     3  import (
     4  	"net/http"
     5  )
     6  
     7  var _ IMaintenanceOperation = &GetIndexingStatusOperation{}
     8  
     9  type GetIndexingStatusOperation struct {
    10  	Command *GetIndexingStatusCommand
    11  }
    12  
    13  func NewGetIndexingStatusOperation() *GetIndexingStatusOperation {
    14  	return &GetIndexingStatusOperation{}
    15  }
    16  
    17  func (o *GetIndexingStatusOperation) GetCommand(conventions *DocumentConventions) (RavenCommand, error) {
    18  	o.Command = NewGetIndexingStatusCommand()
    19  	return o.Command, nil
    20  }
    21  
    22  var (
    23  	_ RavenCommand = &GetIndexingStatusCommand{}
    24  )
    25  
    26  type GetIndexingStatusCommand struct {
    27  	RavenCommandBase
    28  
    29  	Result *IndexingStatus
    30  }
    31  
    32  func NewGetIndexingStatusCommand() *GetIndexingStatusCommand {
    33  	res := &GetIndexingStatusCommand{
    34  		RavenCommandBase: NewRavenCommandBase(),
    35  	}
    36  	res.IsReadRequest = true
    37  	return res
    38  }
    39  
    40  func (c *GetIndexingStatusCommand) createRequest(node *ServerNode) (*http.Request, error) {
    41  	url := node.URL + "/databases/" + node.Database + "/indexes/status"
    42  
    43  	return newHttpGet(url)
    44  }
    45  
    46  func (c *GetIndexingStatusCommand) setResponse(response []byte, fromCache bool) error {
    47  	if response == nil {
    48  		return throwInvalidResponse()
    49  	}
    50  
    51  	return jsonUnmarshal(response, &c.Result)
    52  }