Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement organizations API. #477

Merged
merged 3 commits into from
Sep 11, 2024
Merged

Conversation

gigerdo
Copy link
Member

@gigerdo gigerdo commented Aug 2, 2024

Adds the APIs for managing an Elastic cloud organization and its members.

  • Get/List/Update organization
  • List/Create/Delete organization invitations
  • List/Delete organization members
  • Add/Remove roles from a member

(https://www.elastic.co/guide/en/cloud/current/Organizations.html)

This change is needed to implement RBAC support in terraform-provider-ec

Description

Related Issues

Motivation and Context

How Has This Been Tested?

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Adds the APIs for managing the organization:
- Get/List/Update organizations
- List/Create/Delete organization invitations
- List/Delete organization members
- Add/Remove organization member role assignments

(API docs: https://www.elastic.co/guide/en/cloud/current/Organizations.html)
@gigerdo gigerdo marked this pull request as ready for review September 3, 2024 11:58
@gigerdo gigerdo requested a review from a team as a code owner September 3, 2024 11:58
if got != nil && !assert.Equal(t, test.want, *got) {
t.Error(err)
}
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a nit, but it seems like we wouldn't verify want == got if got is nil. It seems like we would maybe want to fail the test in that case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, true. It is done this way to ensure the 'want' is not checked when an error is expected. But I think I can write this in a clearer way:

if test.err != "" {
  assert.EqualError(t, err, test.err)
  assert.Nil(t, got)
} else {
  assert.NoError(t, err)
  assert.Equal(t, test.want, *got)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated all tests to use this format.

if err != nil && !assert.EqualError(t, err, test.err) {
t.Error(err)
}
if got != nil && !assert.Equal(t, test.want, *got) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just commenting here so that if a change is made for the prior comment RE: failing the test if got == nil it also gets made here.

Copy link

@nick-benoit nick-benoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and is well tested. One minor question with some tests, otherwise LGTM

Clearly check either the error case or the successful result case.
Copy link

@nick-benoit nick-benoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gigerdo gigerdo merged commit 491161a into elastic:master Sep 11, 2024
2 checks passed
@gigerdo gigerdo deleted the add-organization-api branch September 11, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants