Giter VIP home page Giter VIP logo

madmin-go's Introduction

Golang Admin Client API Reference 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.

Initialize MinIO Admin Client object.

MinIO

package main

import (
    "fmt"

    "github.com/minio/madmin-go/v3"
)

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.ServerInfo()
    if err != nil {
        fmt.Println(err)
        return
    }
	for _, peerInfo := range serversInfo {
		log.Printf("Node: %s, Info: %v\n", peerInfo.Addr, peerInfo.Data)
	}
}
Service operations Info operations Healing operations Config operations
ServiceTrace ServerInfo Heal GetConfig
ServiceStop StorageInfo SetConfig
ServiceRestart AccountInfo
Top operations IAM operations Misc KMS
TopLocks AddUser StartProfiling GetKeyStatus
SetPolicy DownloadProfilingData
ListUsers ServerUpdate
AddCannedPolicy

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(ctx context.Context) (ServiceStatusMetadata, error)

Fetch service status, replies disk space used, backend type and total disks offline/online (applicable in distributed mode).

Param Type Description
serviceStatus ServiceStatusMetadata Represents current server status info in following format:
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.

Example

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

ServiceRestart(ctx context.Context) error

Sends a service action restart command to MinIO server.

Example

   // To restart the service, restarts all servers in the cluster.
   err := madmClnt.ServiceRestart(context.Background())
   if err != nil {
       log.Fatalln(err)
   }
   log.Println("Success")

ServiceStop(ctx context.Context) error

Sends a service action stop command to MinIO server.

Example

   // To stop the service, stops all servers in the cluster.
   err := madmClnt.ServiceStop(context.Background())
   if err != nil {
       log.Fatalln(err)
   }
   log.Println("Success")

ServiceTrace(ctx context.Context, allTrace bool, doneCh <-chan struct{}) <-chan TraceInfo

Enable HTTP request tracing on all nodes in a MinIO cluster

Example

    doneCh := make(chan struct{})
    defer close(doneCh)
    // listen to all trace including internal API calls
    allTrace := true
    // Start listening on all trace activity.
    traceCh := madmClnt.ServiceTrace(context.Background(), allTrace, doneCh)
    for traceInfo := range traceCh {
        fmt.Println(traceInfo.String())
    }

3. Info operations

ServerInfo(ctx context.Context) ([]ServerInfo, error)

Fetches information for all cluster nodes, such as server properties, storage information, network statistics, etc.

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.
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

   serversInfo, err := madmClnt.ServerInfo(context.Background())
   if err != nil {
   	log.Fatalln(err)
   }

   for _, peerInfo := range serversInfo {
   	log.Printf("Node: %s, Info: %v\n", peerInfo.Addr, peerInfo.Data)
   }

StorageInfo(ctx context.Context) (StorageInfo, error)

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.StandardSCParity int Parity disks set for standard 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

   storageInfo, err := madmClnt.StorageInfo(context.Background())
   if err != nil {
   	log.Fatalln(err)
   }

   log.Println(storageInfo)

AccountInfo(ctx context.Context) (AccountInfo, error)

Fetches accounting usage information for the current authenticated user

Param Type Description
AccountInfo.AccountName string Account name.
AccountInfo.Buckets []BucketAccessInfo Bucket usage info.
Param Type Description
BucketAccessInfo.Name string The name of the current bucket
BucketAccessInfo.Size uint64 The total size of the current bucket
BucketAccessInfo.Created time.Time Bucket creation time
BucketAccessInfo.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

   accountInfo, err := madmClnt.AccountInfo(context.Background())
   if err != nil {
	log.Fatalln(err)
   }

   log.Println(accountInfo)

5. Heal operations

Heal(ctx context.Context, bucket, prefix string, healOpts HealOpts, clientToken string, forceStart bool, forceStop bool) (start HealStartSuccess, status HealTaskStatus, err error)

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

    opts := madmin.HealOpts{
            Recursive: true,
            DryRun:    false,
    }
    forceStart := false
    forceStop := false
    healPath, err := madmClnt.Heal(context.Background(), "", "", opts, "", forceStart, forceStop)
    if err != nil {
        log.Fatalln(err)
    }
    log.Printf("Heal sequence started at %s", healPath)

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
l

6. Config operations

GetConfig(ctx context.Context) ([]byte, error)

Get current config.json of a MinIO server.

