创建

描述

object mediatype.create(object/array **mediaTypes**)

此方法允许创建新的媒介类型

参数

(object/array)创建媒介类型

该方法接受媒介类型关于 standard media type properties

返回值

(object) 返回一个包含在“mediatypeids”属性下创建的媒体类型的ids的对象,返回id的顺序与传递的媒介类型的顺序匹配。

示例如下

创建一个媒介类型

创建一个新的邮件媒介类型

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "mediatype.create",
  4. "params": {
  5. "description": "E-mail",
  6. "type": 0,
  7. "smtp_server": "[email protected]",
  8. "smtp_helo": "company.com",
  9. "smtp_email": "[email protected]"
  10. },
  11. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  12. "id": 1
  13. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "mediatypeids": [
  5. "7"
  6. ]
  7. },
  8. "id": 1
  9. }

创建具有自定义选项的媒体类型

创建一个具有自定义值的新脚本媒体类型,用于尝试次数和尝试间隔。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "mediatype.create",
  4. "params": {
  5. "type": 1,
  6. "description": "Push notifications",
  7. "exec_path": "push-notification.sh",
  8. "exec_params": "{ALERT.SENDTO}\n{ALERT.SUBJECT}\n{ALERT.MESSAGE}\n",
  9. "maxattempts": "5",
  10. "attempt_interval": "11s"
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "mediatypeids": [
  5. "8"
  6. ]
  7. },
  8. "id": 1
  9. }

CMediaType::create() in frontends/php/include/classes/api/services/CMediaType.php.