-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Admin Management Functionality #953
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #953 +/- ##
==========================================
- Coverage 85.43% 83.01% -2.42%
==========================================
Files 43 50 +7
Lines 2313 2684 +371
==========================================
+ Hits 1976 2228 +252
- Misses 315 410 +95
- Partials 22 46 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I add additional test cases to get a better coverage of the implementation. I believe this is failing the coverage now due to the example included. I see that other examples do not have test written for them, and I didn't see an obvious way to exclude it from being checked. |
@sashabaranov any chance this can be looked at? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces the Admin Management functionality for managing API keys, org invites, users, projects, project users, and usage costs via the OpenAI Admin API.
- Implements new endpoints in the client for various administrative operations.
- Adds comprehensive tests for Admin Users, Projects, Project Users, API Keys, and Invites.
- Updates examples and documentation to reflect the new Admin API features.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
examples/admin_usage/main.go | Adds an example demonstrating Admin API usage cost retrieval. |
examples/admin_usage/README.md | Provides usage instructions for Admin API examples. |
admin_user*.go & admin_user_test.go | Implements and tests Admin Users management functions. |
admin_usage*.go | Implements and tests Admin Usage Cost functions. |
admin_project*.go & admin_project_test.go | Implements and tests Admin Projects management functions. |
admin_project_user*.go | Implements and tests Admin Project Users management functions. |
admin_key*.go & admin_key_test.go | Implements and tests Admin API Keys management functions. |
admin_invite*.go & admin_invite_test.go | Implements and tests Admin Invites management functions. |
Comments suppressed due to low confidence (2)
admin_project_user.go:73
- The parameter 'userID' in CreateAdminProjectUser is passed an email value in tests. Consider renaming it to 'userEmail' or updating its usage to ensure consistency.
func (c *Client) CreateAdminProjectUser(
admin_invite.go:97
- Consider using a strict equality check for validating the admin role instead of a substring match, unless substring matching is intentionally desired.
if !containsSubstr(adminInviteRoles, role) {
@sashabaranov sorry for the ping again on this, would really like to get this merged so I can setup some automation on my side without using my fork. If you have any advice on how to exclude the examples from the code coverage, which seems to be dropping the overall coverage, happy to take a look at it. |
Hi @MattDavisRV! Sorry for being so slow with this. This is a fantastic PR that I'm finding hard to chew. The 1821 lines added are non-trivial to review, especially with the fact that there is no good integration testing for this! Can we break this down into smaller pieces and merge one by one? No reduction in unit test coverage would also help! |
Sure, I'll break this up into smaller PRs, I'll start with the usage one as that's what I need for my use case. |
A similar PR may already be submitted!
Please search among the Pull request before creating one.
If your changes introduce breaking changes, please prefix the title of your pull request with "[BREAKING_CHANGES]". This allows for clear identification of such changes in the 'What's Changed' section on the release page, making it developer-friendly.
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request.
Describe the change
This change includes functionality to manage your Org via Admin API. This change does not include all endpoints and functionality related to the Admin API. As I have time, and if no one else has added them, I will submit another PR for the missing functionality.
Provide OpenAI documentation link
Admin API Documentation
Describe your solution
Implemented functionality to:
Tests
Tests have been created for all functionality added. Test methodology was copied from existing tests in the library.
Additional context
I'm unsure why the Sanity checks are failing, they were locally as well, but unrelated to my changes (jsonschema).
Issue: #XXXX