mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
fix: allow accountInfo, addUser and getUserInfo implicit (#10978)
- accountInfo API that returns information about user, access to buckets and the size per bucket - addUser - user is allowed to change their secretKey - getUserInfo - returns user info if the incoming is the same user requesting their information
This commit is contained in:
@@ -47,7 +47,7 @@ func main() {
|
||||
|:------------------------------------|:-----------------------------------------|:-------------------|:--------------------------|
|
||||
| [`ServiceTrace`](#ServiceTrace) | [`ServerInfo`](#ServerInfo) | [`Heal`](#Heal) | [`GetConfig`](#GetConfig) |
|
||||
| [`ServiceStop`](#ServiceStop) | [`StorageInfo`](#StorageInfo) | | [`SetConfig`](#SetConfig) |
|
||||
| [`ServiceRestart`](#ServiceRestart) | [`AccountUsageInfo`](#AccountUsageInfo) | | |
|
||||
| [`ServiceRestart`](#ServiceRestart) | [`AccountInfo`](#AccountInfo) | | |
|
||||
|
||||
|
||||
|
||||
@@ -251,16 +251,16 @@ __Example__
|
||||
|
||||
```
|
||||
|
||||
<a name="AccountUsageInfo"></a>
|
||||
<a name="AccountInfo"></a>
|
||||
|
||||
### AccountUsageInfo(ctx context.Context) (AccountUsageInfo, error)
|
||||
### AccountInfo(ctx context.Context) (AccountInfo, error)
|
||||
|
||||
Fetches accounting usage information for the current authenticated user
|
||||
|
||||
| Param | Type | Description |
|
||||
|--------------------------------|----------------------|-------------------------|
|
||||
| `AccountUsageInfo.AccountName` | _string_ | Account name. |
|
||||
| `AccountUsageInfo.Buckets` | _[]BucketUsageInfo_ | Bucket usage info. |
|
||||
| `AccountInfo.AccountName` | _string_ | Account name. |
|
||||
| `AccountInfo.Buckets` | _[]BucketUsageInfo_ | Bucket usage info. |
|
||||
|
||||
|
||||
| Param | Type | Description |
|
||||
@@ -281,12 +281,12 @@ __Example__
|
||||
|
||||
```go
|
||||
|
||||
accountUsageInfo, err := madmClnt.AccountUsageInfo(context.Background())
|
||||
accountInfo, err := madmClnt.AccountInfo(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
log.Println(accountUsageInfo)
|
||||
log.Println(accountInfo)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
accountUsageInfo, err := madmClnt.AccountUsageInfo(context.Background())
|
||||
accountInfo, err := madmClnt.AccountInfo(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
log.Println(accountUsageInfo)
|
||||
log.Println(accountInfo)
|
||||
}
|
||||
@@ -44,37 +44,38 @@ type BucketUsageInfo struct {
|
||||
Access AccountAccess `json:"access"`
|
||||
}
|
||||
|
||||
// AccountUsageInfo represents the account usage info of an
|
||||
// AccountInfo represents the account usage info of an
|
||||
// account across buckets.
|
||||
type AccountUsageInfo struct {
|
||||
type AccountInfo struct {
|
||||
AccountName string
|
||||
Policy iampolicy.Policy
|
||||
Buckets []BucketUsageInfo
|
||||
}
|
||||
|
||||
// AccountUsageInfo returns the usage info for the authenticating account.
|
||||
func (adm *AdminClient) AccountUsageInfo(ctx context.Context) (AccountUsageInfo, error) {
|
||||
resp, err := adm.executeMethod(ctx, http.MethodGet, requestData{relPath: adminAPIPrefix + "/accountusageinfo"})
|
||||
// AccountInfo returns the usage info for the authenticating account.
|
||||
func (adm *AdminClient) AccountInfo(ctx context.Context) (AccountInfo, error) {
|
||||
resp, err := adm.executeMethod(ctx, http.MethodGet, requestData{relPath: adminAPIPrefix + "/accountinfo"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return AccountUsageInfo{}, err
|
||||
return AccountInfo{}, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return AccountUsageInfo{}, httpRespToErrorResponse(resp)
|
||||
return AccountInfo{}, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var accountInfo AccountUsageInfo
|
||||
var accountInfo AccountInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return AccountUsageInfo{}, err
|
||||
return AccountInfo{}, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &accountInfo)
|
||||
if err != nil {
|
||||
return AccountUsageInfo{}, err
|
||||
return AccountInfo{}, err
|
||||
}
|
||||
|
||||
return accountInfo, nil
|
||||
|
||||
Reference in New Issue
Block a user