uuid used

This commit is contained in:
2026-02-20 15:06:15 +02:00
parent 35e83ed705
commit 8546ad496f
31 changed files with 265 additions and 238 deletions
+14 -14
View File
@@ -15,10 +15,10 @@ type CreateAccountParams struct {
Password string `json:"password"`
}
type CreateAccountResult struct {
AccountID string `json:"accountId"`
AccountID auxuuid.UUID `json:"accountId"`
}
func (oper *Operator) CreateAccount(ctx context.Context, operatorID string, params *CreateAccountParams) (*CreateAccountResult, error) {
func (oper *Operator) CreateAccount(ctx context.Context, operatorID auxuuid.UUID, params *CreateAccountParams) (*CreateAccountResult, error) {
var err error
res := &CreateAccountResult{}
@@ -62,14 +62,14 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID string, para
// GetAccount
type GetAccountParams struct {
Username string `json:"username"`
AccountID string `json:"accountId"`
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
}
type GetAccountResult struct {
Account *descr.AccountShort `json:"account"`
}
func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams) (*GetAccountResult, error) {
func (oper *Operator) GetAccount(ctx context.Context, operatorID auxuuid.UUID, params *GetAccountParams) (*GetAccountResult, error) {
var err error
res := &GetAccountResult{}
@@ -128,15 +128,15 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
}
type UpdateAccountParams struct {
Username string `json:"username"`
AccountID string `json:"accountId"`
NewUsername string `json:"newUsername"`
NewPassword string `json:"newPassword"`
Disabled bool `json:"disabled"`
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
NewUsername string `json:"newUsername"`
NewPassword string `json:"newPassword"`
Disabled bool `json:"disabled"`
}
type UpdateAccountResult struct{}
func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountParams) (*UpdateAccountResult, error) {
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID auxuuid.UUID, params *UpdateAccountParams) (*UpdateAccountResult, error) {
var err error
res := &UpdateAccountResult{}
if params.Username == "" && params.AccountID == "" {
@@ -195,12 +195,12 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
}
type DeleteAccountParams struct {
Username string `json:"username"`
AccountID string `json:"accountId"`
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
}
type DeleteAccountResult struct{}
func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountParams) (*DeleteAccountResult, error) {
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID auxuuid.UUID, params *DeleteAccountParams) (*DeleteAccountResult, error) {
var err error
res := &DeleteAccountResult{}
+1 -1
View File
@@ -73,7 +73,7 @@ type PostUploadParams struct {
From string
}
type PostUploadResult struct {
DockerUploadUUID string
DockerUploadUUID auxuuid.UUID
Location string
ContentLength string
}
+14 -14
View File
@@ -41,9 +41,9 @@ type FileInfoResult struct {
ContentDigest string
ContentCreatedAt string
ContentCreatedBy string
ContentCreatedBy auxuuid.UUID
ContentUpdatedAt string
ContentUpdatedBy string
ContentUpdatedBy auxuuid.UUID
}
func cleanFilepath(filename string) (string, error) {
@@ -51,7 +51,7 @@ func cleanFilepath(filename string) (string, error) {
return filepath.Clean(filename), nil
}
func (oper *Operator) FileInfo(ctx context.Context, operID string, param *FileInfoParams) (int, *FileInfoResult, error) {
func (oper *Operator) FileInfo(ctx context.Context, operatorID auxuuid.UUID, param *FileInfoParams) (int, *FileInfoResult, error) {
var err error
code := http.StatusOK
res := &FileInfoResult{}
@@ -101,7 +101,7 @@ type PutFileResult struct{}
const defaultContentType = "application/octet-stream"
// TODO: checking catalog and file names conflict
func (oper *Operator) PutFile(ctx context.Context, operID string, param *PutFileParams) (int, *PutFileResult, error) {
func (oper *Operator) PutFile(ctx context.Context, operatorID auxuuid.UUID, param *PutFileParams) (int, *PutFileResult, error) {
var err error
res := &PutFileResult{}
@@ -147,7 +147,7 @@ func (oper *Operator) PutFile(ctx context.Context, operID string, param *PutFile
fileDescr.Checksum = checksum
fileDescr.UpdatedAt = now
fileDescr.Type = contentType
fileDescr.UpdatedBy = operID
fileDescr.UpdatedBy = operatorID
err = oper.mdb.UpdateFileByID(ctx, fileDescr.ID, fileDescr)
if err != nil {
code := http.StatusInternalServerError
@@ -163,8 +163,8 @@ func (oper *Operator) PutFile(ctx context.Context, operID string, param *PutFile
Checksum: checksum,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: operID,
UpdatedBy: operID,
CreatedBy: operatorID,
UpdatedBy: operatorID,
}
err = oper.mdb.InsertFile(ctx, fileDescr)
if err != nil {
@@ -193,12 +193,12 @@ type GetFileResult struct {
Source io.ReadCloser
ContentCreatedAt string
ContentCreatedBy string
ContentCreatedBy auxuuid.UUID
ContentUpdatedAt string
ContentUpdatedBy string
ContentUpdatedBy auxuuid.UUID
}
func (oper *Operator) GetFile(ctx context.Context, operID string, param *GetFileParams) (int, *GetFileResult, error) {
func (oper *Operator) GetFile(ctx context.Context, operatorID auxuuid.UUID, param *GetFileParams) (int, *GetFileResult, error) {
var err error
res := &GetFileResult{}
@@ -247,7 +247,7 @@ type DeleteFileParams struct {
}
type DeleteFileResult struct{}
func (oper *Operator) DeleteFile(ctx context.Context, operID string, param *DeleteFileParams) (int, *DeleteFileResult, error) {
func (oper *Operator) DeleteFile(ctx context.Context, operatorID auxuuid.UUID, param *DeleteFileParams) (int, *DeleteFileResult, error) {
var err error
res := &DeleteFileResult{}
code := http.StatusOK
@@ -294,7 +294,7 @@ type ListFilesResult struct {
Files []descr.File `json:"files,omitempty"`
}
func (oper *Operator) ListFiles(ctx context.Context, operID string, params *ListFilesParams) (int, *ListFilesResult, error) {
func (oper *Operator) ListFiles(ctx context.Context, operatorID auxuuid.UUID, params *ListFilesParams) (int, *ListFilesResult, error) {
var err error
res := &ListFilesResult{
Files: make([]descr.File, 0),
@@ -406,7 +406,7 @@ type ListCollectionsResult struct {
Collections []string `json:"collection,omitempty"`
}
func (oper *Operator) ListCollections(ctx context.Context, operID string, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
func (oper *Operator) ListCollections(ctx context.Context, operatorID auxuuid.UUID, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
var err error
res := &ListCollectionsResult{
Collections: make([]string, 0),
@@ -539,7 +539,7 @@ type DeleteColletionResult struct {
Files []descr.File `json:"files,omitempty"`
}
func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID auxuuid.UUID, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
var err error
res := &DeleteColletionResult{
Files: make([]descr.File, 0),
+17 -17
View File
@@ -12,16 +12,16 @@ import (
// CreateGrant
type CreateGrantParams struct {
AccountID string `json:"accountID"`
Username string `json:"username"`
Right string `json:"operation"`
Pattern string `json:"pattern"`
AccountID auxuuid.UUID `json:"accountID"`
Username string `json:"username"`
Right string `json:"operation"`
Pattern string `json:"pattern"`
}
type CreateGrantResult struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *CreateGrantParams) (*CreateGrantResult, error) {
func (oper *Operator) CreateGrant(ctx context.Context, operatorID auxuuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
var err error
res := &CreateGrantResult{}
@@ -86,8 +86,8 @@ func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *Cr
Pattern: params.Pattern,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: operID,
UpdatedBy: operID,
CreatedBy: operatorID,
UpdatedBy: operatorID,
}
err = oper.mdb.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -99,12 +99,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *Cr
// UpdateGrant
type UpdateGrantParams struct {
GrantID string
GrantID auxuuid.UUID
NewPattern string
}
type UpdateGrantResult struct{}
func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *UpdateGrantParams) (*UpdateGrantResult, error) {
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID auxuuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
var err error
res := &UpdateGrantResult{}
@@ -130,7 +130,7 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *Up
now := auxtool.TimeNow()
if params.NewPattern != "" {
grantDescr.UpdatedAt = now
grantDescr.UpdatedBy = operID
grantDescr.UpdatedBy = operatorID
grantDescr.Pattern = params.NewPattern
}
err = oper.mdb.UpdateGrantByID(ctx, grantDescr.ID, grantDescr)
@@ -142,11 +142,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *Up
// DeleteGrant
type DeleteGrantParams struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
type DeleteGrantResult struct{}
func (oper *Operator) DeleteGrant(ctx context.Context, operID string, params *DeleteGrantParams) (*DeleteGrantResult, error) {
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID auxuuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
var err error
res := &DeleteGrantResult{}
@@ -176,13 +176,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operID string, params *De
// ListGrants
type ListGrantsParams struct {
Username string
AccountID string
AccountID auxuuid.UUID
}
type ListGrantsResult struct {
Grants []descr.Grant `json:"grants"`
}
func (oper *Operator) ListGrants(ctx context.Context, operID string, params *ListGrantsParams) (*ListGrantsResult, error) {
func (oper *Operator) ListGrants(ctx context.Context, operatorID auxuuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
var err error
res := &ListGrantsResult{
Grants: make([]descr.Grant, 0),
@@ -223,13 +223,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operID string, params *Lis
// Get Grants
type GetGrantParams struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
type GetGrantResult struct {
Grant *descr.Grant `json:"grant"`
}
func (oper *Operator) GetGrant(ctx context.Context, operID string, params *GetGrantParams) (*GetGrantResult, error) {
func (oper *Operator) GetGrant(ctx context.Context, operatorID auxuuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
var err error
res := &GetGrantResult{}