diff --git a/pkg/accountmanagement/accountmanagement_api.go b/pkg/accountmanagement/accountmanagement_api.go index 1259a6585..d2cbaea27 100644 --- a/pkg/accountmanagement/accountmanagement_api.go +++ b/pkg/accountmanagement/accountmanagement_api.go @@ -131,27 +131,31 @@ const AccountManagementUpdateAccountMutation = `mutation( ) { managedAccount { id + isCanceled name regionCode } } }` -// NOTE: Tutone changes made to GetManagedAccounts and dependent functions and queries have been reverted -// owing to a few limitations. In order to use the recently added attribute "isCanceled" with GetManagedAccounts, -// please see the functions in accountmanagement_api_.go. - // Admin-level info about the accounts in an organization. -func (a *Accountmanagement) GetManagedAccounts() (*[]AccountManagementManagedAccount, error) { - return a.GetManagedAccountsWithContext(context.Background()) +func (a *Accountmanagement) GetManagedAccounts( + isCanceled bool, +) (*[]AccountManagementManagedAccount, error) { + return a.GetManagedAccountsWithContext(context.Background(), + isCanceled, + ) } // Admin-level info about the accounts in an organization. func (a *Accountmanagement) GetManagedAccountsWithContext( ctx context.Context, + isCanceled bool, ) (*[]AccountManagementManagedAccount, error) { resp := managedAccountsResponse{} - vars := map[string]interface{}{} + vars := map[string]interface{}{ + "isCanceled": isCanceled, + } if err := a.client.NerdGraphQueryWithContext(ctx, getManagedAccountsQuery, vars, &resp); err != nil { return nil, err diff --git a/pkg/usermanagement/types.go b/pkg/usermanagement/types.go index 7c07dd197..8bfccf568 100644 --- a/pkg/usermanagement/types.go +++ b/pkg/usermanagement/types.go @@ -229,12 +229,6 @@ type OrganizationAuthenticationDomainCollection struct { NextCursor string `json:"nextCursor,omitempty"` } -// UserManagementAddUsersToGroupsPayload - Autogenerated return type of AddUsersToGroups. -type UserManagementAddUsersToGroupsPayload struct { - // The group(s) updated. - Groups []UserManagementGroup `json:"groups"` -} - // UserManagementAuthenticationDomain - An "authentication domain" is a grouping of New Relic users governed by the same user management settings, like how they're provisioned (added and updated), how they're authenticated (logged in), session settings, and how user upgrades are managed. type UserManagementAuthenticationDomain struct { // container for groups enabling cursor based pagination @@ -305,36 +299,6 @@ type UserManagementCreatedUser struct { Type UserManagementUserType `json:"type"` } -// UserManagementDeleteGroup - The input object representing the group to remove -type UserManagementDeleteGroup struct { - // The ID of the group being removed. - ID string `json:"id"` -} - -// UserManagementDeleteGroupPayload - Autogenerated return type of DeleteGroup. -type UserManagementDeleteGroupPayload struct { - // The group that was deleted - Group UserManagementGroup `json:"group,omitempty"` -} - -// UserManagementDeleteUser - The input object representing the user being deleted -type UserManagementDeleteUser struct { - // The ID of the user to be deleted - ID string `json:"id"` -} - -// UserManagementDeleteUserPayload - Autogenerated return type of DeleteUser. -type UserManagementDeleteUserPayload struct { - // The user that was deleted - DeletedUser UserManagementDeletedUser `json:"deletedUser,omitempty"` -} - -// UserManagementDeletedUser - A user of New Relic to be deleted. -type UserManagementDeletedUser struct { - // The id of the deleted user - ID string `json:"id"` -} - // UserManagementDisplayNameInput - Available filtering types for group display names type UserManagementDisplayNameInput struct { // Part of a display name @@ -452,52 +416,12 @@ type UserManagementPendingUpgradeRequestInput struct { Exists bool `json:"exists"` } -// UserManagementRemoveUsersFromGroupsPayload - Autogenerated return type of RemoveUsersFromGroups. -type UserManagementRemoveUsersFromGroupsPayload struct { - // The group(s) updated. - Groups []UserManagementGroup `json:"groups"` -} - // UserManagementTypeInput - Available filtering types for user type type UserManagementTypeInput struct { // A user type Eq UserManagementTypeEnum `json:"eq"` } -// UserManagementUpdateGroup - The input object representing the group being updated -type UserManagementUpdateGroup struct { - // The name of the group - DisplayName string `json:"displayName"` - // The id of the group to update - ID string `json:"id"` -} - -// UserManagementUpdateGroupPayload - Autogenerated return type of UpdateGroup. -type UserManagementUpdateGroupPayload struct { - // The group that was updated - Group UserManagementGroup `json:"group,omitempty"` -} - -// UserManagementUpdateUser - The input object representing the user being updated -type UserManagementUpdateUser struct { - // The new email address to be updated on the user - Email string `json:"email,omitempty"` - // The ID of the user to be updated - ID string `json:"id"` - // The full name of the user to be updated - Name string `json:"name,omitempty"` - // The user time zone to be updated, in IANA zoneinfo format, e.g. 'America/Chicago' - TimeZone string `json:"timeZone,omitempty"` - // The new user type to be updated on the user - UserType UserManagementRequestedTierName `json:"userType,omitempty"` -} - -// UserManagementUpdateUserPayload - Autogenerated return type of UpdateUser. -type UserManagementUpdateUserPayload struct { - // The user that was updated - User UserManagementUser `json:"user,omitempty"` -} - // UserManagementUser - A user of New Relic scoped to an authentication domain. type UserManagementUser struct { // Email address of the user. @@ -586,14 +510,6 @@ type UserManagementUsers struct { Users []UserManagementUser `json:"users"` } -// UserManagementUsersGroupsInput - The input object representing the group(s) and user(s) to update. -type UserManagementUsersGroupsInput struct { - // The id of the group(s) to add the user(s) to. Max: 10 - GroupIds []string `json:"groupIds"` - // The id of the user(s) to be added to the group(s). Max: 50 - UserIDs []string `json:"userIds"` -} - type authenticationDomainsResponse struct { Actor Actor `json:"actor"` } diff --git a/pkg/usermanagement/usermanagement_api.go b/pkg/usermanagement/usermanagement_api.go index 51982534e..fc918bab8 100644 --- a/pkg/usermanagement/usermanagement_api.go +++ b/pkg/usermanagement/usermanagement_api.go @@ -3,52 +3,6 @@ package usermanagement import "context" -// A mutation for adding user(s) to group(s). -func (a *Usermanagement) UserManagementAddUsersToGroups( - addUsersToGroupsOptions UserManagementUsersGroupsInput, -) (*UserManagementAddUsersToGroupsPayload, error) { - return a.UserManagementAddUsersToGroupsWithContext(context.Background(), - addUsersToGroupsOptions, - ) -} - -// A mutation for adding user(s) to group(s). -func (a *Usermanagement) UserManagementAddUsersToGroupsWithContext( - ctx context.Context, - addUsersToGroupsOptions UserManagementUsersGroupsInput, -) (*UserManagementAddUsersToGroupsPayload, error) { - - resp := UserManagementAddUsersToGroupsQueryResponse{} - vars := map[string]interface{}{ - "addUsersToGroupsOptions": addUsersToGroupsOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementAddUsersToGroupsMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementAddUsersToGroupsPayload, nil -} - -type UserManagementAddUsersToGroupsQueryResponse struct { - UserManagementAddUsersToGroupsPayload UserManagementAddUsersToGroupsPayload `json:"UserManagementAddUsersToGroups"` -} - -const UserManagementAddUsersToGroupsMutation = `mutation( - $addUsersToGroupsOptions: UserManagementUsersGroupsInput, -) { userManagementAddUsersToGroups( - addUsersToGroupsOptions: $addUsersToGroupsOptions, -) { - groups { - displayName - id - users { - nextCursor - totalCount - } - } -} }` - // A mutation for creating a group in an authentication domain. func (a *Usermanagement) UserManagementCreateGroup( createGroupOptions UserManagementCreateGroup, @@ -136,247 +90,6 @@ const UserManagementCreateUserMutation = `mutation( email id name - type { - displayName - id - } - } -} }` - -// A mutation for deleting a group. -func (a *Usermanagement) UserManagementDeleteGroup( - groupOptions UserManagementDeleteGroup, -) (*UserManagementDeleteGroupPayload, error) { - return a.UserManagementDeleteGroupWithContext(context.Background(), - groupOptions, - ) -} - -// A mutation for deleting a group. -func (a *Usermanagement) UserManagementDeleteGroupWithContext( - ctx context.Context, - groupOptions UserManagementDeleteGroup, -) (*UserManagementDeleteGroupPayload, error) { - - resp := UserManagementDeleteGroupQueryResponse{} - vars := map[string]interface{}{ - "groupOptions": groupOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementDeleteGroupMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementDeleteGroupPayload, nil -} - -type UserManagementDeleteGroupQueryResponse struct { - UserManagementDeleteGroupPayload UserManagementDeleteGroupPayload `json:"UserManagementDeleteGroup"` -} - -const UserManagementDeleteGroupMutation = `mutation( - $groupOptions: UserManagementDeleteGroup, -) { userManagementDeleteGroup( - groupOptions: $groupOptions, -) { - group { - displayName - id - users { - nextCursor - totalCount - } - } -} }` - -// A mutation for deleting a user. -func (a *Usermanagement) UserManagementDeleteUser( - deleteUserOptions UserManagementDeleteUser, -) (*UserManagementDeleteUserPayload, error) { - return a.UserManagementDeleteUserWithContext(context.Background(), - deleteUserOptions, - ) -} - -// A mutation for deleting a user. -func (a *Usermanagement) UserManagementDeleteUserWithContext( - ctx context.Context, - deleteUserOptions UserManagementDeleteUser, -) (*UserManagementDeleteUserPayload, error) { - - resp := UserManagementDeleteUserQueryResponse{} - vars := map[string]interface{}{ - "deleteUserOptions": deleteUserOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementDeleteUserMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementDeleteUserPayload, nil -} - -type UserManagementDeleteUserQueryResponse struct { - UserManagementDeleteUserPayload UserManagementDeleteUserPayload `json:"UserManagementDeleteUser"` -} - -const UserManagementDeleteUserMutation = `mutation( - $deleteUserOptions: UserManagementDeleteUser!, -) { userManagementDeleteUser( - deleteUserOptions: $deleteUserOptions, -) { - deletedUser { - id - } -} }` - -// A mutation for removing user(s) from group(s). -func (a *Usermanagement) UserManagementRemoveUsersFromGroups( - removeUsersFromGroupsOptions UserManagementUsersGroupsInput, -) (*UserManagementRemoveUsersFromGroupsPayload, error) { - return a.UserManagementRemoveUsersFromGroupsWithContext(context.Background(), - removeUsersFromGroupsOptions, - ) -} - -// A mutation for removing user(s) from group(s). -func (a *Usermanagement) UserManagementRemoveUsersFromGroupsWithContext( - ctx context.Context, - removeUsersFromGroupsOptions UserManagementUsersGroupsInput, -) (*UserManagementRemoveUsersFromGroupsPayload, error) { - - resp := UserManagementRemoveUsersFromGroupsQueryResponse{} - vars := map[string]interface{}{ - "removeUsersFromGroupsOptions": removeUsersFromGroupsOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementRemoveUsersFromGroupsMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementRemoveUsersFromGroupsPayload, nil -} - -type UserManagementRemoveUsersFromGroupsQueryResponse struct { - UserManagementRemoveUsersFromGroupsPayload UserManagementRemoveUsersFromGroupsPayload `json:"UserManagementRemoveUsersFromGroups"` -} - -const UserManagementRemoveUsersFromGroupsMutation = `mutation( - $removeUsersFromGroupsOptions: UserManagementUsersGroupsInput!, -) { userManagementRemoveUsersFromGroups( - removeUsersFromGroupsOptions: $removeUsersFromGroupsOptions, -) { - groups { - displayName - id - users { - nextCursor - totalCount - } - } -} }` - -// A mutation for updating an existing group. -func (a *Usermanagement) UserManagementUpdateGroup( - updateGroupOptions UserManagementUpdateGroup, -) (*UserManagementUpdateGroupPayload, error) { - return a.UserManagementUpdateGroupWithContext(context.Background(), - updateGroupOptions, - ) -} - -// A mutation for updating an existing group. -func (a *Usermanagement) UserManagementUpdateGroupWithContext( - ctx context.Context, - updateGroupOptions UserManagementUpdateGroup, -) (*UserManagementUpdateGroupPayload, error) { - - resp := UserManagementUpdateGroupQueryResponse{} - vars := map[string]interface{}{ - "updateGroupOptions": updateGroupOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementUpdateGroupMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementUpdateGroupPayload, nil -} - -type UserManagementUpdateGroupQueryResponse struct { - UserManagementUpdateGroupPayload UserManagementUpdateGroupPayload `json:"UserManagementUpdateGroup"` -} - -const UserManagementUpdateGroupMutation = `mutation( - $updateGroupOptions: UserManagementUpdateGroup, -) { userManagementUpdateGroup( - updateGroupOptions: $updateGroupOptions, -) { - group { - displayName - id - users { - nextCursor - totalCount - } - } -} }` - -// A mutation for updating an existing user. -func (a *Usermanagement) UserManagementUpdateUser( - updateUserOptions UserManagementUpdateUser, -) (*UserManagementUpdateUserPayload, error) { - return a.UserManagementUpdateUserWithContext(context.Background(), - updateUserOptions, - ) -} - -// A mutation for updating an existing user. -func (a *Usermanagement) UserManagementUpdateUserWithContext( - ctx context.Context, - updateUserOptions UserManagementUpdateUser, -) (*UserManagementUpdateUserPayload, error) { - - resp := UserManagementUpdateUserQueryResponse{} - vars := map[string]interface{}{ - "updateUserOptions": updateUserOptions, - } - - if err := a.client.NerdGraphQueryWithContext(ctx, UserManagementUpdateUserMutation, vars, &resp); err != nil { - return nil, err - } - - return &resp.UserManagementUpdateUserPayload, nil -} - -type UserManagementUpdateUserQueryResponse struct { - UserManagementUpdateUserPayload UserManagementUpdateUserPayload `json:"UserManagementUpdateUser"` -} - -const UserManagementUpdateUserMutation = `mutation( - $updateUserOptions: UserManagementUpdateUser!, -) { userManagementUpdateUser( - updateUserOptions: $updateUserOptions, -) { - user { - email - emailVerificationState - groups { - nextCursor - totalCount - } - id - lastActive - name - pendingUpgradeRequest { - id - message - } - timeZone - type { - displayName - id - } } } }` @@ -404,17 +117,6 @@ func (a *Usermanagement) GetAuthenticationDomainsWithContext( "id": iD, } - // The following two conditions are not generated by Tutone, but have been added to make these variables optional in the query - // to return results (fetch ALL authentication domains) in the event of no cursor and ID being specified. - // DO NOT DISCARD THESE CHANGES (conditions to delete cursor and id from the variables map) - if cursor == "" { - delete(vars, "cursor") - } - - if len(iD) == 0 { - delete(vars, "id") - } - if err := a.client.NerdGraphQueryWithContext(ctx, getAuthenticationDomainsQuery, vars, &resp); err != nil { return nil, err } diff --git a/pkg/usermanagement/usermanagement_integration_test.go b/pkg/usermanagement/usermanagement_integration_test.go new file mode 100644 index 000000000..e69de29bb