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

feat: addition of client code corresponding to packages customeradministration, authorizationmanagement, organization #1126

Merged
merged 12 commits into from
Apr 15, 2024

Conversation

pranav-new-relic
Copy link
Member

@pranav-new-relic pranav-new-relic commented Apr 10, 2024

Background

A new package, customeradministration was recently added to NerdGraph (few months ago), after which significant customer interests were received to have these under the purview of the New Relic Go Client, in order to be able to perform these queries in Go. This was conveyed to the team maintaining the Go Client (New Relic Internal: see this Jira ticket for more details), as a result of which work was logged to have the package added to the client.

In addition to the above, further interests were received in terms of PR contributions, in order to have a few mutations from the authorizationmanagement and organization packages also included in addition to customeradministration, in order to enable a few additional functions for customers via the Go Client (to manage organizations, grants, and more).

This PR is a consolidation of all of the above -

  • addition of support to use endpoints within the customeradministration package on NerdGraph to perform queries
  • addition of support to use few endpoints within the packages authorizationmanagement and organization to manage grants and organizations
  • addition of test cases to cover most of the above

Tests

Tests have been added to all relevant code changes, however, a few of these endpoints added have been excluded (owing to reasons listed here - New Relic Internal), to be added as a follow up to this PR after necessary evalutation.

Things to Note

This PR also proposes the addition of two new secrets, INTEGRATION_TESTING_NEW_RELIC_ORGANIZATION_ID and INTEGRATION_TESTING_NEW_RELIC_AUTHENTICATION_DOMAIN_ID as it might not be a good idea to have these included in the code. These secrets have been added to this repository, and require to be added to local environment in order to test most test cases written in this PR.

@pranav-new-relic pranav-new-relic force-pushed the pkg-customeradministration branch from a614465 to 804f7bc Compare April 11, 2024 10:28
@pranav-new-relic pranav-new-relic marked this pull request as ready for review April 12, 2024 09:43
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 20.36082% with 309 lines in your changes are missing coverage. Please review.

Project coverage is 37.82%. Comparing base (3ff4ee2) to head (33b8b20).
Report is 8 commits behind head on main.

❗ Current head 33b8b20 differs from pull request most recent head b7750b1. Consider uploading reports for the commit b7750b1 to get more accurate results

Files Patch % Lines
...stomeradministration/customeradministration_api.go 0.00% 238 Missing ⚠️
...orizationmanagement/authorizationmanagement_api.go 0.00% 47 Missing ⚠️
...authorizationmanagement/authorizationmanagement.go 0.00% 9 Missing ⚠️
...g/customeradministration/customeradministration.go 0.00% 9 Missing ⚠️
pkg/organization/organization_api.go 86.95% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1126      +/-   ##
==========================================
- Coverage   38.84%   37.82%   -1.03%     
==========================================
  Files          86       92       +6     
  Lines        5612     6044     +432     
==========================================
+ Hits         2180     2286     +106     
- Misses       3266     3589     +323     
- Partials      166      169       +3     
Flag Coverage Δ
unit 37.82% <20.36%> (-1.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pranav-new-relic pranav-new-relic merged commit 0e073a6 into main Apr 15, 2024
10 checks passed
@pranav-new-relic pranav-new-relic deleted the pkg-customeradministration branch April 15, 2024 04:43
@pranav-new-relic
Copy link
Member Author

pranav-new-relic commented Apr 16, 2024

⚠️ A Note About a Limitation These Changes Include w.r.t customeradministration

(a general note, for anyone visiting this PR)

(As on 16 April, 2024)

In the customeradministration package, few types which correspond to fields whose values would need to match either a string, or be contained in a list of strings comprise Eq string json:"eq,omitempty" and In []string json:"in", as seen in customeradministration > types.go. Since the field Eq has an omitempty tag next to it, while the In field does not, failures when trying to use the Get methods in this package, with an error stating that these types are expected may be observed.

This is not a limitation in the New Relic Go Client or with the tool Tutone which we use for code generation; instead, it has been observed that this occurrence is because of the schema definition of these fields in NerdGraph, with In as [ID!] and Eq as ID, which implies that In is a mandatory field with a list of IDs. Though this can be deselected in the NerdGraph UI, since an identical schema exists within the Go Client, the aforementioned failures are seen as In is expected to be populated.

It may be noted that adding an omitempty tag next to these In fields in the Go Client could solve the problem, however, the idea is to engage our friends over at the API team in a conversation to see if this scenario with NerdGraph could be made better, so the Go Client can tune into those changes, without having to deviate from the schema seen on NerdGraph. This shall be an ongoing effort, however, in the interim, in order to avoid the aforementioned error with the specified datatypes comprising Eq and In, a workaround could be to include the value you would like to specify in the Eq field in the In field instead, embedded in a list of strings. An example of this would be the following - if you would like to specify

			AuthenticationDomainId: &MultiTenantAuthorizationGrantAuthenticationDomainIdInputFilter{
				Eq: authenticationDomainId,
			},

in order to avoid the aforementioned error, the workaround would be to add the same variable authenticationDomainId in a list of strings to In instead, as this is currently behaving as a required field.

			AuthenticationDomainId: &MultiTenantAuthorizationGrantAuthenticationDomainIdInputFilter{
				In: []string{
					authenticationDomainId,
				},
			},

The following datatypes in customeradministration > types.go have been observed to display this behaviour and require the aforementioned workaround.

Type Path in NerdGraph
MultiTenantAuthorizationGrantAuthenticationDomainIdInputFilter customerAdministration > grants > filter! > authenticationDomainId
MultiTenantAuthorizationGrantGroupIdInputFilter customerAdministration > grants > filter! > groupId
MultiTenantAuthorizationGrantScopeIdInputFilter customerAdministration > grants > filter! > scopeId
MultiTenantAuthorizationRoleGroupIdInputFilter customerAdministration > roles > filter! > groupId
MultiTenantIdentityUserGroupIdInput customerAdministration > users > filter! > groupId
MultiTenantIdentityUserIdInput ~
OrganizationOrganizationCreateJobIdInput customerAdministration > jobs > organizationCreateAsyncResults > filter! > jobId
UserManagementGroupIdInput ~
UserManagementUserIdInput ~

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.

3 participants