github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/serverwide/operations/operation_get_cluster_topology.go (about)

     1  package operations
     2  
     3  import (
     4  	"encoding/json"
     5  	"github.com/ravendb/ravendb-go-client"
     6  	"net/http"
     7  )
     8  
     9  type OperationGetClusterTopology struct {
    10  	Topology           ravendb.ClusterTopology
    11  	Etag               int    `json:"Etag"`
    12  	Leader             string `json:"Leader"`
    13  	LeaderShipDuration int    `json:"LeaderShipDuration"`
    14  	CurrentState       string `json:"CurrentState"`
    15  	NodeTag            string `json:"NodeTag"`
    16  	CurrentTerm        int    `json:"CurrentTerm"`
    17  	NodeLicenseDetails struct {
    18  		UtilizedCores       int         `json:"UtilizedCores"`
    19  		MaxUtilizedCores    interface{} `json:"MaxUtilizedCores"`
    20  		NumberOfCores       int         `json:"NumberOfCores"`
    21  		InstalledMemoryInGb float64     `json:"InstalledMemoryInGb"`
    22  		UsableMemoryInGb    float64     `json:"UsableMemoryInGb"`
    23  		BuildInfo           struct {
    24  			ProductVersion string `json:"ProductVersion"`
    25  			BuildVersion   int    `json:"BuildVersion"`
    26  			CommitHash     string `json:"CommitHash"`
    27  			FullVersion    string `json:"FullVersion"`
    28  		} `json:"BuildInfo"`
    29  		OsInfo struct {
    30  			Type         string `json:"Type"`
    31  			FullName     string `json:"FullName"`
    32  			Version      string `json:"Version"`
    33  			BuildVersion string `json:"BuildVersion"`
    34  			Is64Bit      bool   `json:"Is64Bit"`
    35  		} `json:"OsInfo"`
    36  	}
    37  	LastStateChangeReason string   `json:"LastStateChangeReason"`
    38  	Status                struct{} `json:"Status"`
    39  }
    40  
    41  func (operation *OperationGetClusterTopology) GetCommand(conventions *ravendb.DocumentConventions) (ravendb.RavenCommand, error) {
    42  	return &getClusterTopology{
    43  		RavenCommandBase: ravendb.RavenCommandBase{
    44  			ResponseType: ravendb.RavenCommandResponseTypeObject,
    45  		},
    46  		parent: operation,
    47  	}, nil
    48  }
    49  
    50  type getClusterTopology struct {
    51  	ravendb.RavenCommandBase
    52  	parent *OperationGetClusterTopology
    53  }
    54  
    55  func (c *getClusterTopology) CreateRequest(node *ravendb.ServerNode) (*http.Request, error) {
    56  	url := node.URL + "/cluster/topology"
    57  	return http.NewRequest(http.MethodGet, url, nil)
    58  }
    59  func (c *getClusterTopology) SetResponse(response []byte, fromCache bool) error {
    60  	return json.Unmarshal(response, c.parent)
    61  }