Example

    configBytes, err := madmClnt.GetConfig(context.Background())
    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()))

SetConfig(ctx context.Context, config io.Reader) error

Set a new config.json for a MinIO server.

Example

    config := bytes.NewReader([]byte(`config.json contents go here`))
    if err := madmClnt.SetConfig(context.Background(), config); err != nil {
        log.Fatalf("failed due to: %v", err)
    }
    log.Println("SetConfig was successful")

7. Top operations

TopLocks(ctx context.Context) (LockEntries, error)

Get the oldest locks from MinIO server.

Example

    locks, err := madmClnt.TopLocks(context.Background())
    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))

8. IAM operations

AddCannedPolicy(ctx context.Context, policyName string, policy *iampolicy.Policy) error

Create a new canned policy on MinIO server.

Example

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

    if err = madmClnt.AddCannedPolicy(context.Background(), "get-only", policy); err != nil {
		log.Fatalln(err)
	}

AddUser(ctx context.Context, user string, secret string) error

Add a new user on a MinIO server.

Example

	if err = madmClnt.AddUser(context.Background(), "newuser", "newstrongpassword"); err != nil {
		log.Fatalln(err)
	}

SetPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error

Enable a canned policy get-only for a given user or group on MinIO server.

Example

	if err = madmClnt.SetPolicy(context.Background(), "get-only", "newuser", false); err != nil {
		log.Fatalln(err)
	}

ListUsers(ctx context.Context) (map[string]UserInfo, error)

Lists all users on MinIO server.

Example

	users, err := madmClnt.ListUsers(context.Background());
    if err != nil {
		log.Fatalln(err)
	}
    for k, v := range users {
        fmt.Printf("User %s Status %s\n", k, v.Status)
    }

9. Misc operations

ServerUpdate(ctx context.Context, updateURL string) (ServerUpdateStatus, error)

Sends a update command to MinIO server, to update MinIO server to latest release. In distributed setup it updates all servers atomically.

Example

   // Updates all servers and restarts all the servers in the cluster.
   // optionally takes an updateURL, which is used to update the binary.
   us, err := madmClnt.ServerUpdate(context.Background(), updateURL)
   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)
   }

StartProfiling(ctx context.Context, profiler string) error

Ask all nodes to start profiling using the specified profiler mode

Example

    startProfilingResults, err = madmClnt.StartProfiling(context.Background(), "cpu")
    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)
        }
    }

DownloadProfilingData(ctx context.Context) ([]byte, error)

Download profiling data of all nodes in a zip format.

Example

    profilingData, err := madmClnt.DownloadProfilingData(context.Background())
    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.")

11. KMS

GetKeyStatus(ctx context.Context, keyID string) (*KMSKeyStatus, error)

Requests status information about one particular KMS master key from a MinIO server. The keyID is optional and the server will use the default master key (configured via MINIO_KMS_VAULT_KEY_NAME or MINIO_KMS_MASTER_KEY) if the keyID is empty.

Example

    keyInfo, err := madmClnt.GetKeyStatus(context.Background(), "my-minio-key")
    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)
    }

License

All versions of this SDK starting from v2.0.0 are distributed under the GNU AGPLv3 license that can be found in the LICENSE file.

madmin-go's People

Contributors

aead avatar alevsk avatar anjalshireesh avatar balamurugana avatar cesnietor avatar donatello avatar dvaldivia avatar emirisman avatar gibmat avatar harshavardhana avatar jiuker avatar jy-kkkim avatar kaankabalak avatar klauspost avatar krishnasrinivas avatar krisis avatar marktheunissen avatar moting9 avatar mrusme avatar paytonward6 avatar pjuarezd avatar poornas avatar praveenrajmani avatar ravindk89 avatar reivaj05 avatar shtripat avatar sinhaashish avatar taran-p avatar vadmeste avatar wlan0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

madmin-go's Issues

use madmin.ServerInfo to get the number of bucket reads and writes

Hi,
First and foremost, thanks for providing this super useful pkg.
I want to get the number of reads and writes of the bucket through the madmin.ServerInfo interface,But I don't know which parameter I need."ReadVersion" always changes when I read and write files to the bucket, but other numbers don't change
image
What can I do to get the results I want?

Group Management

It seems like the SDK does not yet contain methods for group management.

I'd expect to see:

  • AddGroup
  • RemoveGroup

