minio/pkg/madmin/API.md

2.9 KiB

Golang Admin Client API Reference Slack

Initialize Minio Admin Client object.

Minio


package main

import (
	"fmt"

	"github.com/minio/minio/pkg/madmin"
)

func main() {
	// Use a secure connection.
	ssl := true

	// Initialize minio client object.
	mdmClnt, err := madmin.New("your-minio.example.com:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETKEY", ssl)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Fetch service status.
	st, err := mdmClnt.ServiceStatus()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%#v\n", st)
}

Service operations LockInfo operations Healing operations
ServiceStatus
ServiceRestart

1. Constructor

New(endpoint string, accessKeyID string, secretAccessKey string, ssl bool) (*AdminClient, error)

Initializes a new admin client object.

Parameters

Param Type Description
endpoint string Minio endpoint.
accessKeyID string Access key for the object storage endpoint.
secretAccessKey string Secret key for the object storage endpoint.
ssl bool Set this value to 'true' to enable secure (HTTPS) access.

2. Service operations

ServiceStatus() (ServiceStatusMetadata, error)

Fetch service status, replies disk space used, backend type and total disks offline/online (XL).

Param Type Description
serviceStatus ServiceStatusMetadata Represents current server status info in following format:
Param Type Description
st.Total int64 Total disk space.
st.Free int64 Free disk space.
st.Backend struct{} Represents backend type embedded structure.
Param Type Description
backend.Type BackendType Type of backend used by the server currently only FS or XL.
backend.OnlineDisks int Total number of disks online (only applies to XL backend), is empty for FS.
backend.OfflineDisks int Total number of disks offline (only applies to XL backend), is empty for FS.
backend.ReadQuorum int Current total read quorum threshold before reads will be unavailable, is empty for FS.
backend.WriteQuorum int Current total write quorum threshold before writes will be unavailable, is empty for FS.

Example


   st, err := madmClnt.ServiceStatus()
   if err != nil {
   	log.Fatalln(err)
   }
   log.Printf("%#v\n", st)

ServiceRestart() (error)

If successful restarts the running minio service, for distributed setup restarts all remote minio servers.

Example



   st, err := madmClnt.ServiceRestart()
   if err != nil {
   	log.Fatalln(err)
   }
   log.Printf("Succes")