mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
api: Implement About API.
This commit is contained in:
parent
a1c6e4055b
commit
e63a982dee
@ -26,6 +26,9 @@ type MakeBucketArgs struct {
|
|||||||
// DiskInfoArgs - disk info args.
|
// DiskInfoArgs - disk info args.
|
||||||
type DiskInfoArgs struct{}
|
type DiskInfoArgs struct{}
|
||||||
|
|
||||||
|
// ServerInfoArgs - server info args.
|
||||||
|
type ServerInfoArgs struct{}
|
||||||
|
|
||||||
// ListBucketsArgs - list bucket args.
|
// ListBucketsArgs - list bucket args.
|
||||||
type ListBucketsArgs struct{}
|
type ListBucketsArgs struct{}
|
||||||
|
|
||||||
@ -35,6 +38,20 @@ type ListObjectsArgs struct {
|
|||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutObjectURLArgs - args to generate url for upload access.
|
||||||
|
type PutObjectURLArgs struct {
|
||||||
|
TargetHost string `json:"targetHost"`
|
||||||
|
BucketName string `json:"bucketName"`
|
||||||
|
ObjectName string `json:"objectName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetObjectURLArgs - args to generate url for download access.
|
||||||
|
type GetObjectURLArgs struct {
|
||||||
|
TargetHost string `json:"targetHost"`
|
||||||
|
BucketName string `json:"bucketName"`
|
||||||
|
ObjectName string `json:"objectName"`
|
||||||
|
}
|
||||||
|
|
||||||
// BucketInfo container for list buckets metadata.
|
// BucketInfo container for list buckets metadata.
|
||||||
type BucketInfo struct {
|
type BucketInfo struct {
|
||||||
// The name of the bucket.
|
// The name of the bucket.
|
||||||
@ -55,27 +72,21 @@ type ObjectInfo struct {
|
|||||||
ContentType string `json:"contentType"`
|
ContentType string `json:"contentType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutObjectURLArgs - args to generate url for upload access.
|
|
||||||
type PutObjectURLArgs struct {
|
|
||||||
TargetHost string `json:"targetHost"`
|
|
||||||
BucketName string `json:"bucketName"`
|
|
||||||
ObjectName string `json:"objectName"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetObjectURLArgs - args to generate url for download access.
|
|
||||||
type GetObjectURLArgs struct {
|
|
||||||
TargetHost string `json:"targetHost"`
|
|
||||||
BucketName string `json:"bucketName"`
|
|
||||||
ObjectName string `json:"objectName"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AuthToken - auth token reply
|
|
||||||
type AuthToken struct {
|
|
||||||
Token string `json:"token" form:"token"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoginArgs - login arguments.
|
// LoginArgs - login arguments.
|
||||||
type LoginArgs struct {
|
type LoginArgs struct {
|
||||||
Username string `json:"username" form:"username"`
|
Username string `json:"username" form:"username"`
|
||||||
Password string `json:"password" form:"password"`
|
Password string `json:"password" form:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuthToken - auth token reply.
|
||||||
|
type AuthToken struct {
|
||||||
|
Token string `json:"token" form:"token"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerInfo - server info reply.
|
||||||
|
type ServerInfo struct {
|
||||||
|
MinioVersion string
|
||||||
|
MinioMemory string
|
||||||
|
MinioPlatform string
|
||||||
|
MinioRuntime string
|
||||||
|
}
|
||||||
|
@ -20,10 +20,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jwtgo "github.com/dgrijalva/jwt-go"
|
jwtgo "github.com/dgrijalva/jwt-go"
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/minio/minio-go"
|
"github.com/minio/minio-go"
|
||||||
"github.com/minio/minio-xl/pkg/probe"
|
"github.com/minio/minio-xl/pkg/probe"
|
||||||
"github.com/minio/minio/pkg/disk"
|
"github.com/minio/minio/pkg/disk"
|
||||||
@ -45,6 +49,36 @@ func isAuthenticated(req *http.Request) bool {
|
|||||||
return tokenRequest.Valid
|
return tokenRequest.Valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerInfo - get server info.
|
||||||
|
func (web *WebAPI) ServerInfo(r *http.Request, args *ServerInfoArgs, reply *ServerInfo) error {
|
||||||
|
if !isAuthenticated(r) {
|
||||||
|
return errUnAuthorizedRequest
|
||||||
|
}
|
||||||
|
host, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
host = ""
|
||||||
|
}
|
||||||
|
memstats := &runtime.MemStats{}
|
||||||
|
runtime.ReadMemStats(memstats)
|
||||||
|
mem := fmt.Sprintf("Used: %s | Allocated: %s | Used-Heap: %s | Allocated-Heap: %s",
|
||||||
|
humanize.Bytes(memstats.Alloc),
|
||||||
|
humanize.Bytes(memstats.TotalAlloc),
|
||||||
|
humanize.Bytes(memstats.HeapAlloc),
|
||||||
|
humanize.Bytes(memstats.HeapSys))
|
||||||
|
platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s",
|
||||||
|
host,
|
||||||
|
runtime.GOOS,
|
||||||
|
runtime.GOARCH)
|
||||||
|
goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU()))
|
||||||
|
serverInfo := ServerInfo{}
|
||||||
|
serverInfo.MinioVersion = minioVersion
|
||||||
|
serverInfo.MinioMemory = mem
|
||||||
|
serverInfo.MinioPlatform = platform
|
||||||
|
serverInfo.MinioRuntime = goruntime
|
||||||
|
*reply = serverInfo
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// DiskInfo - get disk statistics.
|
// DiskInfo - get disk statistics.
|
||||||
func (web *WebAPI) DiskInfo(r *http.Request, args *DiskInfoArgs, reply *disk.Info) error {
|
func (web *WebAPI) DiskInfo(r *http.Request, args *DiskInfoArgs, reply *disk.Info) error {
|
||||||
if !isAuthenticated(r) {
|
if !isAuthenticated(r) {
|
||||||
|
Loading…
Reference in New Issue
Block a user