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(graphQL-apis): Added mutations for creating, updating, and delet… #19971

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions src/content/docs/apis/nerdgraph/examples/nerdgraph-manage-groups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,129 @@ Here's an example response:
},
```

## Create a role [#create-role]

Here's an example of creating a [role](/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#roles):

```graphql
mutation {
customRoleCreate(
container: {
id: "$YOUR_ORGANIZATION_ID"
type: "ORGANIZATION"
}
name: "MY CUSTOM ROLE"
permissionIds: [1,2,3]
scope: "ACCOUNT"
) {
id
}
}
```
### Parameters
- `container`:
- `id`: (String) The unique identifier of your organization. Replace $YOUR_ORGANIZATION_ID with your actual organization ID.
- `type`: (String) The type of container. Currently, the only supported type is "ORGANIZATION".
- `name`: (String) The name assigned to the custom role. Example: "MY CUSTOM ROLE".
- `permissionIds`: (Array) A list of permission IDs representing the capabilities assigned to the custom role. Ensure these IDs correspond to valid permissions in your system.
- `scope`: (String) The level at which the role's permissions apply. In this instance, the scope is "ACCOUNT".

### Response
- `id`: Returns the unique ID of the newly created custom role.

<Callout variant="important">
- Replace `$YOUR_ORGANIZATION_ID` with your specific organization ID before executing the mutation.
- Ensure that the `permissionIds` provided are valid and align with the permissions you want to grant.
</Callout>

Before you create a custom role, you have to identify the permissions you want to assign to it.

Use the following query to retrieve the list of permissions:

```graphql
mutation {
customerAdministration {
permissions {
items {
category
feature
id
product
subsetIds
}
nextCursor
}
}
}
```
This returns account-scoped permissions. For permissions scoped to an org, run the following query instead:

```graphql
{
customerAdministration {
permissions(filter: {scope: {eq: "organization"}}) {
items {
category
feature
id
product
subsetIds
}
nextCursor
}
}
}
```

Note the following fields:
- `items`: An array of permission objects, each containing the following attributes:
- `category`: (String) The category or grouping the permission belongs to.
- `feature`: (String) The specific feature the permission is associated with.
- `id`: (String) A unique identifier for each permission.
- `product`: (String) The product that the permission applies to.
- `subsetIds`: (Array) A list of IDs representing subsets or related permissions.

After you have the unique identifier for each permission you want to assign to the new role, create that role.

## Update role [#update-role]

Here's an example of updating a [role](/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#roles).

```graphql
mutation {
customRoleUpdate(
id: $ROLE_ID
name: "MY NEW CUSTOM ROLE NAME"
permissionIds: [4,5,6]
) {
id
}
}
```

### Parameters
- `id`: The unique identifier of the custom role you wish to modify. Replace `$ROLE_ID` with the actual ID of the role.
- `name`: The new name you want to assign to the custom role. In this example, it's `MY NEW CUSTOM ROLE NAME`.
- `permissionIds`: An array of permission IDs you want to assign to this role. Ensure these IDs are valid and correspond to the permissions you intend to implement.

## Delete a role [#delete-role]
Here's an example of deleting a [role](/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#roles):

```graphql
mutation {
customRoleDelete(
id: $ROLE_ID
) {
id
}
}
```

### Parameters
- `id`: The unique identifier of the role you wish to delete. Replace `$ROLE_ID` with the actual ID of the role you want to remove.
### Response
- `id`: Returns the ID of the role that has been deleted, confirming the successful execution of the mutation.

## Create a group [#create-group]

Here's an example of creating a [group](/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#groups):
Expand Down
Loading