madmin

package
v0.0.0-...-03dfc37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

README

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

Documentation

Index

Constants

View Source
const (
	HealItemMetadata       HealItemType = "metadata"
	HealItemBucket                      = "bucket"
	HealItemBucketMetadata              = "bucket-metadata"
	HealItemObject                      = "object"
)

HealItemType constants

View Source
const (
	DriveStateOk      string = "ok"
	DriveStateOffline        = "offline"
	DriveStateCorrupt        = "corrupt"
	DriveStateMissing        = "missing"
)

Drive state constants

Variables

This section is empty.

Functions

func ErrInvalidArgument

func ErrInvalidArgument(message string) error

ErrInvalidArgument - Invalid argument response.

Types

type AdminAPIVersionInfo

type AdminAPIVersionInfo struct {
	Version string `json:"version"`
}

AdminAPIVersionInfo - contains admin API version information

type AdminClient

type AdminClient struct {
	// contains filtered or unexported fields
}

AdminClient implements Amazon S3 compatible methods.

func New

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

New - instantiate minio client Client, adds automatic verification of signature.

func (*AdminClient) ClearLocks

func (adm *AdminClient) ClearLocks(bucket, prefix string,
	duration time.Duration) ([]VolumeLockInfo, error)

ClearLocks - Calls Clear Locks Management API to clear locks held on bucket, matching prefix older than duration supplied.

func (*AdminClient) GetConfig

func (adm *AdminClient) GetConfig() ([]byte, error)

GetConfig - returns the config.json of a minio setup.

func (*AdminClient) Heal

func (adm *AdminClient) Heal(bucket, prefix string, healOpts HealOpts,
	clientToken string, forceStart bool) (
	healStart HealStartSuccess, healTaskStatus HealTaskStatus, err error)

Heal - API endpoint to start heal and to fetch status

func (*AdminClient) ListLocks

func (adm *AdminClient) ListLocks(bucket, prefix string,
	duration time.Duration) ([]VolumeLockInfo, error)

ListLocks - Calls List Locks Management API to fetch locks matching bucket, prefix and held before the duration supplied.

func (*AdminClient) ServerInfo

func (adm *AdminClient) ServerInfo() ([]ServerInfo, error)

ServerInfo - Connect to a minio server and call Server Info Management API to fetch server's information represented by ServerInfo structure

func (*AdminClient) ServiceSendAction

func (adm *AdminClient) ServiceSendAction(action ServiceActionValue) error

ServiceSendAction - Call Service Restart/Stop API to restart/stop a Minio server

func (*AdminClient) ServiceStatus

func (adm *AdminClient) ServiceStatus() (ss ServiceStatus, err error)

ServiceStatus - Connect to a minio server and call Service Status Management API to fetch server's storage information represented by ServiceStatusMetadata structure

func (*AdminClient) SetAppInfo

func (c *AdminClient) SetAppInfo(appName string, appVersion string)

SetAppInfo - add application details to user agent.

func (*AdminClient) SetConfig

func (adm *AdminClient) SetConfig(config io.Reader) (r SetConfigResult, err error)

SetConfig - set config supplied as config.json for the setup.

func (*AdminClient) SetCredentials

func (adm *AdminClient) SetCredentials(access, secret string) error

SetCredentials - Call Set Credentials API to set new access and secret keys in the specified Minio server

func (*AdminClient) SetCustomTransport

func (c *AdminClient) SetCustomTransport(customHTTPTransport http.RoundTripper)

SetCustomTransport - set new custom transport.

func (*AdminClient) TraceOff

func (c *AdminClient) TraceOff()

TraceOff - disable HTTP tracing.

func (*AdminClient) TraceOn

func (c *AdminClient) TraceOn(outputStream io.Writer)

TraceOn - enable HTTP tracing.

func (*AdminClient) VersionInfo

func (adm *AdminClient) VersionInfo() (verInfo AdminAPIVersionInfo, err error)

VersionInfo - Connect to minio server and call the version API to retrieve the server API version

type BackendType

type BackendType int

BackendType - represents different backend types.

const (
	Unknown BackendType = iota
	// Filesystem backend.
	FS
	// Multi disk Erasure (single, distributed) backend.
	Erasure
)

Enum for different backend types.

type DriveInfo

type DriveInfo HealDriveInfo

DriveInfo - represents each drive info, describing status, uuid and endpoint.

type ErrorResponse

type ErrorResponse struct {
	XMLName    xml.Name `xml:"Error" json:"-"`
	Code       string
	Message    string
	BucketName string
	Key        string
	RequestID  string `xml:"RequestId"`
	HostID     string `xml:"HostId"`

	// Region where the bucket is located. This header is returned
	// only in HEAD bucket and ListObjects response.
	Region string
}

