@@ -14,7 +14,7 @@ const projectAPIKeysPath = "groups/%s/apiKeys"
14
14
type ProjectAPIKeysService interface {
15
15
List (context.Context , string , * ListOptions ) ([]APIKey , * Response , error )
16
16
Create (context.Context , string , * APIKeyInput ) (* APIKey , * Response , error )
17
- Assign (context.Context , string , string ) (* Response , error )
17
+ Assign (context.Context , string , string , * AssignAPIKey ) (* Response , error )
18
18
Unassign (context.Context , string , string ) (* Response , error )
19
19
}
20
20
@@ -26,6 +26,11 @@ type ProjectAPIKeysOp struct {
26
26
27
27
var _ ProjectAPIKeysService = & ProjectAPIKeysOp {}
28
28
29
+ // AssignAPIKey contains the roles to be assigned to an Organization API key into a Project
30
+ type AssignAPIKey struct {
31
+ Roles []string `json:"roles"`
32
+ }
33
+
29
34
//List all API-KEY in the organization associated to {GROUP-ID}.
30
35
//See more: https://docs.atlas.mongodb.com/reference/api/projectApiKeys/get-all-apiKeys-in-one-project/
31
36
func (s * ProjectAPIKeysOp ) List (ctx context.Context , groupID string , listOptions * ListOptions ) ([]APIKey , * Response , error ) {
@@ -80,9 +85,9 @@ func (s *ProjectAPIKeysOp) Create(ctx context.Context, groupID string, createReq
80
85
81
86
//Assign an API-KEY related to {GROUP-ID} to a the project with {API-KEY-ID}.
82
87
//See more: https://docs.atlas.mongodb.com/reference/api/projectApiKeys/assign-one-org-apiKey-to-one-project/
83
- func (s * ProjectAPIKeysOp ) Assign (ctx context.Context , groupID string , keyID string ) (* Response , error ) {
88
+ func (s * ProjectAPIKeysOp ) Assign (ctx context.Context , groupID string , keyID string , assignAPIKeyRequest * AssignAPIKey ) (* Response , error ) {
84
89
if groupID == "" {
85
- return nil , NewArgError ("apiKeyID " , "must be set" )
90
+ return nil , NewArgError ("groupID " , "must be set" )
86
91
}
87
92
88
93
if keyID == "" {
@@ -93,7 +98,7 @@ func (s *ProjectAPIKeysOp) Assign(ctx context.Context, groupID string, keyID str
93
98
94
99
path := fmt .Sprintf ("%s/%s" , basePath , keyID )
95
100
96
- req , err := s .client .NewRequest (ctx , http .MethodPost , path , nil )
101
+ req , err := s .client .NewRequest (ctx , http .MethodPatch , path , assignAPIKeyRequest )
97
102
if err != nil {
98
103
return nil , err
99
104
}
0 commit comments