minoss

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 8 Imported by: 0

README

minoss

MinIO OSS wrapper

Documentation

Index

Constants

View Source
const (
	EffectAllow = "Allow"
	EffectDeny  = "Deny"
)
View Source
const (
	OctetStream = "application/octet-stream"
)

Variables

This section is empty.

Functions

func DefaultGetObjectOptions

func DefaultGetObjectOptions() minio.GetObjectOptions

func DefaultPublicPolicy added in v0.2.0

func DefaultPublicPolicy(bucket string) string

func DefaultPutObjectOptions

func DefaultPutObjectOptions() minio.PutObjectOptions

func DefaultRemoveOptions

func DefaultRemoveOptions() minio.RemoveObjectOptions

Types

type MinOSS

type MinOSS struct {
	// contains filtered or unexported fields
}

func NewMinOSS

func NewMinOSS(opt Option) *MinOSS

func (*MinOSS) AdminAddUser

func (m *MinOSS) AdminAddUser(ctx context.Context, accessKey, secretKey string) (err error)

AdminAddUser add user

func (*MinOSS) AdminClient

func (m *MinOSS) AdminClient() *madmin.AdminClient

AdminClient returns minio admin client

func (*MinOSS) AdminGetBucketsUsage

func (m *MinOSS) AdminGetBucketsUsage(ctx context.Context) (buckets map[string]madmin.BucketUsageInfo, err error)

AdminGetBucketsUsage get all buckets usage information

func (*MinOSS) AdminGetDataUsage

func (m *MinOSS) AdminGetDataUsage(ctx context.Context) (usage madmin.DataUsageInfo, err error)

AdminGetDataUsage get total data usage information

func (*MinOSS) AdminGetQuota

func (m *MinOSS) AdminGetQuota(ctx context.Context, bucket string) (MiB float64, err error)

AdminGetQuota get bucket quota (MiB)

func (*MinOSS) AdminGetServerInfo

func (m *MinOSS) AdminGetServerInfo(ctx context.Context) (info madmin.InfoMessage, err error)

AdminGetServerInfo get server information

func (*MinOSS) AdminGetStorageDetails

func (m *MinOSS) AdminGetStorageDetails() (details map[string]StorageDetails, err error)

AdminGetStorageDetails get all instance storage details

func (*MinOSS) AdminGetStorageInfo

func (m *MinOSS) AdminGetStorageInfo(ctx context.Context) (info madmin.StorageInfo, err error)

AdminGetStorageInfo get storage information

func (*MinOSS) AdminGetStorageUsage

func (m *MinOSS) AdminGetStorageUsage(ctx context.Context) (usage StorageUsage, err error)

AdminGetStorageUsage get storage usage information

func (*MinOSS) AdminRemoveUser

func (m *MinOSS) AdminRemoveUser(ctx context.Context, accessKey string) (err error)

AdminRemoveUser delete user

func (*MinOSS) AdminSetPolicy

func (m *MinOSS) AdminSetPolicy(ctx context.Context, accessKey, policyName string, isGroup bool) (err error)

AdminSetPolicy set the policy by access key

func (*MinOSS) AdminSetQuota

func (m *MinOSS) AdminSetQuota(ctx context.Context, bucket string, MiB int64) (err error)

AdminSetQuota set bucket quota in hard mode (MiB)

func (*MinOSS) AdminSetUserStatus

func (m *MinOSS) AdminSetUserStatus(ctx context.Context, accessKey string, status madmin.AccountStatus) (err error)

AdminSetUserStatus set user status (enabled or disabled)

func (*MinOSS) DownloadObject

func (m *MinOSS) DownloadObject(ctx context.Context, bucket, objname string, writer io.Writer, options ...minio.GetObjectOptions) (written int64, err error)

DownloadObject downloads an object

func (*MinOSS) DownloadObject2File added in v0.3.0

func (m *MinOSS) DownloadObject2File(ctx context.Context, bucket, objname, filepath string, options ...minio.GetObjectOptions) (err error)

DownloadObject2File downloads an object write to file

func (*MinOSS) GetBucketPolicy added in v0.2.0

func (m *MinOSS) GetBucketPolicy(ctx context.Context, bucket string) (string, error)

func (*MinOSS) GetObjectList

func (m *MinOSS) GetObjectList(ctx context.Context, bucket string) (objects []*minio.ObjectInfo, err error)

GetObjectList get bucket all objects

func (*MinOSS) ListBuckets

func (m *MinOSS) ListBuckets(ctx context.Context) (buckets []minio.BucketInfo, err error)

ListBuckets list all buckets

func (*MinOSS) MakeBucket

