Skip to content

Commit 6885485

Browse files
add new S3Vectors action
1 parent f1fa17f commit 6885485

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

policy/vectors-action.go

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Copyright (c) 2015-2025 MinIO, Inc.
2+
//
3+
// This file is part of MinIO Object Storage stack
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU Affero General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU Affero General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU Affero General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
package policy
19+
20+
import (
21+
"github.com/minio/pkg/v3/policy/condition"
22+
)
23+
24+
// VectorsAction - S3 Vectors policy action.
25+
type VectorsAction string
26+
27+
const (
28+
// S3VectorsCreateVectorBucketAction maps to the AWS `CreateVectorBucket` S3 Vectors action.
29+
S3VectorsCreateVectorBucketAction VectorsAction = "s3vectors:CreateVectorBucket"
30+
31+
// S3VectorsDeleteVectorBucketAction maps to the AWS `DeleteVectorBucket` S3 Vectors action.
32+
S3VectorsDeleteVectorBucketAction = "s3vectors:DeleteVectorBucket"
33+
34+
// S3VectorsGetVectorBucketAction maps to the AWS `GetVectorBucket` S3 Vectors action.
35+
S3VectorsGetVectorBucketAction = "s3vectors:GetVectorBucket"
36+
37+
// S3VectorsListVectorBucketsAction maps to the AWS `ListVectorBuckets` S3 Vectors action.
38+
S3VectorsListVectorBucketsAction = "s3vectors:ListVectorBuckets"
39+
40+
// S3VectorsCreateIndexAction maps to the AWS `CreateIndex` S3 Vectors action.
41+
S3VectorsCreateIndexAction = "s3vectors:CreateIndex"
42+
43+
// S3VectorsDeleteIndexAction maps to the AWS `DeleteIndex` S3 Vectors action.
44+
S3VectorsDeleteIndexAction = "s3vectors:DeleteIndex"
45+
46+
// S3VectorsGetIndexAction maps to the AWS `GetIndex` S3 Vectors action.
47+
S3VectorsGetIndexAction = "s3vectors:GetIndex"
48+
49+
// S3VectorsListIndexesAction maps to the AWS `ListIndexes` S3 Vectors action.
50+
S3VectorsListIndexesAction = "s3vectors:ListIndexes"
51+
52+
// S3VectorsPutVectorsAction maps to the AWS `PutVectors` S3 Vectors action.
53+
S3VectorsPutVectorsAction = "s3vectors:PutVectors"
54+
55+
// S3VectorsGetVectorsAction maps to the AWS `GetVectors` S3 Vectors action.
56+
S3VectorsGetVectorsAction = "s3vectors:GetVectors"
57+
58+
// S3VectorsDeleteVectorsAction maps to the AWS `DeleteVectors` S3 Vectors action.
59+
S3VectorsDeleteVectorsAction = "s3vectors:DeleteVectors"
60+
61+
// S3VectorsListVectorsAction maps to the AWS `ListVectors` S3 Vectors action.
62+
S3VectorsListVectorsAction = "s3vectors:ListVectors"
63+
64+
// S3VectorsQueryVectorsAction maps to the AWS `QueryVectors` S3 Vectors action.
65+
S3VectorsQueryVectorsAction = "s3vectors:QueryVectors"
66+
67+
// AllS3VectorsActions - all Amazon S3 Vectors actions
68+
AllS3VectorsActions = "s3vectors:*"
69+
)
70+
71+
// SupportedVectorsActions - list of all supported S3 Vectors actions.
72+
var SupportedVectorsActions = map[VectorsAction]struct{}{
73+
S3VectorsCreateVectorBucketAction: {},
74+
S3VectorsDeleteVectorBucketAction: {},
75+
S3VectorsGetVectorBucketAction: {},
76+
S3VectorsListVectorBucketsAction: {},
77+
S3VectorsCreateIndexAction: {},
78+
S3VectorsDeleteIndexAction: {},
79+
S3VectorsGetIndexAction: {},
80+
S3VectorsListIndexesAction: {},
81+
S3VectorsPutVectorsAction: {},
82+
S3VectorsGetVectorsAction: {},
83+
S3VectorsDeleteVectorsAction: {},
84+
S3VectorsListVectorsAction: {},
85+
S3VectorsQueryVectorsAction: {},
86+
AllS3VectorsActions: {},
87+
}
88+
89+
// IsValid - checks if action is valid or not.
90+
func (action VectorsAction) IsValid() bool {
91+
_, ok := SupportedVectorsActions[action]
92+
return ok
93+
}
94+
95+
func createVectorsActionConditionKeyMap() map[Action]condition.KeySet {
96+
commonKeys := []condition.Key{}
97+
for _, keyName := range condition.CommonKeys {
98+
commonKeys = append(commonKeys, keyName.ToKey())
99+
}
100+
101+
vectorsActionConditionKeyMap := map[Action]condition.KeySet{}
102+
for act := range SupportedVectorsActions {
103+
vectorsActionConditionKeyMap[Action(act)] = condition.NewKeySet(commonKeys...)
104+
}
105+
106+
// Override specific actions with their condition keys as needed
107+
// For now, all actions use only common keys
108+
109+
return vectorsActionConditionKeyMap
110+
}
111+
112+
// VectorsActionConditionKeyMap - holds mapping of Vectors actions to condition keys.
113+
var VectorsActionConditionKeyMap = createVectorsActionConditionKeyMap()

0 commit comments

Comments
 (0)