Updated on 2024-02-21 GMT+08:00

Creating a Role

Function

This API is used to create a role.

URI

POST /v1/{project_id}/instances/{instance_id}/roles

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For how to obtain the project ID, see Obtaining a Project ID (lakeformation_04_0026.xml).

instance_id

Yes

String

LakeFormation instance ID. The value is automatically generated when the instance is created, for example, 2180518f-42b8-4947-b20b-adfc53981a25.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

Array of strings

Tenant token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

role_name

Yes

String

Role name. The value should contain 1 to 255 characters. Only letters, numbers, hyphens (-), and underscores (_) are allowed.

description

No

String

Description. Enter a maximum of 4,000 characters.

parameters

No

Map<String,String>

Parameter.

external_role_id

No

String

User role ID, which is specified during creation and cannot be changed.

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

role_name

String

Role name. The value should contain 1 to 255 characters. Only letters, numbers, hyphens (-), and underscores (_) are allowed.

description

String

Description. Enter a maximum of 4,000 characters. If there is no description, the value of description is null. If the value is null, the response body does not contain this parameter.

principal_source

String

Entity source. IAM: cloud user SAML: SAML-based federation. LDAP: ID user LOCAL: local user AGENTTENANT: agency OTHER: others

Enumeration values:

  • IAM

  • SAML

  • LDAP

  • LOCAL

  • AGENTTENANT

  • OTHER

parameters

Map<String,String>

Parameter.

external_role_id

String

User role ID, which is specified during creation and cannot be changed.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

solution_msg

String

Solution.

Status code: 404

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

solution_msg

String

Solution.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

solution_msg

String

Solution.

Example Requests

POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/roles

{
  "role_name" : "admin",
  "description" : "role from lakeformation"
}

Example Responses

Status code: 201

Created

{
  "role_name" : "admin",
  "principal_source" : " LOCAL ",
  "description" : "role from lakeformation"
}

Status code: 400

Bad Request

{
  "error_code" : "common.01000001",
  "error_msg" : "failed to read http request, please check your input, code: 400, reason: Type mismatch., cause: TypeMismatchException"
}

Status code: 401

Unauthorized

{
  "error_code": 'APIG.1002',
  "error_msg": 'Incorrect token or token resolution failed'
}

Status code: 403

Forbidden

{
  "error" : {
    "code" : "403",
    "message" : "X-Auth-Token is invalid in the request",
    "error_code" : null,
    "error_msg" : null,
    "title" : "Forbidden"
  },
  "error_code" : "403",
  "error_msg" : "X-Auth-Token is invalid in the request",
  "title" : "Forbidden"
}

Status code: 404

Not Found

{
  "error_code" : "common.01000001",
  "error_msg" : "response status exception, code: 404"
}

Status code: 408

Request Timeout

{
  "error_code" : "common.00000408",
  "error_msg" : "timeout exception occurred"
}

Status code: 500

Internal Server Error

{
  "error_code" : "common.00000500",
  "error_msg" : "internal error"
}

Status Codes

Status Code

Description

201

Created

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

408

Request Timeout

500

Internal Server Error

Error Codes

See Error Codes.