mirror of
https://github.com/minio/minio.git
synced 2025-11-10 14:09:48 -05:00
admin: Add version to service Status API response (#3605)
Add server's version field to service status API:
"version":{
"version":"DEVELOPMENT.GOGET",
"commitID":"DEVELOPMENT.GOGET"
}
This commit is contained in:
committed by
Harshavardhana
parent
e1f64141a2
commit
d1d89116f1
@@ -74,9 +74,11 @@ Fetch service status, replies disk space used, backend type and total disks offl
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|`st.Total` | _int64_ | Total disk space. |
|
||||
|`st.Free` | _int64_ | Free disk space. |
|
||||
|`st.Backend`| _struct{}_ | Represents backend type embedded structure. |
|
||||
|`st.ServerVersion.Version` | _string_ | Server version. |
|
||||
|`st.ServerVersion.CommitID` | _string_ | Server commit id. |
|
||||
|`st.StorageInfo.Total` | _int64_ | Total disk space. |
|
||||
|`st.StorageInfo.Free` | _int64_ | Free disk space. |
|
||||
|`st.StorageInfo.Backend`| _struct{}_ | Represents backend type embedded structure. |
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|
||||
@@ -41,8 +41,8 @@ const (
|
||||
// Add your own backend.
|
||||
)
|
||||
|
||||
// ServiceStatusMetadata - represents total capacity of underlying storage.
|
||||
type ServiceStatusMetadata struct {
|
||||
// StorageInfo - represents total capacity of underlying storage.
|
||||
type StorageInfo struct {
|
||||
// Total disk space.
|
||||
Total int64
|
||||
// Free available disk space.
|
||||
@@ -60,10 +60,23 @@ type ServiceStatusMetadata struct {
|
||||
}
|
||||
}
|
||||
|
||||
// ServerVersion - server version
|
||||
type ServerVersion struct {
|
||||
Version string `json:"version"`
|
||||
CommitID string `json:"commitID"`
|
||||
}
|
||||
|
||||
// ServiceStatusMetadata - contains the response of service status API
|
||||
type ServiceStatusMetadata struct {
|
||||
StorageInfo StorageInfo `json:"storageInfo"`
|
||||
ServerVersion ServerVersion `json:"serverVersion"`
|
||||
}
|
||||
|
||||
// ServiceStatus - Connect to a minio server and call Service Status Management API
|
||||
// to fetch server's storage information represented by ServiceStatusMetadata structure
|
||||
func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) {
|
||||
|
||||
// Prepare web service request
|
||||
reqData := requestData{}
|
||||
reqData.queryValues = make(url.Values)
|
||||
reqData.queryValues.Set("service", "")
|
||||
@@ -72,29 +85,30 @@ func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) {
|
||||
|
||||
// Execute GET on bucket to list objects.
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return ServiceStatusMetadata{}, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return ServiceStatusMetadata{}, errors.New("Got HTTP Status: " + resp.Status)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var serviceStatus ServiceStatusMetadata
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return ServiceStatusMetadata{}, err
|
||||
}
|
||||
|
||||
var storageInfo ServiceStatusMetadata
|
||||
|
||||
err = json.Unmarshal(respBytes, &storageInfo)
|
||||
err = json.Unmarshal(respBytes, &serviceStatus)
|
||||
if err != nil {
|
||||
return ServiceStatusMetadata{}, err
|
||||
}
|
||||
|
||||
return storageInfo, nil
|
||||
return serviceStatus, nil
|
||||
}
|
||||
|
||||
// ServiceRestart - Call Service Restart API to restart a specified Minio server
|
||||
|
||||
Reference in New Issue
Block a user