Skip to content

Commit

Permalink
Change ProjectAPIKeys.Assign POST -> Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
thetonymaster committed Aug 14, 2019
1 parent c4701ea commit d6325b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mongodbatlas/project_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var _ ProjectAPIKeysService = &ProjectAPIKeysOp{}

// AssignAPIKey contains the roles to be assigned to an Organization API key into a Project
type AssignAPIKey struct {
Roles []string `json:"roles,omitempty"`
Roles []string `json:"roles"`
}

//List all API-KEY in the organization associated to {GROUP-ID}.
Expand Down Expand Up @@ -87,7 +87,7 @@ func (s *ProjectAPIKeysOp) Create(ctx context.Context, groupID string, createReq
//See more: https://docs.atlas.mongodb.com/reference/api/projectApiKeys/assign-one-org-apiKey-to-one-project/
func (s *ProjectAPIKeysOp) Assign(ctx context.Context, groupID string, keyID string, assignAPIKeyRequest *AssignAPIKey) (*Response, error) {
if groupID == "" {
return nil, NewArgError("apiKeyID", "must be set")
return nil, NewArgError("groupID", "must be set")
}

if keyID == "" {
Expand All @@ -98,7 +98,7 @@ func (s *ProjectAPIKeysOp) Assign(ctx context.Context, groupID string, keyID str

path := fmt.Sprintf("%s/%s", basePath, keyID)

req, err := s.client.NewRequest(ctx, http.MethodPost, path, assignAPIKeyRequest)
req, err := s.client.NewRequest(ctx, http.MethodPatch, path, assignAPIKeyRequest)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion mongodbatlas/project_api_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestProjectAPIKeys_Assign(t *testing.T) {
keyID := "5d1d12c087d9d63e6d682438"

mux.HandleFunc(fmt.Sprintf("/groups/%s/apiKeys/%s", groupID, keyID), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
testMethod(t, r, http.MethodPatch)
})

_, err := client.ProjectAPIKeys.Assign(ctx, groupID, keyID, &AssignAPIKey{})
Expand Down

0 comments on commit d6325b6

Please sign in to comment.