ErrorResponse - Is the typed error returned by all API operations.

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

Error - Returns HTTP error string

type HealDriveInfo

type HealDriveInfo struct {
	UUID     string `json:"uuid"`
	Endpoint string `json:"endpoint"`
	State    string `json:"state"`
}

HealDriveInfo - struct for an individual drive info item.

type HealItemType

type HealItemType string

HealItemType - specify the type of heal operation in a healing result

type HealOpts

type HealOpts struct {
	Recursive bool `json:"recursive"`
	DryRun    bool `json:"dryRun"`
}

HealOpts - collection of options for a heal sequence

type HealResultItem

type HealResultItem struct {
	ResultIndex  int64        `json:"resultId"`
	Type         HealItemType `json:"type"`
	Bucket       string       `json:"bucket"`
	Object       string       `json:"object"`
	Detail       string       `json:"detail"`
	ParityBlocks int          `json:"parityBlocks,omitempty"`
	DataBlocks   int          `json:"dataBlocks,omitempty"`
	DiskCount    int          `json:"diskCount"`
	SetCount     int          `json:"setCount"`
	// below slices are from drive info.
	Before struct {
		Drives []HealDriveInfo `json:"drives"`
	} `json:"before"`
	After struct {
		Drives []HealDriveInfo `json:"drives"`
	} `json:"after"`
	ObjectSize int64 `json:"objectSize"`
}

HealResultItem - struct for an individual heal result item

func (*HealResultItem) GetCorruptedCounts

func (hri *HealResultItem) GetCorruptedCounts() (b, a int)

GetCorruptedCounts - returns the number of corrupted disks before and after heal

func (*HealResultItem) GetMissingCounts

func (hri *HealResultItem) GetMissingCounts() (b, a int)

GetMissingCounts - returns the number of missing disks before and after heal

func (*HealResultItem) GetOfflineCounts

func (hri *HealResultItem) GetOfflineCounts() (b, a int)

GetOfflineCounts - returns the number of offline disks before and after heal

func (*HealResultItem) GetOnlineCounts

func (hri *HealResultItem) GetOnlineCounts() (b, a int)

GetOnlineCounts - returns the number of online disks before and after heal

type HealStartSuccess

type HealStartSuccess struct {
	ClientToken   string    `json:"clientToken"`
	ClientAddress string    `json:"clientAddress"`
	StartTime     time.Time `json:"startTime"`
}

HealStartSuccess - holds information about a successfully started heal operation

type HealTaskStatus

type HealTaskStatus struct {
	Summary       string    `json:"summary"`
	FailureDetail string    `json:"detail"`
	StartTime     time.Time `json:"startTime"`
	HealSettings  HealOpts  `json:"settings"`
	NumDisks      int       `json:"numDisks"`

	Items []HealResultItem `json:"items,omitempty"`
}

HealTaskStatus - status struct for a heal task

type NodeSummary

type NodeSummary struct {
	Name   string `json:"name"`
	ErrSet bool   `json:"errSet"`
	ErrMsg string `json:"errMsg"`
}

NodeSummary - represents the result of an operation part of set-config on a node.

type OpsLockState

type OpsLockState struct {
	OperationID string     `json:"id"`     // String containing operation ID.
	LockSource  string     `json:"source"` // Operation type (GetObject, PutObject...)
	LockType    lockType   `json:"type"`   // Lock type (RLock, WLock)
	Status      statusType `json:"status"` // Status can be Running/Ready/Blocked.
	Since       time.Time  `json:"since"`  // Time when the lock was initially held.
}

OpsLockState - represents lock specific details.

type ServerConnStats

type ServerConnStats struct {
	TotalInputBytes  uint64 `json:"transferred"`
	TotalOutputBytes uint64 `json:"received"`
}

ServerConnStats holds network information

type ServerHTTPMethodStats

type ServerHTTPMethodStats struct {
	Count       uint64 `json:"count"`
	AvgDuration string `json:"avgDuration"`
}

ServerHTTPMethodStats holds total number of HTTP operations from/to the server, including the average duration the call was spent.

type ServerHTTPStats

