[comment]: # translation:outdated

[comment]: # ({312e3a40-312e3a40})
# role.create

[comment]: # ({/312e3a40-312e3a40})

[comment]: # ({4fbfaef2-17ca7358})
### 説明

`object role.create(object/array roles)`

このメソッドで、新しいロールを作成できます。

::: noteclassic
このメソッドは*Super admin*ユーザータイプでのみ使用できます。 メソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。 詳細については[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

[comment]: # ({/4fbfaef2-17ca7358})

[comment]: # ({9ab16382-be3f23e2})
### パラメータ

`(object/array)` 作成するロール

このメソッドは[標準のロールプロパティ](object#role)に加えて、次のパラメーターを受け入れます。

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|rules|array|ロール用に作成されるロール[ルール](object#role_rules)|

[comment]: # ({/9ab16382-be3f23e2})

[comment]: # ({f343e9f2-f343e9f2})
### 戻り値

`(object)` `roleids`プロパティの下に作成されたロールのIDを含むオブジェクトを返します。 返されるIDの順序は、渡されたロールの順序と一致します。

[comment]: # ({/f343e9f2-f343e9f2})

[comment]: # ({b41637d2-b41637d2})
### 例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({02c7262b-7e61457f})
#### ロールの作成

タイプが"ユーザー"で、2つのUI要素へのアクセスを拒否するロールを作成します。

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "role.create",
    "params": {
        "name": "Operator",
        "type": "1",
        "rules": {
            "ui": [
                {
                    "name": "monitoring.hosts",
                    "status": "0"
                },
                {
                    "name": "monitoring.maps",
                    "status": "0"
                }
            ]
        }
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "roleids": [
            "5"
        ]
    },
    "id": 1
}
```

[comment]: # ({/02c7262b-7e61457f})

[comment]: # ({c3d5b904-c3d5b904})
### 参照

-   [Role rules](object#role_rules)
-   [UI element](object#ui_element)
-   [Module](object#module)
-   [Action](object#action)

[comment]: # ({/c3d5b904-c3d5b904})

[comment]: # ({4b30d86c-4b30d86c})
### ソース

CRole::create() in *ui/include/classes/api/services/CRole.php*.

[comment]: # ({/4b30d86c-4b30d86c})
