right type used
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*
|
||||
* This work is published and licensed under a Creative Commons
|
||||
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
*
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
package auxuuid
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type UUID string
|
||||
|
||||
const ZeroUUID = "00000000-0000-0000-0000-000000000000"
|
||||
|
||||
func NewUUID() UUID {
|
||||
return UUID(uuid.New().String())
|
||||
}
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
|
||||
"mstore/app/handler"
|
||||
"mstore/app/operator"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (auxuuid.UUID, error) {
|
||||
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (uuid.UUID, error) {
|
||||
var err error
|
||||
var res auxuuid.UUID
|
||||
var res uuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
|
||||
if err != nil {
|
||||
@@ -54,7 +54,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.AccountShort, error) {
|
||||
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uuid.UUID) (*descr.AccountShort, error) {
|
||||
var err error
|
||||
res := &descr.AccountShort{}
|
||||
|
||||
@@ -121,7 +121,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID, newUsername, newPassword string) error {
|
||||
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uuid.UUID, newUsername, newPassword string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/update")
|
||||
@@ -215,7 +215,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) error {
|
||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uuid.UUID) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||
|
||||
+10
-9
@@ -16,13 +16,14 @@ import (
|
||||
|
||||
"mstore/app/handler"
|
||||
"mstore/app/operator"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID, right, pattern string) (auxuuid.UUID, error) {
|
||||
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID, right terms.Right, pattern string) (uuid.UUID, error) {
|
||||
var err error
|
||||
var res auxuuid.UUID
|
||||
var res uuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||
if err != nil {
|
||||
@@ -55,9 +56,9 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, a
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username, right, pattern string) (auxuuid.UUID, error) {
|
||||
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right terms.Right, pattern string) (uuid.UUID, error) {
|
||||
var err error
|
||||
var res auxuuid.UUID
|
||||
var res uuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||
if err != nil {
|
||||
@@ -90,7 +91,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username,
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.Grant, error) {
|
||||
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uuid.UUID) (*descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
|
||||
@@ -123,7 +124,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi string, id auxuuid.UUID
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID, newPattern string) error {
|
||||
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uuid.UUID, newPattern string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
|
||||
@@ -154,7 +155,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID auxu
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID) error {
|
||||
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uuid.UUID) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
|
||||
@@ -185,7 +186,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID auxu
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID) ([]descr.Grant, error) {
|
||||
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID) ([]descr.Grant, error) {
|
||||
var err error
|
||||
res := make([]descr.Grant, 0)
|
||||
|
||||
|
||||
+17
-17
@@ -10,27 +10,27 @@
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID auxuuid.UUID `json:"id" db:"id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Passhash string `json:"passhash" db:"passhash"`
|
||||
Disabled bool `json:"disabled" db:"disabled"`
|
||||
CreatedAt string `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt string `json:"updatedAt" db:"updated_at"`
|
||||
CreatedBy auxuuid.UUID `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy auxuuid.UUID `json:"updatedBy" db:"updated_by"`
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Passhash string `json:"passhash" db:"passhash"`
|
||||
Disabled bool `json:"disabled" db:"disabled"`
|
||||
CreatedAt string `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt string `json:"updatedAt" db:"updated_at"`
|
||||
CreatedBy uuid.UUID `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
|
||||
}
|
||||
|
||||
type AccountShort struct {
|
||||
ID auxuuid.UUID `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Disabled bool `json:"disabled"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
CreatedBy auxuuid.UUID `json:"createdBy"`
|
||||
UpdatedBy auxuuid.UUID `json:"updatedBy"`
|
||||
Grants []Grant `json:"grants"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Disabled bool `json:"disabled"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
CreatedBy uuid.UUID `json:"createdBy"`
|
||||
UpdatedBy uuid.UUID `json:"updatedBy"`
|
||||
Grants []Grant `json:"grants"`
|
||||
}
|
||||
|
||||
+11
-11
@@ -10,18 +10,18 @@
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type Blob struct {
|
||||
ID auxuuid.UUID `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Reference string `db:"reference" json:"reference"`
|
||||
MediaType string `db:"mediaType" json:"mediaType"`
|
||||
Digest string `db:"digest" json:"digest"`
|
||||
Size int64 `db:"size" json:"size"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Reference string `db:"reference" json:"reference"`
|
||||
MediaType string `db:"mediaType" json:"mediaType"`
|
||||
Digest string `db:"digest" json:"digest"`
|
||||
Size int64 `db:"size" json:"size"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
}
|
||||
|
||||
+11
-11
@@ -10,18 +10,18 @@
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
ID auxuuid.UUID `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
|
||||
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
|
||||
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"`
|
||||
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
|
||||
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
||||
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
||||
ID uuid.UUID `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
|
||||
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
|
||||
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"`
|
||||
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
|
||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
||||
}
|
||||
|
||||
+10
-9
@@ -11,16 +11,17 @@
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type Grant struct {
|
||||
ID auxuuid.UUID `json:"id" db:"id"`
|
||||
AccountID auxuuid.UUID `json:"accountID" db:"account_id"`
|
||||
Right string `json:"right" db:"right"`
|
||||
Pattern string `json:"pattern" db:"pattern"`
|
||||
CreatedAt string `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt string `json:"updatedAt" db:"updated_at"`
|
||||
CreatedBy auxuuid.UUID `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy auxuuid.UUID `json:"updatedBy" db:"updated_by"`
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
AccountID uuid.UUID `json:"accountID" db:"account_id"`
|
||||
Right terms.Right `json:"right" db:"right"`
|
||||
Pattern string `json:"pattern" db:"pattern"`
|
||||
CreatedAt string `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt string `json:"updatedAt" db:"updated_at"`
|
||||
CreatedBy uuid.UUID `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
|
||||
}
|
||||
|
||||
+11
-11
@@ -10,20 +10,20 @@
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type Manifest struct {
|
||||
ID auxuuid.UUID `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Reference string `db:"reference" json:"reference"`
|
||||
ContentType string `db:"contentType" json:"contentType"`
|
||||
Payload string `db:"payload" json:"-"`
|
||||
Digest string `db:"digest" json:"digest"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Reference string `db:"reference" json:"reference"`
|
||||
ContentType string `db:"contentType" json:"contentType"`
|
||||
Payload string `db:"payload" json:"-"`
|
||||
Digest string `db:"digest" json:"digest"`
|
||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
}
|
||||
|
||||
type Tags struct {
|
||||
|
||||
+15
-13
@@ -11,7 +11,7 @@
|
||||
package terms
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
type PathUsage string
|
||||
@@ -23,20 +23,22 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
AnonimousUsername string = "anonymous"
|
||||
AnonymousID auxuuid.UUID = "10000000-0000-0000-0000-000000000001"
|
||||
ServerUsername string = "server"
|
||||
ServerID auxuuid.UUID = "10000000-0000-0000-0000-000000000002"
|
||||
InitUsername string = "mstore"
|
||||
InitID auxuuid.UUID = "10000000-0000-0000-0000-000000000005"
|
||||
AnonimousUsername string = "anonymous"
|
||||
AnonymousID uuid.UUID = "10000000-0000-0000-0000-000000000001"
|
||||
ServerUsername string = "server"
|
||||
ServerID uuid.UUID = "10000000-0000-0000-0000-000000000002"
|
||||
InitUsername string = "mstore"
|
||||
InitID uuid.UUID = "10000000-0000-0000-0000-000000000005"
|
||||
)
|
||||
|
||||
type Right string
|
||||
|
||||
const (
|
||||
// Accounts, grants
|
||||
RightReadAccounts = "readAccounts" // GetAccount, ListAccounts
|
||||
RightWriteAccounts = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
|
||||
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles
|
||||
RightReadFiles = "readFiles" // PutFile, DeleteFile
|
||||
RightReadImages = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
|
||||
RightWriteImages = "writeImages" // other opearion
|
||||
RightReadAccounts Right = "readAccounts" // GetAccount, ListAccounts
|
||||
RightWriteAccounts Right = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
|
||||
RightWriteFiles Right = "writeFiles" // FileInfo, GetFile, ListFiles
|
||||
RightReadFiles Right = "readFiles" // PutFile, DeleteFile
|
||||
RightReadImages Right = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
|
||||
RightWriteImages Right = "writeImages" // other opearion
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user