mirror of
https://github.com/ceph/go-ceph
synced 2024-12-14 02:15:47 +00:00
936fc2deb1
Implement support for new /info AdminOps interface, which returns a json record similar to: { "info": { "storage_backends": [ { "name":"rados", "cluster_id":"204a1415-0b03-4926-bf76-6aebd192a52d" } ] } } Co-authored-by: Anoop C S <anoopcs@cryptolab.net> Co-authored-by: Sébastien Han <seb@redhat.com> Signed-off-by: Matt Benjamin <mbenjamin@redhat.com> Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
40 lines
836 B
Go
40 lines
836 B
Go
//go:build !(nautilus || octopus || pacific) && ceph_preview
|
|
// +build !nautilus,!octopus,!pacific,ceph_preview
|
|
|
|
package admin
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
// StorageBackend struct
|
|
type StorageBackend struct {
|
|
Name string `json:"name"`
|
|
ClusterID string `json:"cluster_id"`
|
|
}
|
|
|
|
// Info struct
|
|
type Info struct {
|
|
InfoSpec struct {
|
|
StorageBackends []StorageBackend `json:"storage_backends"`
|
|
} `json:"info"`
|
|
}
|
|
|
|
// GetInfo - https://docs.ceph.com/en/latest/radosgw/adminops/#info
|
|
func (api *API) GetInfo(ctx context.Context) (Info, error) {
|
|
body, err := api.call(ctx, http.MethodGet, "/info", nil)
|
|
if err != nil {
|
|
return Info{}, err
|
|
}
|
|
i := Info{}
|
|
err = json.Unmarshal(body, &i)
|
|
if err != nil {
|
|
return Info{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
|
}
|
|
|
|
return i, nil
|
|
}
|