type ServerHTTPStats struct {
	TotalHEADStats     ServerHTTPMethodStats `json:"totalHEADs"`
	SuccessHEADStats   ServerHTTPMethodStats `json:"successHEADs"`
	TotalGETStats      ServerHTTPMethodStats `json:"totalGETs"`
	SuccessGETStats    ServerHTTPMethodStats `json:"successGETs"`
	TotalPUTStats      ServerHTTPMethodStats `json:"totalPUTs"`
	SuccessPUTStats    ServerHTTPMethodStats `json:"successPUTs"`
	TotalPOSTStats     ServerHTTPMethodStats `json:"totalPOSTs"`
	SuccessPOSTStats   ServerHTTPMethodStats `json:"successPOSTs"`
	TotalDELETEStats   ServerHTTPMethodStats `json:"totalDELETEs"`
	SuccessDELETEStats ServerHTTPMethodStats `json:"successDELETEs"`
}

ServerHTTPStats holds all type of http operations performed to/from the server including their average execution time.

type ServerInfo

type ServerInfo struct {
	Error string          `json:"error"`
	Addr  string          `json:"addr"`
	Data  *ServerInfoData `json:"data"`
}

ServerInfo holds server information result of one node

type ServerInfoData

type ServerInfoData struct {
	StorageInfo StorageInfo      `json:"storage"`
	ConnStats   ServerConnStats  `json:"network"`
	HTTPStats   ServerHTTPStats  `json:"http"`
	Properties  ServerProperties `json:"server"`
}

ServerInfoData holds storage, connections and other information of a given server

type ServerProperties

type ServerProperties struct {
	Uptime   time.Duration `json:"uptime"`
	Version  string        `json:"version"`
	CommitID string        `json:"commitID"`
	Region   string        `json:"region"`
	SQSARN   []string      `json:"sqsARN"`
}

ServerProperties holds some of the server's information such as uptime, version, region, ..

type ServerVersion

type ServerVersion struct {
	Version  string `json:"version"`
	CommitID string `json:"commitID"`
}

ServerVersion - server version

type ServiceAction

type ServiceAction struct {
	Action ServiceActionValue `json:"action"`
}

ServiceAction - represents POST body for service action APIs

type ServiceActionValue

type ServiceActionValue string

ServiceActionValue - type to restrict service-action values

const (
	// ServiceActionValueRestart represents restart action
	ServiceActionValueRestart ServiceActionValue = "restart"
	// ServiceActionValueStop represents stop action
	ServiceActionValueStop = "stop"
)

type ServiceStatus

type ServiceStatus struct {
	ServerVersion ServerVersion `json:"serverVersion"`
	Uptime        time.Duration `json:"uptime"`
}

ServiceStatus - contains the response of service status API

type SetConfigResult

type SetConfigResult struct {
	NodeResults []NodeSummary `json:"nodeResults"`
	Status      bool          `json:"status"`
}

SetConfigResult - represents detailed results of a set-config operation.

type SetCredsReq

type SetCredsReq struct {
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`
}

SetCredsReq - xml to send to the server to set new credentials

type StorageInfo

type StorageInfo struct {
	// Total disk space.
	Total int64
	// Free available disk space.
	Free int64
	// Backend type.
	Backend struct {
		// Represents various backend types, currently on FS and Erasure.
		Type BackendType

		// Following fields are only meaningful if BackendType is Erasure.
		OnlineDisks      int // Online disks during server startup.
		OfflineDisks     int // Offline disks during server startup.
		StandardSCData   int // Data disks for currently configured Standard storage class.
		StandardSCParity int // Parity disks for currently configured Standard storage class.
		RRSCData         int // Data disks for currently configured Reduced Redundancy storage class.
		RRSCParity       int // Parity disks for currently configured Reduced Redundancy storage class.

		// List of all disk status, this is only meaningful if BackendType is Erasure.
		Sets [][]DriveInfo
	}
}

StorageInfo - represents total capacity of underlying storage.

type VolumeLockInfo

type VolumeLockInfo struct {
	Bucket string `json:"bucket"`
	Object string `json:"object"`

	// All locks blocked + running for given <volume,path> pair.
	LocksOnObject int64 `json:"-"`
	// Count of operations which has successfully acquired the lock
	// but hasn't unlocked yet( operation in progress).
	LocksAcquiredOnObject int64 `json:"-"`
	// Count of operations which are blocked waiting for the lock
	// to be released.
	TotalBlockedLocks int64 `json:"-"`

	// Count of all read locks
	TotalReadLocks int64 `json:"readLocks"`
	// Count of all write locks
	TotalWriteLocks int64 `json:"writeLocks"`
	// State information containing state of the locks for all operations
	// on given <volume,path> pair.
	LockDetailsOnObject []OpsLockState `json:"lockOwners"`
}

VolumeLockInfo - represents summary and individual lock details of all locks held on a given bucket, object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL