2019-04-24 15:54:44 -04:00
# Golang Admin Client API Reference [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
2019-04-09 14:39:42 -04:00
The MinIO Admin Golang Client SDK provides APIs to manage MinIO services.
2016-12-20 21:49:48 -05:00
2019-04-09 14:39:42 -04:00
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.
2016-12-20 21:49:48 -05:00
2019-08-15 19:00:50 -04:00
This document assumes that you have a working [Golang setup ](https://golang.org/doc/install ).
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
## Initialize MinIO Admin Client object.
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
## MinIO
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
```go
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.
2019-08-28 18:04:43 -04:00
st, err := mdmClnt.ServerInfo()
2019-04-24 15:54:44 -04:00
if err != nil {
fmt.Println(err)
return
}
2019-08-28 18:04:43 -04:00
for _, peerInfo := range serversInfo {
log.Printf("Node: %s, Info: %v\n", peerInfo.Addr, peerInfo.Data)
}
2019-04-24 15:54:44 -04:00
}
2016-12-20 21:49:48 -05:00
```
2020-04-13 01:00:41 -04:00
2020-06-30 11:34:08 -04:00
| Service operations | Info operations | Healing operations | Config operations |
|:------------------------------------|:-----------------------------------------|:-------------------|:--------------------------|
| [`ServiceTrace` ](#ServiceTrace ) | [`ServerInfo` ](#ServerInfo ) | [`Heal` ](#Heal ) | [`GetConfig` ](#GetConfig ) |
| [`ServiceStop` ](#ServiceStop ) | [`StorageInfo` ](#StorageInfo ) | | [`SetConfig` ](#SetConfig ) |
| [`ServiceRestart` ](#ServiceRestart ) | [`AccountUsageInfo` ](#AccountUsageInfo ) | | |
2020-04-13 01:00:41 -04:00
| Top operations | IAM operations | Misc | KMS |
|:------------------------|:--------------------------------------|:--------------------------------------------------|:--------------------------------|
| [`TopLocks` ](#TopLocks ) | [`AddUser` ](#AddUser ) | [`StartProfiling` ](#StartProfiling ) | [`GetKeyStatus` ](#GetKeyStatus ) |
| | [`SetUserPolicy` ](#SetUserPolicy ) | [`DownloadProfilingData` ](#DownloadProfilingData ) | |
| | [`ListUsers` ](#ListUsers ) | [`ServerUpdate` ](#ServerUpdate ) | |
| | [`AddCannedPolicy` ](#AddCannedPolicy ) | | |
2019-09-13 19:34:34 -04:00
2019-04-24 15:54:44 -04:00
## 1. Constructor
< a name = "MinIO" > < / a >
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
### New(endpoint string, accessKeyID string, secretAccessKey string, ssl bool) (*AdminClient, error)
Initializes a new admin client object.
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
__Parameters__
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
| 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. |
2016-12-20 21:49:48 -05:00
2019-08-27 14:37:47 -04:00
## 2. Service operations
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
< a name = "ServiceStatus" > < / a >
2020-04-07 22:30:59 -04:00
### ServiceStatus(ctx context.Context) (ServiceStatusMetadata, error)
2019-04-24 15:54:44 -04:00
Fetch service status, replies disk space used, backend type and total disks offline/online (applicable in distributed mode).
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
| Param | Type | Description |
|-----------------|-------------------------|------------------------------------------------------------|
| `serviceStatus` | _ServiceStatusMetadata_ | Represents current server status info in following format: |
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
| Param | Type | Description |
|-----------------------------|-----------------|------------------------------------|
| `st.ServerVersion.Version` | _string_ | Server version. |
| `st.ServerVersion.CommitID` | _string_ | Server commit id. |
| `st.Uptime` | _time.Duration_ | Server uptime duration in seconds. |
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
__Example__
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
```go
2016-12-20 21:49:48 -05:00
2020-04-07 22:30:59 -04:00
st, err := madmClnt.ServiceStatus(context.Background())
2016-12-20 21:49:48 -05:00
if err != nil {
log.Fatalln(err)
}
2019-04-24 15:54:44 -04:00
log.Printf("%#v\n", st)
```
2019-08-27 14:37:47 -04:00
< a name = "ServiceRestart" > < / a >
2020-04-07 22:30:59 -04:00
### ServiceRestart(ctx context.Context) error
2019-08-27 14:37:47 -04:00
Sends a service action restart command to MinIO server.
2019-04-24 15:54:44 -04:00
__Example__
2016-12-20 21:49:48 -05:00
2019-08-27 14:37:47 -04:00
```go
// To restart the service, restarts all servers in the cluster.
2020-04-07 22:30:59 -04:00
err := madmClnt.ServiceRestart(context.Background())
2019-08-27 14:37:47 -04:00
if err != nil {
log.Fatalln(err)
}
log.Println("Success")
```
2019-04-24 15:54:44 -04:00
2019-08-27 14:37:47 -04:00
< a name = "ServiceStop" > < / a >
2020-04-07 22:30:59 -04:00
### ServiceStop(ctx context.Context) error
2019-08-27 14:37:47 -04:00
Sends a service action stop command to MinIO server.
__Example__
```go
// To stop the service, stops all servers in the cluster.
2020-04-07 22:30:59 -04:00
err := madmClnt.ServiceStop(context.Background())
2019-08-27 14:37:47 -04:00
if err != nil {
log.Fatalln(err)
}
log.Println("Success")
```
< a name = "ServiceTrace" > < / a >
2020-04-07 22:30:59 -04:00
### ServiceTrace(ctx context.Context, allTrace bool, doneCh <-chan struct{}) <-chan TraceInfo
2019-08-27 14:37:47 -04:00
Enable HTTP request tracing on all nodes in a MinIO cluster
__Example__
``` go
doneCh := make(chan struct{})
defer close(doneCh)
// listen to all trace including internal API calls
allTrace := true
// Start listening on all trace activity.
2020-04-07 22:30:59 -04:00
traceCh := madmClnt.ServiceTrace(context.Background(), allTrace, doneCh)
2019-08-27 14:37:47 -04:00
for traceInfo := range traceCh {
fmt.Println(traceInfo.String())
}
```
2019-04-24 15:54:44 -04:00
2019-08-27 14:37:47 -04:00
## 3. Info operations
2019-04-24 15:54:44 -04:00
< a name = "ServerInfo" > < / a >
2020-04-07 22:30:59 -04:00
### ServerInfo(ctx context.Context) ([]ServerInfo, error)
2019-04-24 15:54:44 -04:00
Fetches information for all cluster nodes, such as server properties, storage information, network statistics, etc.
2019-10-23 00:01:14 -04:00
| Param | Type | Description |
|----------------------------------|--------------------|--------------------------------------------------------------------|
| `si.Addr` | _string_ | Address of the server the following information is retrieved from. |
| `si.ConnStats` | _ServerConnStats_ | Connection statistics from the given server. |
| `si.HTTPStats` | _ServerHTTPStats_ | HTTP connection statistics from the given server. |
| `si.Properties` | _ServerProperties_ | Server properties such as region, notification targets. |
2019-04-24 15:54:44 -04:00
| Param | Type | Description |
|-----------------------------|-----------------|----------------------------------------------------|
| `ServerProperties.Uptime` | _time.Duration_ | Total duration in seconds since server is running. |
| `ServerProperties.Version` | _string_ | Current server version. |
| `ServerProperties.CommitID` | _string_ | Current server commitID. |
| `ServerProperties.Region` | _string_ | Configured server region. |
| `ServerProperties.SQSARN` | _[]string_ | List of notification target ARNs. |
| Param | Type | Description |
|------------------------------------|----------|-------------------------------------|
| `ServerConnStats.TotalInputBytes` | _uint64_ | Total bytes received by the server. |
| `ServerConnStats.TotalOutputBytes` | _uint64_ | Total bytes sent by the server. |
| Param | Type | Description |
|--------------------------------------|-------------------------|---------------------------------------------------------|
| `ServerHTTPStats.TotalHEADStats` | _ServerHTTPMethodStats_ | Total statistics regarding HEAD operations |
| `ServerHTTPStats.SuccessHEADStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful HEAD operations |
| `ServerHTTPStats.TotalGETStats` | _ServerHTTPMethodStats_ | Total statistics regarding GET operations |
| `ServerHTTPStats.SuccessGETStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful GET operations |
| `ServerHTTPStats.TotalPUTStats` | _ServerHTTPMethodStats_ | Total statistics regarding PUT operations |
| `ServerHTTPStats.SuccessPUTStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful PUT operations |
| `ServerHTTPStats.TotalPOSTStats` | _ServerHTTPMethodStats_ | Total statistics regarding POST operations |
| `ServerHTTPStats.SuccessPOSTStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful POST operations |
| `ServerHTTPStats.TotalDELETEStats` | _ServerHTTPMethodStats_ | Total statistics regarding DELETE operations |
| `ServerHTTPStats.SuccessDELETEStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful DELETE operations |
| Param | Type | Description |
|-------------------------------------|----------|-------------------------------------------------|
| `ServerHTTPMethodStats.Count` | _uint64_ | Total number of operations. |
| `ServerHTTPMethodStats.AvgDuration` | _string_ | Average duration of Count number of operations. |
| Param | Type | Description |
|----------------------|----------|-------------------------------------------------------|
| `DriveInfo.UUID` | _string_ | Unique ID for each disk provisioned by server format. |
| `DriveInfo.Endpoint` | _string_ | Endpoint location of the remote/local disk. |
| `DriveInfo.State` | _string_ | Current state of the disk at endpoint. |
__Example__
```go
2020-04-07 22:30:59 -04:00
serversInfo, err := madmClnt.ServerInfo(context.Background())
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalln(err)
}
for _, peerInfo := range serversInfo {
log.Printf("Node: %s, Info: %v\n", peerInfo.Addr, peerInfo.Data)
}
```
2019-10-23 00:01:14 -04:00
< a name = "StorageInfo" > < / a >
2020-04-07 22:30:59 -04:00
### StorageInfo(ctx context.Context) (StorageInfo, error)
2019-10-23 00:01:14 -04:00
Fetches Storage information for all cluster nodes.
| Param | Type | Description |
|-------------------------|------------|---------------------------------------------|
| `storageInfo.Used` | _[]int64_ | Used disk spaces. |
| `storageInfo.Total` | _[]int64_ | Total disk spaces. |
| `storageInfo.Available` | _[]int64_ | Available disk spaces. |
| `StorageInfo.Backend` | _struct{}_ | Represents backend type embedded structure. |
| Param | Type | Description |
|----------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------|
| `Backend.Type` | _BackendType_ | Type of backend used by the server currently only FS or Erasure. |
| `Backend.OnlineDisks` | _BackendDisks_ | Total number of disks online per node (only applies to Erasure backend) represented in map[string]int, is empty for FS. |
| `Backend.OfflineDisks` | _BackendDisks_ | Total number of disks offline per node (only applies to Erasure backend) represented in map[string]int, is empty for FS. |
| `Backend.StandardSCData` | _int_ | Data disks set for standard storage class, is empty for FS. |
| `Backend.StandardSCParity` | _int_ | Parity disks set for standard storage class, is empty for FS. |
| `Backend.RRSCData` | _int_ | Data disks set for reduced redundancy storage class, is empty for FS. |
| `Backend.RRSCParity` | _int_ | Parity disks set for reduced redundancy storage class, is empty for FS. |
| `Backend.Sets` | _[][]DriveInfo_ | Represents topology of drives in erasure coded sets. |
__Example__
```go
2020-04-07 22:30:59 -04:00
storageInfo, err := madmClnt.StorageInfo(context.Background())
2019-10-23 00:01:14 -04:00
if err != nil {
log.Fatalln(err)
}
log.Println(storageInfo)
```
2020-06-30 11:34:08 -04:00
< a name = "AccountUsageInfo" > < / a >
### AccountUsageInfo(ctx context.Context) (AccountUsageInfo, error)
Fetches accounting usage information for the current authenticated user
| Param | Type | Description |
|--------------------------------|----------------------|-------------------------|
| `AccountUsageInfo.AccountName` | _string_ | Account name. |
| `AccountUsageInfo.Buckets` | _[]BucketUsageInfo_ | Bucket usage info. |
| Param | Type | Description |
|----------------------------|-----------------|-----------------------------------------|
| `BucketUsageInfo.Name` | _string_ | The name of the current bucket
| `BucketUsageInfo.Size` | _uint64_ | The total size of the current bucket
| `BucketUsageInfo.Created` | _time.Time_ | Bucket creation time
| `BucketUsageInfo.Access` | _AccountAccess_ | Type of access of the current account
| Param | Type | Description |
|------------------------|---------|------------------------------------------------------------------|
| `AccountAccess.Read` | _bool_ | Indicate if the bucket is readable by the current account name. |
| `AccountAccess.Write` | _bool_ | Indocate if the bucket is writable by the current account name. |
__Example__
```go
accountUsageInfo, err := madmClnt.AccountUsageInfo(context.Background())
if err != nil {
log.Fatalln(err)
}
log.Println(accountUsageInfo)
```
2019-08-27 14:37:47 -04:00
## 5. Heal operations
2019-04-24 15:54:44 -04:00
< a name = "Heal" > < / a >
2020-04-07 22:30:59 -04:00
### Heal(ctx context.Context, bucket, prefix string, healOpts HealOpts, clientToken string, forceStart bool, forceStop bool) (start HealStartSuccess, status HealTaskStatus, err error)
2019-04-24 15:54:44 -04:00
Start a heal sequence that scans data under given (possible empty)
`bucket` and `prefix` . The `recursive` bool turns on recursive
traversal under the given path. `dryRun` does not mutate on-disk data,
but performs data validation.
Two heal sequences on overlapping paths may not be initiated.
The progress of a heal should be followed using the same API `Heal`
by providing the `clientToken` previously obtained from a `Heal`
API. The server accumulates results of the heal traversal and waits
for the client to receive and acknowledge them using the status
request by providing `clientToken` .
__Example__
``` go
opts := madmin.HealOpts{
Recursive: true,
DryRun: false,
}
forceStart := false
forceStop := false
2020-04-07 22:30:59 -04:00
healPath, err := madmClnt.Heal(context.Background(), "", "", opts, "", forceStart, forceStop)
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalln(err)
}
log.Printf("Heal sequence started at %s", healPath)
2016-12-20 21:49:48 -05:00
```
2019-04-24 15:54:44 -04:00
#### HealStartSuccess structure
| Param | Type | Description |
|-------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------|
| `s.ClientToken` | _string_ | A unique token for a successfully started heal operation, this token is used to request realtime progress of the heal operation. |
| `s.ClientAddress` | _string_ | Address of the client which initiated the heal operation, the client address has the form "host:port". |
| `s.StartTime` | _time.Time_ | Time when heal was initially started. |
#### HealTaskStatus structure
| Param | Type | Description |
|-------------------|--------------------|---------------------------------------------------|
| `s.Summary` | _string_ | Short status of heal sequence |
| `s.FailureDetail` | _string_ | Error message in case of heal sequence failure |
| `s.HealSettings` | _HealOpts_ | Contains the booleans set in the `HealStart` call |
| `s.Items` | _[]HealResultItem_ | Heal records for actions performed by server |
#### HealResultItem structure
| Param | Type | Description |
|------------------------|----------------|-----------------------------------------------------------------|
| `ResultIndex` | _int64_ | Index of the heal-result record |
| `Type` | _HealItemType_ | Represents kind of heal operation in the heal record |
| `Bucket` | _string_ | Bucket name |
| `Object` | _string_ | Object name |
| `Detail` | _string_ | Details about heal operation |
| `DiskInfo.AvailableOn` | _[]int_ | List of disks on which the healed entity is present and healthy |
| `DiskInfo.HealedOn` | _[]int_ | List of disks on which the healed entity was restored |
2019-08-27 14:37:47 -04:00
## 6. Config operations
2019-04-24 15:54:44 -04:00
< a name = "GetConfig" > < / a >
2020-04-07 22:30:59 -04:00
### GetConfig(ctx context.Context) ([]byte, error)
2019-04-24 15:54:44 -04:00
Get current `config.json` of a MinIO server.
__Example__
``` go
2020-04-07 22:30:59 -04:00
configBytes, err := madmClnt.GetConfig(context.Background())
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalf("failed due to: %v", err)
}
// Pretty-print config received as json.
var buf bytes.Buffer
err = json.Indent(buf, configBytes, "", "\t")
if err != nil {
log.Fatalf("failed due to: %v", err)
}
log.Println("config received successfully: ", string(buf.Bytes()))
```
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
< a name = "SetConfig" > < / a >
2020-04-07 22:30:59 -04:00
### SetConfig(ctx context.Context, config io.Reader) error
2019-04-24 15:54:44 -04:00
Set a new `config.json` for a MinIO server.
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
__Example__
``` go
config := bytes.NewReader([]byte(`config.json contents go here`))
2020-04-07 22:30:59 -04:00
if err := madmClnt.SetConfig(context.Background(), config); err != nil {
2019-04-24 15:54:44 -04:00
log.Fatalf("failed due to: %v", err)
}
log.Println("SetConfig was successful")
```
2019-08-27 14:37:47 -04:00
## 7. Top operations
2019-04-24 15:54:44 -04:00
< a name = "TopLocks" > < / a >
2020-04-07 22:30:59 -04:00
### TopLocks(ctx context.Context) (LockEntries, error)
2019-04-24 15:54:44 -04:00
Get the oldest locks from MinIO server.
__Example__
``` go
2020-04-07 22:30:59 -04:00
locks, err := madmClnt.TopLocks(context.Background())
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalf("failed due to: %v", err)
}
out, err := json.Marshal(locks)
if err != nil {
log.Fatalf("Marshal failed due to: %v", err)
}
log.Println("TopLocks received successfully: ", string(out))
```
2019-08-27 14:37:47 -04:00
## 8. IAM operations
2019-04-24 15:54:44 -04:00
< a name = "AddCannedPolicy" > < / a >
2020-04-07 22:30:59 -04:00
### AddCannedPolicy(ctx context.Context, policyName string, policy *iampolicy.Policy) error
2019-04-24 15:54:44 -04:00
Create a new canned policy on MinIO server.
__Example__
```
2020-04-07 22:30:59 -04:00
policy, err := iampolicy.ParseConfig(strings.NewReader(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject"],"Effect": "Allow","Resource": ["arn:aws:s3:::my-bucketname/*"],"Sid": ""}]}`))
if err != nil {
log.Fatalln(err)
}
2019-04-24 15:54:44 -04:00
2020-04-07 22:30:59 -04:00
if err = madmClnt.AddCannedPolicy(context.Background(), "get-only", policy); err != nil {
2019-04-24 15:54:44 -04:00
log.Fatalln(err)
}
```
< a name = "AddUser" > < / a >
2020-04-07 22:30:59 -04:00
### AddUser(ctx context.Context, user string, secret string) error
2019-04-24 15:54:44 -04:00
Add a new user on a MinIO server.
__Example__
``` go
2020-04-07 22:30:59 -04:00
if err = madmClnt.AddUser(context.Background(), "newuser", "newstrongpassword"); err != nil {
2019-04-24 15:54:44 -04:00
log.Fatalln(err)
}
2016-12-20 21:49:48 -05:00
```
2019-04-24 15:54:44 -04:00
< a name = "SetUserPolicy" > < / a >
2020-04-07 22:30:59 -04:00
### SetUserPolicy(ctx context.Context, user string, policyName string) error
2019-04-24 15:54:44 -04:00
Enable a canned policy `get-only` for a given user on MinIO server.
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
__Example__
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
``` go
2020-04-07 22:30:59 -04:00
if err = madmClnt.SetUserPolicy(context.Background(), "newuser", "get-only"); err != nil {
2019-04-24 15:54:44 -04:00
log.Fatalln(err)
}
```
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
< a name = "ListUsers" > < / a >
2020-04-07 22:30:59 -04:00
### ListUsers(ctx context.Context) (map[string]UserInfo, error)
2019-04-24 15:54:44 -04:00
Lists all users on MinIO server.
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
__Example__
2016-12-20 21:49:48 -05:00
2019-04-24 15:54:44 -04:00
``` go
2020-04-07 22:30:59 -04:00
users, err := madmClnt.ListUsers(context.Background());
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalln(err)
}
for k, v := range users {
fmt.Printf("User %s Status %s\n", k, v.Status)
}
```
2016-12-20 21:49:48 -05:00
2019-08-27 14:37:47 -04:00
## 9. Misc operations
2016-12-20 21:49:48 -05:00
2019-08-28 18:04:43 -04:00
< a name = "ServerUpdate" > < / a >
2020-04-07 22:30:59 -04:00
### ServerUpdate(ctx context.Context, updateURL string) (ServerUpdateStatus, error)
2019-08-28 18:04:43 -04:00
Sends a update command to MinIO server, to update MinIO server to latest release. In distributed setup it updates all servers atomically.
__Example__
```go
// Updates all servers and restarts all the servers in the cluster.
// optionally takes an updateURL, which is used to update the binary.
2020-04-07 22:30:59 -04:00
us, err := madmClnt.ServerUpdate(context.Background(), updateURL)
2019-08-28 18:04:43 -04:00
if err != nil {
log.Fatalln(err)
}
if us.CurrentVersion != us.UpdatedVersion {
log.Printf("Updated server version from %s to %s successfully", us.CurrentVersion, us.UpdatedVersion)
}
```
2019-04-24 15:54:44 -04:00
< a name = "StartProfiling" > < / a >
2020-04-07 22:30:59 -04:00
### StartProfiling(ctx context.Context, profiler string) error
2019-04-24 15:54:44 -04:00
Ask all nodes to start profiling using the specified profiler mode
__Example__
``` go
2020-04-07 22:30:59 -04:00
startProfilingResults, err = madmClnt.StartProfiling(context.Background(), "cpu")
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalln(err)
}
for _, result := range startProfilingResults {
if !result.Success {
log.Printf("Unable to start profiling on node `%s` , reason = `%s` \n", result.NodeName, result.Error)
} else {
log.Printf("Profiling successfully started on node `%s` \n", result.NodeName)
}
}
```
< a name = "DownloadProfilingData" > < / a >
2020-04-07 22:30:59 -04:00
### DownloadProfilingData(ctx context.Context) ([]byte, error)
2019-04-24 15:54:44 -04:00
Download profiling data of all nodes in a zip format.
__Example__
``` go
2020-04-07 22:30:59 -04:00
profilingData, err := madmClnt.DownloadProfilingData(context.Background())
2019-04-24 15:54:44 -04:00
if err != nil {
log.Fatalln(err)
}
profilingFile, err := os.Create("/tmp/profiling-data.zip")
if err != nil {
log.Fatal(err)
}
if _, err := io.Copy(profilingFile, profilingData); err != nil {
log.Fatal(err)
}
if err := profilingFile.Close(); err != nil {
log.Fatal(err)
}
if err := profilingData.Close(); err != nil {
log.Fatal(err)
}
log.Println("Profiling data successfully downloaded.")
```
2019-09-04 16:19:44 -04:00
## 11. KMS
2019-09-13 19:34:34 -04:00
< a name = "GetKeyStatus" > < / a >
2020-04-07 22:30:59 -04:00
### GetKeyStatus(ctx context.Context, keyID string) (*KMSKeyStatus, error)
2019-09-04 16:19:44 -04:00
Requests status information about one particular KMS master key
from a MinIO server. The keyID is optional and the server will
2019-10-23 01:59:13 -04:00
use the default master key (configured via `MINIO_KMS_VAULT_KEY_NAME`
or `MINIO_KMS_MASTER_KEY` ) if the keyID is empty.
2019-09-04 16:19:44 -04:00
__Example__
``` go
2020-04-07 22:30:59 -04:00
keyInfo, err := madmClnt.GetKeyStatus(context.Background(), "my-minio-key")
2019-09-04 16:19:44 -04:00
if err != nil {
log.Fatalln(err)
}
if keyInfo.EncryptionErr != "" {
log.Fatalf("Failed to perform encryption operation using '%s': %v\n", keyInfo.KeyID, keyInfo.EncryptionErr)
}
if keyInfo.UpdateErr != "" {
log.Fatalf("Failed to perform key re-wrap operation using '%s': %v\n", keyInfo.KeyID, keyInfo.UpdateErr)
}
if keyInfo.DecryptionErr != "" {
log.Fatalf("Failed to perform decryption operation using '%s': %v\n", keyInfo.KeyID, keyInfo.DecryptionErr)
}
```