Memory Issues with ListUsers

Hi,

I saw a high memory consumption in our go application that uses the minio admin sdk. I tracked it down to the ListUsers function. It seems the results are not properly garbage collected with multiple calls.

Here is a code snippet and the memory consumption:

ctx := context.Background()
for i := 1; i <= 10; i++ {
    PrintMemUsage()
    _, err := r.MinioAdminClient.ListUsers(ctx)
    if err != nil {
	return nil, err
    }
}

Memory usages:
Alloc = 99 MiB TotalAlloc = 123 MiB Sys = 139 MiB NumGC = 9
Alloc = 92 MiB TotalAlloc = 189 MiB Sys = 206 MiB NumGC = 10
Alloc = 156 MiB TotalAlloc = 253 MiB Sys = 206 MiB NumGC = 10
Alloc = 156 MiB TotalAlloc = 253 MiB Sys = 206 MiB NumGC = 10
Alloc = 156 MiB TotalAlloc = 253 MiB Sys = 206 MiB NumGC = 10
Alloc = 220 MiB TotalAlloc = 317 MiB Sys = 272 MiB NumGC = 11
Alloc = 220 MiB TotalAlloc = 318 MiB Sys = 272 MiB NumGC = 11
Alloc = 284 MiB TotalAlloc = 382 MiB Sys = 338 MiB NumGC = 11
Alloc = 284 MiB TotalAlloc = 382 MiB Sys = 338 MiB NumGC = 11
Alloc = 284 MiB TotalAlloc = 382 MiB Sys = 338 MiB NumGC = 11

Can this be investigated?

Question: Generate user (session?) policy document

Hi,

In the UI, when creating a personal service account, the option exists to generate the session policy document, edit it, and attach it to the service account.

We have MinIO authentication and authorisation using LDAP and policies on LDAP groups. That works nicely.

Sometimes users join new LDAP groups and therefore get updated session policies. For automation purposes (secret rotation) we would like to update existing service accounts (system wide but user specific) with new policy documents. These new policy documents should be generated by MinIO similar to what the UI does. That way we can update and/or rotate existing/new service accounts with the current complete policy document.

However, using minio admin go client:
mc admin user policy myminio "CN=Hartwig\, Jonas (cvv556),OU=...." I get the following error: mc: <ERROR> Unable to fetch user policy document. Policy not found for user CN=Hartwig\, Jonas (cvv556),OU=.... When using the minio admin go client, create a service account without policy attached, retrieve it and investigate it, it is shown as implied/empty policy. That also makes sense.

Another use case for admins would be to debug the policies. The setup might be quite complex of policies assigned to users and groups. The resulting policy document might be conflicting. It would be helpful to understand a user policy in case of complains.

Now here is what I need: How can I get this implied policy document?

Regards

License clarification

Version 2.0.0 switched the license over to AGPL-3, but a handful of files still list Apache-2 as their license.

For example, in cpu_linux.go:

//
// Copyright (c) 2015-2022 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

//go:build linux
// +build linux

//
// MinIO Object Storage (c) 2021-2022 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

(You can find all such files via grep -ri apache.)

Is this an oversight, or are the affected files dual-licensed?

AddCannedPolicy does not accept Policy type

Hi,

First and foremost, thanks for providing this super useful pkg.

If I follow the example you provided for adding a policy, which is the following:

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)
}
if err = madmClnt.AddCannedPolicy(context.Background(), "get-only", policy); err != nil {
       log.Fatalln(err)
}

The policy is given as Policy type whereas in the function implementation it is expecting []bytes:

func (adm *AdminClient) AddCannedPolicy(ctx context.Context, policyName string, policy []byte) error

I'm using the pkg github.com/minio/pkg/iam/policy to parse my policies, therefore I could notice that there is a function that I can use to convert back the policy to JSON in []bytes:

func (policy Policy) MarshalJSON() ([]byte, error) {
	if err := policy.isValid(); err != nil {
		return nil, err
	}

	// subtype to avoid recursive call to MarshalJSON()
	type subPolicy Policy
	return json.Marshal(subPolicy(policy))
}

However, when I try to use it I get this error:

policy.MarshalJSON undefined (type *iampolicy.Policy has no field or method MarshalJSON)

