madmin

package
v0.0.0-...-f4c3078 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 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 - Service Status.

This example program connects to minio server, gets the current disk status.

We will use the Minio server running at https://your-minio.example.com:9000 in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.

ServiceStatus.go
package main

import (
	"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)
	}

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

}

Run ServiceStatus

go run service-status.go
2016/12/20 16:46:01 madmin.ServiceStatusMetadata{Total:177038229504, Free:120365559808, Backend:struct { Type madmin.BackendType; OnlineDisks int; OfflineDisks int; ReadQuorum int; WriteQuorum int }{Type:1, OnlineDisks:0, OfflineDisks:0, ReadQuorum:0, WriteQuorum:0}}

API Reference

API Reference : Service Operations

Full Examples

Full Examples : Service Operations

Contribute

Contributors Guide

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidArgument

func ErrInvalidArgument(message string) error

ErrInvalidArgument - Invalid argument response.

Types

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) HealBucket

func (adm *AdminClient) HealBucket(bucket string, dryrun bool) error

HealBucket - Heal the given bucket

func (*AdminClient) HealFormat

func (adm *AdminClient) HealFormat(dryrun bool) error

HealFormat - heal storage format on available disks.

func (*AdminClient) HealObject

func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) (HealResult, error)

HealObject - Heal the given object.

func (*AdminClient) HealUpload

func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool) (HealResult, error)

HealUpload - Heal the given upload.

func (*AdminClient) ListBucketsHeal

func (adm *AdminClient) ListBucketsHeal() ([]BucketInfo, error)

ListBucketsHeal - issues heal bucket list API request

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) ListObjectsHeal

func (adm *AdminClient) ListObjectsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan ObjectInfo, error)

ListObjectsHeal - Lists upto maxKeys objects that needing heal matching bucket, prefix, marker, delimiter.

func (*AdminClient) ListUploadsHeal

func (adm *AdminClient) ListUploadsHeal(bucket, prefix string, recursive bool,
	doneCh <-chan struct{}) (<-chan UploadInfo, error)

ListUploadsHeal - issues list heal uploads API request

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) ServiceRestart

func (adm *AdminClient) ServiceRestart() error

ServiceRestart - Call Service Restart API to restart a specified Minio server

func (*AdminClient) ServiceStatus

func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, 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) (SetConfigResult, 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.

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 Bucket

type Bucket struct {
	Name         string
	CreationDate string // time string of format "2006-01-02T15:04:05.000Z"

	HealBucketInfo *HealBucketInfo `xml:"HealBucketInfo,omitempty"`
}

Bucket container for bucket metadata

type BucketInfo

type BucketInfo struct {
	// Name of the bucket.
	Name string

	// Date and time when the bucket was created.
	Created time.Time

	// Healing information
	HealBucketInfo *HealBucketInfo `xml:"HealBucketInfo,omitempty"`
}

BucketInfo - represents bucket metadata.

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 HealBucketInfo

type HealBucketInfo struct {
	Status HealStatus
}

HealBucketInfo - represents healing related information of a bucket.

type HealObjectInfo

type HealObjectInfo struct {
	Status             HealStatus
	MissingDataCount   int
	MissingParityCount int
}

HealObjectInfo - represents healing related information of an object.

type HealResult

type HealResult struct {
	State HealState `json:"state"`
}

HealResult - represents result of heal-object admin API.

type HealState

type HealState int

HealState - different states of heal operation

const (
	// HealNone - none of the disks healed
	HealNone HealState = iota
	// HealPartial - some disks were healed, others were offline
	HealPartial
	// HealOK - all disks were healed
	HealOK
)

type HealStatus

type HealStatus int

HealStatus - represents different states of healing an object could be in.

const (
	// Healthy - Object that is already healthy
	Healthy HealStatus = iota
	// CanHeal - Object can be healed
	CanHeal
	// Corrupted - Object can't be healed
	Corrupted
	// QuorumUnavailable - Object can't be healed until read
	// quorum is available
	QuorumUnavailable
	// CanPartiallyHeal - Object can't be healed completely until
	// disks with missing parts come online
	CanPartiallyHeal
)

type Initiator

type Initiator Owner

Initiator - has same properties as Owner.

type ListBucketsHealResponse

type ListBucketsHealResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"`

	Owner Owner

	// Container for one or more buckets.
	Buckets struct {
		Buckets []Bucket `xml:"Bucket"`
	} // Buckets are nested
}

ListBucketsHealResponse - format for list buckets response

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 ObjectInfo

type ObjectInfo struct {
	// An ETag is optionally set to md5sum of an object.  In case of multipart objects,
	// ETag is of the form MD5SUM-N where MD5SUM is md5sum of all individual md5sums of
	// each parts concatenated into one string.
	ETag string `json:"etag"`

	Key          string    `json:"name"`         // Name of the object
	LastModified time.Time `json:"lastModified"` // Date and time the object was last modified.
	Size         int64     `json:"size"`         // Size in bytes of the object.
	ContentType  string    `json:"contentType"`  // A standard MIME type describing the format of the object data.

	// Collection of additional metadata on the object.
	// eg: x-amz-meta-*, content-encoding etc.
	Metadata http.Header `json:"metadata"`

	// Owner name.
	Owner struct {
		DisplayName string `json:"name"`
		ID          string `json:"id"`
	} `json:"owner"`

	// The class of storage used to store the object.
	StorageClass string `json:"storageClass"`

	// Error
	Err            error           `json:"-"`
	HealObjectInfo *HealObjectInfo `json:"healObjectInfo,omitempty"`
}

ObjectInfo container for object metadata.

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 Owner

type Owner struct {
	ID          string
	DisplayName string
}

Owner - bucket owner/principal

type ServerConnStats

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

ServerConnStats holds network information

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"`
	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 ServiceStatusMetadata

type ServiceStatusMetadata struct {
	Uptime time.Duration `json:"uptime"`
}

ServiceStatusMetadata - 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 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.
		ReadQuorum   int // Minimum disks required for successful read operations.
		WriteQuorum  int // Minimum disks required for successful write operations.
	}
}

StorageInfo - represents total capacity of underlying storage.

type UploadInfo

type UploadInfo struct {
	Key string `json:"name"` // Name of the object being uploaded.

	UploadID string `json:"uploadId"` // UploadID
	// Owner name.
	Owner struct {
		DisplayName string `json:"name"`
		ID          string `json:"id"`
	} `json:"owner"`

	// The class of storage used to store the object.
	StorageClass string `json:"storageClass"`

	Initiated time.Time `json:"initiated"` // Time at which upload was initiated.

	// Error
	Err            error           `json:"-"`
	HealUploadInfo *HealObjectInfo `json:"healObjectInfo,omitempty"`
}

UploadInfo - represents an ongoing upload that needs to be healed.

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