Skip to content

Edit role

PUT
/v1/roles/{roleID}
curl --request PUT \
--url https://api.defined.net/v1/roles/role-LO4SPDSWTZNJC676WFCZKUB3ZQ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "description": "example", "firewallRules": [ { "protocol": "example", "description": "example", "allowedRoleID": "example", "allowedTags": [ "example" ], "portRange": { "from": 1, "to": 1 } } ] }'

Token scope required: roles:update

Caution: Any properties not provided in the request will be reset to their default values. If only changing one firewall rule, be sure to include the others as well, otherwise they will be removed.

roleID
required
string

Example

role-LO4SPDSWTZNJC676WFCZKUB3ZQ
Media typeapplication/json
object
description
string
<= 255 characters
firewallRules

Incoming firewall rules. Will replace existing list of rules.

Array<object>
<= 50 items
object
protocol
required

One of ANY, TCP, UDP or ICMP when creating or updating a rule. Responses may include protocols added later, so clients should accept values not listed here.

string
description
string
<= 255 characters
allowedRoleID

Role ID to allow with this firewall rule. If not specified, all roles are included.

string | null
allowedTags

Tags to allow with this firewall rule. An empty list allows all tags; responses return null instead of an empty list. key is max 20 characters, value is max 50 characters, no whitespace around either allowed

Array<string> | null
portRange

Range of ports for this firewall rule. If not provided or set to null, all ports are allowed.

object
from
required

First port number included in range.

integer
>= 1 <= 65535
to
required

Last port number included in range. Must be greater than from port.

integer
>= 1 <= 65535

Example generated

{
"description": "example",
"firewallRules": [
{
"protocol": "example",
"description": "example",
"allowedRoleID": "example",
"allowedTags": [
"example"
],
"portRange": {
"from": 1,
"to": 1
}
}
]
}

Successful operation

Media typeapplication/json
object
data
required
object
id
required
string
name
required
string
description
required
string
firewallRules
required
Array
object
protocol
required

One of ANY, TCP, UDP or ICMP when creating or updating a rule. Responses may include protocols added later, so clients should accept values not listed here.

string
description
required
string
<= 255 characters
allowedRoleID
required

Role ID to allow with this firewall rule. If not specified, all roles are included.

string | null
allowedTags
required

Tags to allow with this firewall rule. An empty list allows all tags; responses return null instead of an empty list. key is max 20 characters, value is max 50 characters, no whitespace around either allowed

Array<string> | null
portRange
required

Range of ports for this firewall rule. If not provided or set to null, all ports are allowed.

object
from
required

First port number included in range.

integer
>= 1 <= 65535
to
required

Last port number included in range. Must be greater than from port.

integer
>= 1 <= 65535
createdAt
required
string format: date-time
hostCount
required

Number of hosts currently assigned to this role.

integer
modifiedAt
required
string format: date-time

Example

{
"data": {
"id": "role-LO4SPDSWTZNJC676WFCZKUB3ZQ",
"name": "My new role",
"description": "",
"hostCount": 0,
"createdAt": "2023-02-15T13:59:09Z",
"modifiedAt": "2023-02-15T13:59:09Z",
"firewallRules": [
{
"protocol": "TCP",
"description": "allow SSH access",
"allowedRoleID": "role-G3TWUQ4FASQEF44MGMTSRBTYKM",
"allowedTags": null,
"portRange": {
"from": 22,
"to": 22
}
}
]
}
}

Validation error

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Examples

Invalid protocol value.

{
"errors": [
{
"code": "ERR_INVALID_VALUE",
"message": "must be a valid protocol: ANY, TCP, UDP, ICMP",
"path": "firewallRules[0].protocol"
}
]
}

The API key is missing, invalid or expired.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Example

{
"errors": [
{
"code": "ERR_UNAUTHORIZED",
"message": "unauthorized"
}
]
}

The API key lacks a required scope.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Examples

ExamplemissingScope

The API key lacks a required scope.

{
"errors": [
{
"code": "ERR_FORBIDDEN",
"message": "api key must support the following scopes: hosts:read"
}
]
}

Role not found

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Example

{
"errors": [
{
"code": "ERR_NOT_FOUND",
"message": "resource not found"
}
]
}

The organization has exceeded its API request rate limit. Retry the request after a short delay.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Example

{
"errors": [
{
"code": "ERR_TOO_MANY_REQUESTS",
"message": "too many requests"
}
]
}