uuid used
This commit is contained in:
+4
-2
@@ -13,8 +13,10 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type UUID string
|
||||
|
||||
const ZeroUUID = "00000000-0000-0000-0000-000000000000"
|
||||
|
||||
func NewUUID() string {
|
||||
return uuid.New().String()
|
||||
func NewUUID() UUID {
|
||||
return UUID(uuid.New().String())
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ import (
|
||||
|
||||
"mstore/app/handler"
|
||||
"mstore/app/operator"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (string, error) {
|
||||
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (auxuuid.UUID, error) {
|
||||
var err error
|
||||
var res string
|
||||
var res auxuuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
|
||||
if err != nil {
|
||||
@@ -53,7 +54,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) GetAccountByID(ctx context.Context, hosturi, id string) (*descr.AccountShort, error) {
|
||||
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.AccountShort, error) {
|
||||
var err error
|
||||
res := &descr.AccountShort{}
|
||||
|
||||
@@ -120,7 +121,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi, id, newUsername, newPassword string) error {
|
||||
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID, newUsername, newPassword string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/update")
|
||||
@@ -128,7 +129,6 @@ func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi, id, newUserna
|
||||
return err
|
||||
}
|
||||
operParams := operator.UpdateAccountParams{
|
||||
//Username: username,
|
||||
AccountID: id,
|
||||
NewUsername: newUsername,
|
||||
NewPassword: newPassword,
|
||||
@@ -215,7 +215,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi, id string) error {
|
||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||
|
||||
+9
-8
@@ -16,12 +16,13 @@ import (
|
||||
|
||||
"mstore/app/handler"
|
||||
"mstore/app/operator"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi, accountID, right, pattern string) (string, error) {
|
||||
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID, right, pattern string) (auxuuid.UUID, error) {
|
||||
var err error
|
||||
var res string
|
||||
var res auxuuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||
if err != nil {
|
||||
@@ -54,9 +55,9 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi, accountI
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username, right, pattern string) (string, error) {
|
||||
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username, right, pattern string) (auxuuid.UUID, error) {
|
||||
var err error
|
||||
var res string
|
||||
var res auxuuid.UUID
|
||||
|
||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||
if err != nil {
|
||||
@@ -89,7 +90,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username,
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) GetGrant(ctx context.Context, hosturi, id string) (*descr.Grant, error) {
|
||||
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
|
||||
@@ -122,7 +123,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi, id string) (*descr.Gra
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) UpdateGrant(ctx context.Context, hosturi, grantID, newPattern string) error {
|
||||
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID, newPattern string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
|
||||
@@ -153,7 +154,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi, grantID, newPattern
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteGrant(ctx context.Context, hosturi, grantID string) error {
|
||||
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
|
||||
@@ -184,7 +185,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi, grantID string) err
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi, accountID string) ([]descr.Grant, error) {
|
||||
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID) ([]descr.Grant, error) {
|
||||
var err error
|
||||
res := make([]descr.Grant, 0)
|
||||
|
||||
|
||||
+20
-17
@@ -7,27 +7,30 @@
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID string `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 string `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy string `json:"updatedBy" db:"updated_by"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type AccountShort struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Disabled bool `json:"disabled"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
Grants []Grant `json:"grants"`
|
||||
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"`
|
||||
}
|
||||
|
||||
+14
-10
@@ -9,15 +9,19 @@
|
||||
*/
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type Blob struct {
|
||||
ID string `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 string `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
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"`
|
||||
}
|
||||
|
||||
+14
-10
@@ -9,15 +9,19 @@
|
||||
*/
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
ID string `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 string `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
||||
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
||||
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"`
|
||||
}
|
||||
|
||||
+12
-8
@@ -10,13 +10,17 @@
|
||||
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type Grant struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
AccountID string `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 string `json:"createdBy" db:"created_by"`
|
||||
UpdatedBy string `json:"updatedBy" db:"updated_by"`
|
||||
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"`
|
||||
}
|
||||
|
||||
+14
-10
@@ -9,17 +9,21 @@
|
||||
*/
|
||||
package descr
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type Manifest struct {
|
||||
ID string `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 string `db:"created_by" json:"createdBy,omitempty"`
|
||||
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type Tags struct {
|
||||
|
||||
@@ -1,10 +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 descr
|
||||
+10
-7
@@ -10,6 +10,10 @@
|
||||
|
||||
package terms
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type PathUsage string
|
||||
|
||||
const (
|
||||
@@ -19,13 +23,12 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
AnonimousUsername = "anonymous"
|
||||
AnonymousID = "10000000-0000-0000-0000-000000000001"
|
||||
ServerUsername = "server"
|
||||
ServerID = "10000000-0000-0000-0000-000000000002"
|
||||
|
||||
InitUsername = "mstore"
|
||||
InitID = "10000000-0000-0000-0000-000000000005"
|
||||
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"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user