I relay on the policy pkg to do other actions (e.g isValid ); Therefore workarounds like creating directly the policy in []bytes format (see below) would not work for me.

    policyBytes := []byte(fmt.Sprintf(`{
        "Version": "2012-10-17",
        "Statement": [
         {
          "Effect": "Allow",
          "Action": [
           "s3:PutObject",
           "s3:GetObject",
           "s3:ListBucket"
          ],
          "Resource": [
           "arn:aws:s3:::%s/*"
          ]
         }
        ]
       }`, "bucket"))

Any help on how to convert Policy to []bytes?

Regards,
Salim.

go 1.17
github.com/minio/madmin-go v1.1.23
github.com/minio/pkg v1.1.11

Backward compatibility for ServiceStop

Hi,

One of the recent commits removed the ServiceStop function.

Was this intentional or can it be moved back in?
This commit added the option to be able to call the new V2 endpoint using the old ServiceStop instead of ServiceStopV2 which looks reasonable to me.

Thanks!

AddUser() method name

In fact behaviour of this method depends if user already exists or not, and in 1st case it will just update his secret key (and status). Thus, for more transparency would be better maybe to change it to e.g CreateOrUpdateUser? Or at least add additional comment up of the method definition.

func (adm *AdminClient) AddUser(ctx context.Context, accessKey, secretKey string) error {

How to use SetBucketQuota?

Hi,
I would like to use the SetBucketQuota function to impose a usage limit on a bucket.
I checked the bucket-quota.go file in the example folder, and that method does not apply.

Here's what I've tried:

	var kiB int64 = 1 << 10
	ctx := context.Background()
	// set bucket quota config
	if err := madmClnt.SetBucketQuota(ctx, "bucket-name", 64*kiB, HardQuota); err != nil {
		log.Fatalln(err)
	}

output error message:

: too many arguments in call to mdmClnt.SetBucketQuota
        have (context.Context, string, int64, QuotaType)
        want (context.Context, string, *madmin.BucketQuota)

How do I set it up? Help me..

`ListKeys` doesn't provide creation and algorithm information

The ListKeys method has the following signature:

func ListKeys(ctx context.Context, pattern string) ([]KMSKeyInfo, error)

type KMSKeyInfo struct {
	CreatedAt string `json:"createdAt"`
	CreatedBy string `json:"createdBy"`
	Name      string `json:"name"`
}

I noticed that CreatedAt and CreatedBy are always empty. After some investigation I found that the /minio/kms/v1/key/list?pattern=<pattern> handler (KMSListKeysHandler()) in cmd/kms-handlers.go only copies the name.

It would have made more sense to let this function return an array of key names ([]string) instead.

A bug of Speedtest API

When I use the Speedtest API to test, return a error:
This is my test code:

	res,err:=mdmClnt.Speedtest(context.Background(),madmin.SpeedtestOpts{
		Size:        102400,
		Concurrency: 0,
		Duration:    10*time.Second,
		Autotune:    true,
	})

err: json: cannot unmarshal array into Go value of type madmin.SpeedTestResult

`AddGroup` and `DeleteGroup` group management functions missing

It seems that the functionality for adding and removing groups is missing, despite functions for group member management and status being present. I would expect something like AddGroup and RemoveGroup to be present, since the CLI also provides these options.

SetUserReq does not set user policy provided in then AddOrUpdateUserReq

Hello I am trying to set the users policy when creating the user using SetUserReq

here is an example of what I am trying to do

addOrUpdateUserReq := madmin.AddOrUpdateUserReq{
	Policy:    `readwrite`,
	Status:    madmin.AccountEnabled,
	SecretKey: "passowrd123456",
}

if err := service.Client.SetUserReq(context, "exampleName", addOrUpdateUserReq); err != nil {
	logger.Error(err, "failed to create user")
}
```
I've also tried providing it as 

```
addOrUpdateUserReq := madmin.AddOrUpdateUserReq{
	Policy:    `["readwrite"]`,
	Status:    madmin.AccountEnabled,
	SecretKey: "passowrd123456",
}
```
still doesn't work

thank you in advance

Get the specified metrics because all BucketMetrics are too large

The metricsRespBodyLimit size is 10MB, but the actual data is 14MB>10MB, causing an error. Can I specify a metric to access? For example, minio_bucket_usage_total_bytes metric.

const (
	metricsRespBodyLimit = 10 << 20 // 10 MiB
)
// fetchMetrics - returns Metrics of given subsystem in Prometheus format
func (client *MetricsClient) fetchMetrics(ctx context.Context, subSystem string) ([]*prom2json.Family, error) {
	reqData := metricsRequestData{
		relativePath: "/v2/metrics/" + subSystem,
	}

	// Execute GET on /minio/v2/metrics/<subSys>
	resp, err := client.executeGetRequest(ctx, reqData)
	if err != nil {
		return nil, err
	}
	defer closeResponse(resp)

	if resp.StatusCode != http.StatusOK {
		return nil, httpRespToErrorResponse(resp)
	}

	return parsePrometheusResults(io.LimitReader(resp.Body, metricsRespBodyLimit))
}

Event notifications

i want to implement API for configuration notifications like Postgresql, MySql, Kafka, Redis and etc

the first integration is #294 for Postgresql

Unable to build with github.com/shirou/gopsutil/v3 v3.22.10

I am working on packaging this library for use in Debian, and have encountered the following build error when using github.com/shirou/gopsutil/v3 v3.22.10 (the current version of that library and recently updated in Debian):

# github.com/minio/madmin-go
src/github.com/minio/madmin-go/health.go:328:36: undefined: host.Warnings

It appears that commit shirou/gopsutil@dbc0f20 moved host/types.go -> internal/common/warnings.go.

How to remove a policy from a user?

I attach a policy to a user / group with

SetPolicy(ctx, policyName, entityName, isGroup)

How could I detach the permission from user / group?

Add new `replicate.source|target.path` to `mc batch generate` output

Expected behavior

mc batch generate play replicate should return the new path variable added in the MinIO Server RELEASE.2023-05-27T05-56-19Z release

Actual behavior

As of mc.RELEASE.2023-06-19 mc batch generate play replicate does not include the new path variable in the output

Steps to reproduce the behavior

> mc batch generate play replicate

replicate:
  apiVersion: v1
  # source of the objects to be replicated
  source:
    type: TYPE # valid values are "minio"
    bucket: BUCKET
    prefix: PREFIX # 'PREFIX' is optional
    # NOTE: if source is remote then target must be "local"
    # endpoint: ENDPOINT
    # credentials:
    #   accessKey: ACCESS-KEY
    #   secretKey: SECRET-KEY
    #   sessionToken: SESSION-TOKEN # Optional only available when rotating credentials are used

  # target where the objects must be replicated
  target:
    type: TYPE # valid values are "minio"
    bucket: BUCKET
    prefix: PREFIX # 'PREFIX' is optional
    # NOTE: if target is remote then source must be "local"
    # endpoint: ENDPOINT
    # credentials:
    #   accessKey: ACCESS-KEY
    #   secretKey: SECRET-KEY
    #   sessionToken: SESSION-TOKEN # Optional only available when rotating credentials are used

  # NOTE: All flags are optional
  # - filtering criteria only applies for all source objects match the criteria
  # - configurable notification endpoints
  # - configurable retries for the job (each retry skips successfully previously replaced objects)
  flags:
    filter:
      newerThan: "7d" # match objects newer than this value (e.g. 7d10h31s)
      olderThan: "7d" # match objects older than this value (e.g. 7d10h31s)
      createdAfter: "date" # match objects created after "date"
      createdBefore: "date" # match objects created before "date"

      ## NOTE: tags are not supported when "source" is remote.
      # tags:
      #   - key: "name"
      #     value: "pick*" # match objects with tag 'name', with all values starting with 'pick'

      ## NOTE: metadata filter not supported when "source" is non MinIO.
      # metadata:
      #   - key: "content-type"
      #     value: "image/*" # match objects with 'content-type', with all values starting with 'image/'

    notify:
      endpoint: "https://notify.endpoint" # notification endpoint to receive job status events
      token: "Bearer xxxxx" # optional authentication token for the notification endpoint

    retry:
      attempts: 10 # number of retries for the job before giving up
      delay: "500ms" # least amount of delay between each retry

mc --version

mc --version                                                                                                         ✔  docs   system   
mc version RELEASE.2023-06-19T19-31-19Z (commit-id=5f39522e69025bea6be0d350b65fdec2de2785c8)
Runtime: go1.19.10 linux/amd64
Copyright (c) 2015-2023 MinIO, Inc.
License GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>

System information

Manjaro 23.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.