minio/pkg/madmin
Anis Elleuch 3099af70a3 Add admin get/set config keys API (#6113)
This PR adds two new admin APIs in Minio server and madmin package:
- GetConfigKeys(keys []string) ([]byte, error)
- SetConfigKeys(params map[string]string) (err error)

A key is a path in Minio configuration file, (e.g. notify.webhook.1)

The user will always send a string value when setting it in the config file,
the API will know how to convert the value to the appropriate type. The user
is also able to set a raw json.

Before setting a new config, Minio will validate all fields and try to connect
to notification targets if available.
2018-09-06 20:33:18 +05:30
..
examples Add admin get/set config keys API (#6113) 2018-09-06 20:33:18 +05:30
api-error-response.go Move admin APIs to new path and add redesigned heal APIs (#5351) 2018-01-22 14:54:55 -08:00
api.go Ignore region in the case of admin API (#5919) 2018-06-07 10:37:31 -07:00
API.md Add admin get/set config keys API (#6113) 2018-09-06 20:33:18 +05:30
api_test.go admin: Add missing madmin examples and API docs. (#3483) 2016-12-20 18:49:48 -08:00
config-commands.go Add admin get/set config keys API (#6113) 2018-09-06 20:33:18 +05:30
generic-commands.go Ensure that setConfig uses latest functionality (#6302) 2018-08-17 18:51:34 -07:00
heal-commands.go ensure authenticated request bodies for Admin-API (#5984) 2018-05-30 14:49:03 -07:00
heal-commands_test.go Add large bucket support for erasure coded backend (#5160) 2018-02-15 17:45:57 -08:00
info-commands.go Deprecate showing drive capacity and total free (#5976) 2018-05-23 17:30:25 -07:00
README.md Fix typo (#5960) 2018-05-22 08:09:30 +05:30
service-commands.go ensure authenticated request bodies for Admin-API (#5984) 2018-05-30 14:49:03 -07:00
utils.go Remove unused functions and constants (#6175) 2018-07-20 23:37:43 +05:30
version-commands.go Move admin APIs to new path and add redesigned heal APIs (#5351) 2018-01-22 14:54:55 -08:00

Minio Admin Library. Slack

The Minio Admin Golang Client SDK provides APIs to manage Minio services.

This quickstart guide will show you how to install the Minio Admin client SDK, connect to Minio admin service, and provide a walkthrough of a simple file uploader.

This document assumes that you have a working Golang setup.

Download from GitHub


go get -u github.com/minio/minio/pkg/madmin

Initialize Minio Admin Client

You need four items to connect to Minio admin services.

Parameter Description
endpoint URL to object storage service.
accessKeyID Access key is the user ID that uniquely identifies your account.
secretAccessKey Secret key is the password to your account.
secure Set this value to 'true' to enable secure (HTTPS) access.

package main

import (
	"github.com/minio/minio/pkg/madmin"
	"log"
)

func main() {
	endpoint := "your-minio.example.com:9000"
	accessKeyID := "YOUR-ACCESSKEYID"
	secretAccessKey := "YOUR-SECRETKEY"
	useSSL := true

	// Initialize minio admin client object.
	madmClnt, err := madmin.New(endpoint, accessKeyID, secretAccessKey, useSSL)
	if err != nil {
		log.Fatalln(err)
	}

	log.Println("%v", madmClnt) // Minio admin client is now setup
}

Quick Start Example - Server Info

This example program connects to minio server, gets the current disk status and other useful server information.

ServiceStatus.go

package main

import (
	"encoding/json"
	"fmt"
	"log"

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

func main() {
	endpoint := "your-minio.example.com:9000"
	accessKeyID := "YOUR-ACCESSKEYID"
	secretAccessKey := "YOUR-SECRETKEY"
	useSSL := true

	// Initialize minio admin client.
	mdmClnt, err := madmin.New(endpoint, accessKeyID, secretAccessKey, useSSL)
	if err != nil {
		log.Fatalln(err)
	}

	si, err := mdmClnt.ServerInfo()
	if err != nil {
		log.Fatalln(err)
	}
	b, err := json.Marshal(si)
	fmt.Printf("%s\n", string(b))
}

Replace the endpoint and access credentials above according to an actual setup.

Run ServiceStatus

The sample output below shows the result of executing the above program against a locally hosted server.

[{"error":"","addr":"localhost:9000","data":{"storage":{"Total":460373336064,"Free":77001187328,"Backend":{"Type":2,"OnlineDisks":4,"OfflineDisks":0,"StandardSCParity":2,"RRSCParity":2}},"network":{"transferred":30599,"received":36370},"http":{"totalHEADs":{"count":0,"avgDuration":"0s"},"successHEADs":{"count":0,"avgDuration":"0s"},"totalGETs":{"count":11,"avgDuration":"0s"},"successGETs":{"count":11,"avgDuration":"0s"},"totalPUTs":{"count":0,"avgDuration":"0s"},"successPUTs":{"count":0,"avgDuration":"0s"},"totalPOSTs":{"count":0,"avgDuration":"0s"},"successPOSTs":{"count":0,"avgDuration":"0s"},"totalDELETEs":{"count":0,"avgDuration":"0s"},"successDELETEs":{"count":0,"avgDuration":"0s"}},"server":{"uptime":596915001694,"version":"2018-01-18T20:33:21Z","commitID":"e2d5a87b2676e3e01f0f4fa7ebd01205364cfb16","region":"us-east-1","sqsARN":null}}},{"error":"","addr":"minio2:9000","data":{"storage":{"Total":460373336064,"Free":77001187328,"Backend":{"Type":2,"OnlineDisks":4,"OfflineDisks":0,"StandardSCParity":2,"RRSCParity":2}},"network":{"transferred":28538,"received":11845},"http":{"totalHEADs":{"count":0,"avgDuration":"0s"},"successHEADs":{"count":0,"avgDuration":"0s"},"totalGETs":{"count":0,"avgDuration":"0s"},"successGETs":{"count":0,"avgDuration":"0s"},"totalPUTs":{"count":0,"avgDuration":"0s"},"successPUTs":{"count":0,"avgDuration":"0s"},"totalPOSTs":{"count":0,"avgDuration":"0s"},"successPOSTs":{"count":0,"avgDuration":"0s"},"totalDELETEs":{"count":0,"avgDuration":"0s"},"successDELETEs":{"count":0,"avgDuration":"0s"}},"server":{"uptime":595852367296,"version":"2018-01-18T20:33:21Z","commitID":"e2d5a87b2676e3e01f0f4fa7ebd01205364cfb16","region":"us-east-1","sqsARN":null}}},{"error":"","addr":"minio3:9000","data":{"storage":{"Total":460373336064,"Free":77001187328,"Backend":{"Type":2,"OnlineDisks":4,"OfflineDisks":0,"StandardSCParity":2,"RRSCParity":2}},"network":{"transferred":27624,"received":11708},"http":{"totalHEADs":{"count":0,"avgDuration":"0s"},"successHEADs":{"count":0,"avgDuration":"0s"},"totalGETs":{"count":0,"avgDuration":"0s"},"successGETs":{"count":0,"avgDuration":"0s"},"totalPUTs":{"count":0,"avgDuration":"0s"},"successPUTs":{"count":0,"avgDuration":"0s"},"totalPOSTs":{"count":0,"avgDuration":"0s"},"successPOSTs":{"count":0,"avgDuration":"0s"},"totalDELETEs":{"count":0,"avgDuration":"0s"},"successDELETEs":{"count":0,"avgDuration":"0s"}},"server":{"uptime":595831126778,"version":"2018-01-18T20:33:21Z","commitID":"e2d5a87b2676e3e01f0f4fa7ebd01205364cfb16","region":"us-east-1","sqsARN":null}}},{"error":"","addr":"minio4:9000","data":{"storage":{"Total":460373336064,"Free":77001187328,"Backend":{"Type":2,"OnlineDisks":4,"OfflineDisks":0,"StandardSCParity":2,"RRSCParity":2}},"network":{"transferred":27740,"received":12116},"http":{"totalHEADs":{"count":0,"avgDuration":"0s"},"successHEADs":{"count":0,"avgDuration":"0s"},"totalGETs":{"count":0,"avgDuration":"0s"},"successGETs":{"count":0,"avgDuration":"0s"},"totalPUTs":{"count":0,"avgDuration":"0s"},"successPUTs":{"count":0,"avgDuration":"0s"},"totalPOSTs":{"count":0,"avgDuration":"0s"},"successPOSTs":{"count":0,"avgDuration":"0s"},"totalDELETEs":{"count":0,"avgDuration":"0s"},"successDELETEs":{"count":0,"avgDuration":"0s"}},"server":{"uptime":595349958375,"version":"2018-01-18T20:33:21Z","commitID":"e2d5a87b2676e3e01f0f4fa7ebd01205364cfb16","region":"us-east-1","sqsARN":null}}}]

API Reference

API Reference : Service Operations

Full Examples

Full Examples : Service Operations

Contribute

Contributors Guide