Skip to content

Latest commit

 

History

History
808 lines (579 loc) · 26.9 KB

File metadata and controls

808 lines (579 loc) · 26.9 KB

datadog-api-client.v2.RolesApi

All URIs are relative to https://api.datadoghq.com

Method HTTP request Description
addPermissionToRole POST /api/v2/roles/{role_id}/permissions Grant permission to a role
addUserToRole POST /api/v2/roles/{role_id}/users Add a user to a role
createRole POST /api/v2/roles Create role
deleteRole DELETE /api/v2/roles/{role_id} Delete role
getRole GET /api/v2/roles/{role_id} Get a role
listPermissions GET /api/v2/permissions List permissions
listRolePermissions GET /api/v2/roles/{role_id}/permissions List permissions for a role
listRoleUsers GET /api/v2/roles/{role_id}/users Get all users of a role
listRoles GET /api/v2/roles List roles
removePermissionFromRole DELETE /api/v2/roles/{role_id}/permissions Revoke permission
removeUserFromRole DELETE /api/v2/roles/{role_id}/users Remove a user from a role
updateRole PATCH /api/v2/roles/{role_id} Update a role

addPermissionToRole

PermissionsResponse addPermissionToRole(body)

Adds a permission to a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiAddPermissionToRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // RelationshipToPermission
  body: {
    data: {
      id: "id_example",
      type: "permissions",
    },
  },
};

apiInstance
  .addPermissionToRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RelationshipToPermission
roleId [string] The ID of the role. defaults to undefined

Return type

PermissionsResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

addUserToRole

UsersResponse addUserToRole(body)

Adds a user to a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiAddUserToRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // RelationshipToUser
  body: {
    data: {
      id: "00000000-0000-0000-0000-000000000000",
      type: "users",
    },
  },
};

apiInstance
  .addUserToRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RelationshipToUser
roleId [string] The ID of the role. defaults to undefined

Return type

UsersResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

createRole

RoleCreateResponse createRole(body)

Create a new role for your organization.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiCreateRoleRequest = {
  // RoleCreateRequest
  body: {
    data: {
      attributes: {
        name: "developers",
      },
      relationships: {
        permissions: {
          data: [
            {
              id: "id_example",
              type: "permissions",
            },
          ],
        },
        users: {
          data: [],
        },
      },
      type: "roles",
    },
  },
};

apiInstance
  .createRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RoleCreateRequest

Return type

RoleCreateResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteRole

void deleteRole()

Disables a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiDeleteRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
};

apiInstance
  .deleteRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
roleId [string] The ID of the role. defaults to undefined

Return type

void

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
204 OK -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getRole

RoleResponse getRole()

Get a role in the organization specified by the role’s role_id.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiGetRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
};

apiInstance
  .getRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
roleId [string] The ID of the role. defaults to undefined

Return type

RoleResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listPermissions

PermissionsResponse listPermissions()

Returns a list of all permissions, including name, description, and ID.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

apiInstance
  .listPermissions()
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

PermissionsResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listRolePermissions

PermissionsResponse listRolePermissions()

Returns a list of all permissions for a single role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiListRolePermissionsRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
};

apiInstance
  .listRolePermissions(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
roleId [string] The ID of the role. defaults to undefined

Return type

PermissionsResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listRoleUsers

UsersResponse listRoleUsers()

Gets all users of a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiListRoleUsersRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // number | Size for a given page. (optional)
  pageSize: 10,
  // number | Specific page number to return. (optional)
  pageNumber: 0,
  // string | User attribute to order results by. Sort order is **ascending** by default. Sort order is **descending** if the field is prefixed by a negative sign, for example `sort=-name`. Options: `name`, `email`, `status`. (optional)
  sort: "name",
  // string | Filter all users by the given string. Defaults to no filtering. (optional)
  filter: "filter_example",
};

apiInstance
  .listRoleUsers(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
roleId [string] The ID of the role. defaults to undefined
pageSize [number] Size for a given page. (optional) defaults to 10
pageNumber [number] Specific page number to return. (optional) defaults to 0
sort [string] User attribute to order results by. Sort order is ascending by default. Sort order is descending if the field is prefixed by a negative sign, for example `sort=-name`. Options: `name`, `email`, `status`. (optional) defaults to 'name'
filter [string] Filter all users by the given string. Defaults to no filtering. (optional) defaults to undefined

Return type

UsersResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listRoles

RolesResponse listRoles()

Returns all roles, including their names and IDs.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiListRolesRequest = {
  // number | Size for a given page. (optional)
  pageSize: 10,
  // number | Specific page number to return. (optional)
  pageNumber: 0,
  // RolesSort | Sort roles depending on the given field. Sort order is **ascending** by default. Sort order is **descending** if the field is prefixed by a negative sign, for example: `sort=-name`. (optional)
  sort: "name",
  // string | Filter all roles by the given string. (optional)
  filter: "filter_example",
};

apiInstance
  .listRoles(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
pageSize [number] Size for a given page. (optional) defaults to 10
pageNumber [number] Specific page number to return. (optional) defaults to 0
sort RolesSort Sort roles depending on the given field. Sort order is ascending by default. Sort order is descending if the field is prefixed by a negative sign, for example: `sort=-name`. (optional) defaults to undefined
filter [string] Filter all roles by the given string. (optional) defaults to undefined

Return type

RolesResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
403 Authentication error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

removePermissionFromRole

PermissionsResponse removePermissionFromRole(body)

Removes a permission from a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiRemovePermissionFromRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // RelationshipToPermission
  body: {
    data: {
      id: "id_example",
      type: "permissions",
    },
  },
};

apiInstance
  .removePermissionFromRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RelationshipToPermission
roleId [string] The ID of the role. defaults to undefined

Return type

PermissionsResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

removeUserFromRole

UsersResponse removeUserFromRole(body)

Removes a user from a role.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiRemoveUserFromRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // RelationshipToUser
  body: {
    data: {
      id: "00000000-0000-0000-0000-000000000000",
      type: "users",
    },
  },
};

apiInstance
  .removeUserFromRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RelationshipToUser
roleId [string] The ID of the role. defaults to undefined

Return type

UsersResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -
404 Not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updateRole

RoleUpdateResponse updateRole(body)

Edit a role. Can only be used with application keys belonging to administrators.

Example

import { v2 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v2.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);

let params: v2.RolesApiUpdateRoleRequest = {
  // string | The ID of the role.
  roleId: "role_id_example",
  // RoleUpdateRequest
  body: {
    data: {
      attributes: {
        name: "name_example",
      },
      id: "00000000-0000-0000-0000-000000000000",
      type: "roles",
    },
  },
};

apiInstance
  .updateRole(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Parameters

Name Type Description Notes
body RoleUpdateRequest
roleId [string] The ID of the role. defaults to undefined

Return type

RoleUpdateResponse

Authorization

AuthZ, apiKeyAuth, appKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
400 Bad Request -
403 Authentication error -
404 Not found -
422 Unprocessable Entity -

[Back to top] [Back to API list] [Back to Model list] [Back to README]