func (m *MinOSS) MakeBucket(ctx context.Context, bucket string) (err error)

MakeBucket create a bucket

func (*MinOSS) Option

func (m *MinOSS) Option() Option

Option return current OSS option

func (*MinOSS) RemoveBucketPolicy added in v0.2.0

func (m *MinOSS) RemoveBucketPolicy(ctx context.Context, bucket string) error

func (*MinOSS) RemoveObject

func (m *MinOSS) RemoveObject(ctx context.Context, bucket, objname string, options ...minio.RemoveObjectOptions) (err error)

RemoveObject remove object from bucket

func (*MinOSS) SearchObject

func (m *MinOSS) SearchObject(ctx context.Context, bucket, prefix string, recursive bool) (objects []*minio.ObjectInfo, total int64)

SearchObject search objects by bucket and file prefix

func (*MinOSS) SetBucketPolicy added in v0.2.0

func (m *MinOSS) SetBucketPolicy(ctx context.Context, bucket, policy string) error

func (*MinOSS) SetBucketPublicPolicy added in v0.2.0

func (m *MinOSS) SetBucketPublicPolicy(ctx context.Context, bucket string) error

SetBucketPublicPolicy sets the bucket to public read policy aims for file downloads directly from oss endpoint

func (*MinOSS) UploadObject

func (m *MinOSS) UploadObject(ctx context.Context, bucket, objname string, object io.Reader, options ...minio.PutObjectOptions) (err error)

UploadObject uploads an object to bucket

func (*MinOSS) UploadObjectFromFile added in v0.3.0

func (m *MinOSS) UploadObjectFromFile(ctx context.Context, bucket, objname, filepath string, options ...minio.PutObjectOptions) (err error)

UploadObjectFromFile uploads an object from file to bucket

func (*MinOSS) UserClient

func (m *MinOSS) UserClient() *minio.Client

UserClient returns minio user client

type Option

type Option struct {
	Endpoint  string `json:"endpoint"`
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
	Bucket    string `json:"bucket"`
	Region    Region `json:"region"`
	Token     string `json:"token"`
	Secure    bool   `json:"secure"`
}

type Policy added in v0.2.0

type Policy struct {
	Version   string      `json:"Version"`
	Statement []Statement `json:"Statement"`
}

type Region

type Region string
const (
	RegionUSEast1      Region = "us-east-1"
	RegionUSEast2      Region = "us-east-2"
	RegionUSWest1      Region = "us-west-1"
	RegionUSWest2      Region = "us-west-2"
	RegionCACentral1   Region = "ca-central-1"
	RegionEUWest1      Region = "eu-west-1"
	RegionEUWest2      Region = "eu-west-2"
	RegionEUWest3      Region = "eu-west-3"
	RegionEUCentral1   Region = "eu-central-1"
	RegionEUNorth1     Region = "eu-north-1"
	RegionAPEast1      Region = "ap-east-1"
	RegionAPSouth1     Region = "ap-south-1"
	RegionAPSoutheast1 Region = "ap-southeast-1"
	RegionAPSoutheast2 Region = "ap-southeast-2"
	RegionAPNortheast1 Region = "ap-northeast-1"
	RegionAPNortheast2 Region = "ap-northeast-2"
	RegionAPNortheast3 Region = "ap-northeast-3"
	RegionMESouth1     Region = "me-south-1"
	RegionSAEast1      Region = "sa-east-1"
	RegionUSGovWest1   Region = "us-gov-west-1"
	RegionUSGovEast1   Region = "us-gov-east-1"
	RegionCNNorth1     Region = "cn-north-1"
	RegionCNNorthwest1 Region = "cn-northwest-1"
)

type Statement added in v0.2.0

type Statement struct {
	Effect    string `json:"Effect"`
	Principal struct {
		AWS []string `json:"AWS"`
	} `json:"Principal"`
	Action   []string `json:"Action"`
	Resource []string `json:"Resource"`
}

type StorageDetails

type StorageDetails struct {
	Offline   uint64        `json:"offline"`
	Available uint64        `json:"available"`
	Online    uint64        `json:"online"`
	Disks     []StorageDisk `json:"disks"`
}

type StorageDisk

type StorageDisk struct {
	DeviceName        string `json:"device_name"`
	DeviceSN          string `json:"device_sn"`
	Instance          string `json:"instance"`
	TotalCapacity     uint64 `json:"total_capacity"`
	AvailableCapacity uint64 `json:"available_capacity"`
	OK                bool   `json:"ok"`
}

type StorageUsage

type StorageUsage struct {
	Used      uint64 `json:"used"`
	Available uint64 `json:"available"`
	Total     uint64 `json:"total"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL