@@ -14,7 +14,7 @@ const projectAPIKeysPath = "groups/%s/apiKeys"
1414type ProjectAPIKeysService interface {
1515 List (context.Context , string , * ListOptions ) ([]APIKey , * Response , error )
1616 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 )
1818 Unassign (context.Context , string , string ) (* Response , error )
1919}
2020
@@ -26,6 +26,11 @@ type ProjectAPIKeysOp struct {
2626
2727var _ ProjectAPIKeysService = & ProjectAPIKeysOp {}
2828
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+
2934//List all API-KEY in the organization associated to {GROUP-ID}.
3035//See more: https://docs.atlas.mongodb.com/reference/api/projectApiKeys/get-all-apiKeys-in-one-project/
3136func (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
8085
8186//Assign an API-KEY related to {GROUP-ID} to a the project with {API-KEY-ID}.
8287//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 ) {
8489 if groupID == "" {
85- return nil , NewArgError ("apiKeyID " , "must be set" )
90+ return nil , NewArgError ("groupID " , "must be set" )
8691 }
8792
8893 if keyID == "" {
@@ -93,7 +98,7 @@ func (s *ProjectAPIKeysOp) Assign(ctx context.Context, groupID string, keyID str
9398
9499 path := fmt .Sprintf ("%s/%s" , basePath , keyID )
95100
96- req , err := s .client .NewRequest (ctx , http .MethodPost , path , nil )
101+ req , err := s .client .NewRequest (ctx , http .MethodPatch , path , assignAPIKeyRequest )
97102 if err != nil {
98103 return nil , err
99104 }
0 commit comments