文档目录

安全策略定时计划相关接口

创建安全策略定时计划(CreateNetworkSecurityPolicySchedule)

API请求

URLs
POST zstack/v1/network-security-policy-schedules
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "office-hours",
    "description": "Weekday office hours",
    "resourceType": "SecurityGroup",
    "resourceUuid": "d1a544b28f443966aa454aa2f6fc4ba9",
    "timeType": "UTC",
    "repeatType": "Weekly",
    "startDate": "2026-01-01",
    "endDate": "2026-12-31",
    "startTime": "09:00",
    "endTime": "18:00",
    "weekDays": [
      1,
      2,
      3,
      4,
      5
    ]
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"office-hours","description":"Weekday office hours","resourceType":"SecurityGroup","resourceUuid":"d1a544b28f443966aa454aa2f6fc4ba9","timeType":"UTC","repeatType":"Weekly","startDate":"2026-01-01","endDate":"2026-12-31","startTime":"09:00","endTime":"18:00","weekDays":[1,2,3,4,5]}}' \
http://localhost:8080/zstack/v1/network-security-policy-schedules
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 名称 5.5.38
description (可选) String body(包含在params结构中) 描述 5.5.38
resourceType String body(包含在params结构中) 所属资源类型
  • SecurityGroup
  • VpcFirewallRuleSet
5.5.38
resourceUuid String body(包含在params结构中) 所属资源UUID 5.5.38
timeType String body(包含在params结构中) 时间类型,Local 或 UTC
  • Local
  • UTC
5.5.38
repeatType String body(包含在params结构中) 计划类型
  • Once
  • Weekly
5.5.38
startDate String body(包含在params结构中) 开始日期,格式yyyy-MM-dd 5.5.38
endDate String body(包含在params结构中) 结束日期,格式yyyy-MM-dd 5.5.38
startTime String body(包含在params结构中) 开始时间,格式HH:mm 5.5.38
endTime String body(包含在params结构中) 结束时间,格式HH:mm;Weekly使用00:00至00:00表示全天 5.5.38
weekDays (可选) List body(包含在params结构中) Weekly生效星期,1表示周一,7表示周日 5.5.38
systemTags (可选) List body 系统标签 5.5.38
userTags (可选) List body 用户标签 5.5.38

API返回

返回示例
{
  "inventory": {
    "uuid": "4c4aa4f9b7254d76b48ad99f6a20c9ee",
    "name": "office-hours",
    "description": "Weekday office hours",
    "resourceType": "SecurityGroup",
    "resourceUuid": "f1a72f89f9624c92a84cbd07347be003",
    "timeType": "UTC",
    "repeatType": "Weekly",
    "startDate": "2026-01-01",
    "endDate": "2026-12-31",
    "startTime": "09:00",
    "endTime": "18:00",
    "weekDays": [
      1,
      2,
      3,
      4,
      5
    ],
    "timeStatus": "InWindow",
    "expiring": false,
    "createDate": "Jan 1, 2026 12:00:00 AM",
    "lastOpDate": "Jan 1, 2026 12:00:00 AM"
  }
}
名字 类型 描述 起始版本
success boolean 操作是否成功 5.5.38
error ErrorCode 详情参考error 5.5.38
inventory NetworkSecurityPolicyScheduleInventory 详情参考inventory 5.5.38
#inventory
名字 类型 描述 起始版本
uuid String 定时计划UUID 5.5.38
name String 名称 5.5.38
description String 描述 5.5.38
resourceType String 所属资源类型 5.5.38
resourceUuid String 所属资源UUID 5.5.38
timeType String 时间类型,Local 或 UTC 5.5.38
repeatType String Once 或 Weekly 5.5.38
startDate String 开始日期,格式yyyy-MM-dd 5.5.38
endDate String 结束日期,格式yyyy-MM-dd 5.5.38
startTime String 开始时间,格式HH:mm 5.5.38
endTime String 结束时间,格式HH:mm 5.5.38
weekDays List Weekly生效星期 5.5.38
expiring boolean 距离最后一个有效窗口结束大于0且不足24小时 5.5.38
createDate Timestamp 创建时间 5.5.38
lastOpDate Timestamp 最后修改时间 5.5.38
timeStatus NetworkSecurityPolicyScheduleTimeStatus 详情参考timeStatus 5.5.38
#timeStatus
名字 类型 描述 起始版本
NotStarted NetworkSecurityPolicyScheduleTimeStatus 尚未到整体开始边界 5.5.38
InWindow NetworkSecurityPolicyScheduleTimeStatus 当前分钟处于有效时间窗口 5.5.38
OutOfWindow NetworkSecurityPolicyScheduleTimeStatus 当前不在有效时间窗口,但仍存在后续有效窗口 5.5.38
Ended NetworkSecurityPolicyScheduleTimeStatus 已不存在后续有效窗口 5.5.38
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如 SYS.1000、HOST.1001 5.3.20
description String 错误的概要描述 5.3.20
details String 错误的详细信息 5.3.20
elaboration String 保留字段,默认为null 5.3.20
opaque LinkedHashMap 保留字段,默认为null 5.3.20
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 5.3.20

SDK示例

Java SDK
CreateNetworkSecurityPolicyScheduleAction action = new CreateNetworkSecurityPolicyScheduleAction();
action.name = "office-hours";
action.description = "Weekday office hours";
action.resourceType = "SecurityGroup";
action.resourceUuid = "d1a544b28f443966aa454aa2f6fc4ba9";
action.timeType = "UTC";
action.repeatType = "Weekly";
action.startDate = "2026-01-01";
action.endDate = "2026-12-31";
action.startTime = "09:00";
action.endTime = "18:00";
action.weekDays = asList(1,2,3,4,5);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateNetworkSecurityPolicyScheduleAction.Result res = action.call();
Python SDK
action = CreateNetworkSecurityPolicyScheduleAction()
action.name = "office-hours"
action.description = "Weekday office hours"
action.resourceType = "SecurityGroup"
action.resourceUuid = "d1a544b28f443966aa454aa2f6fc4ba9"
action.timeType = "UTC"
action.repeatType = "Weekly"
action.startDate = "2026-01-01"
action.endDate = "2026-12-31"
action.startTime = "09:00"
action.endTime = "18:00"
action.weekDays = [1, 2, 3, 4, 5]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

删除安全策略定时计划(DeleteNetworkSecurityPolicySchedule)

API请求

URLs
DELETE zstack/v1/network-security-policy-schedules/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE \
http://localhost:8080/zstack/v1/network-security-policy-schedules/d2dd5f75e21f3a7bb196887388092856
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 定时计划UUID 5.5.38
deleteMode (可选) String body 删除模式 5.5.38
systemTags (可选) List body 系统标签 5.5.38
userTags (可选) List body 用户标签 5.5.38

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK示例

Java SDK
DeleteNetworkSecurityPolicyScheduleAction action = new DeleteNetworkSecurityPolicyScheduleAction();
action.uuid = "d2dd5f75e21f3a7bb196887388092856";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteNetworkSecurityPolicyScheduleAction.Result res = action.call();
Python SDK
action = DeleteNetworkSecurityPolicyScheduleAction()
action.uuid = "d2dd5f75e21f3a7bb196887388092856"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

获取资源的安全策略定时计划(GetNetworkSecurityPolicySchedule)

API请求

URLs
GET zstack/v1/network-security-policy-schedules
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET \
http://localhost:8080/zstack/v1/network-security-policy-schedules?resourceUuid=ff9de337b8e93ddd8d0e384d7314c028&timeStatus=OutOfWindow&repeatType=Weekly&timeType=UTC
参数列表
名字 类型 位置 描述 可选值 起始版本
resourceUuid String query 资源UUID 5.5.38
timeStatus (可选) String query 时间状态
  • NotStarted
  • InWindow
  • OutOfWindow
  • Ended
5.5.38
repeatType (可选) String query 计划类型
  • Once
  • Weekly
5.5.38
timeType (可选) String query 时区类型
  • Local
  • UTC
5.5.38
systemTags (可选) List query 系统标签 5.5.38
userTags (可选) List query 用户标签 5.5.38

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "4c4aa4f9b7254d76b48ad99f6a20c9ee",
      "name": "office-hours",
      "description": "Weekday office hours",
      "resourceType": "SecurityGroup",
      "resourceUuid": "f1a72f89f9624c92a84cbd07347be003",
      "timeType": "UTC",
      "repeatType": "Weekly",
      "startDate": "2026-01-01",
      "endDate": "2026-12-31",
      "startTime": "09:00",
      "endTime": "18:00",
      "weekDays": [
        1,
        2,
        3,
        4,
        5
      ],
      "timeStatus": "InWindow",
      "expiring": false,
      "createDate": "Jan 1, 2026 12:00:00 AM",
      "lastOpDate": "Jan 1, 2026 12:00:00 AM"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 操作是否成功 5.5.38
error ErrorCode 详情参考error 5.5.38
inventories List 所属资源下的定时计划列表 5.5.38
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如 SYS.1000、HOST.1001 5.3.20
description String 错误的概要描述 5.3.20
details String 错误的详细信息 5.3.20
elaboration String 保留字段,默认为null 5.3.20
opaque LinkedHashMap 保留字段,默认为null 5.3.20
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 5.3.20

SDK示例

Java SDK
GetNetworkSecurityPolicyScheduleAction action = new GetNetworkSecurityPolicyScheduleAction();
action.resourceUuid = "ff9de337b8e93ddd8d0e384d7314c028";
action.timeStatus = "OutOfWindow";
action.repeatType = "Weekly";
action.timeType = "UTC";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetNetworkSecurityPolicyScheduleAction.Result res = action.call();
Python SDK
action = GetNetworkSecurityPolicyScheduleAction()
action.resourceUuid = "ff9de337b8e93ddd8d0e384d7314c028"
action.timeStatus = "OutOfWindow"
action.repeatType = "Weekly"
action.timeType = "UTC"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

设置资源当前使用的安全策略定时计划;不传scheduleUuid时取消当前设置(SetNetworkSecurityPolicySchedule)

API请求

URLs
PUT zstack/v1/network-security-policy-schedules/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "setNetworkSecurityPolicySchedule": {
    "scheduleUuid": "e789526dcde034068670924472952842",
    "resourceType": "SecurityGroup",
    "resourceUuid": "e32979f01e2f3f32a6eafcfb26b985d0"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"setNetworkSecurityPolicySchedule":{"scheduleUuid":"e789526dcde034068670924472952842","resourceType":"SecurityGroup","resourceUuid":"e32979f01e2f3f32a6eafcfb26b985d0"}}' \
http://localhost:8080/zstack/v1/network-security-policy-schedules/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
scheduleUuid (可选) String body(包含在setNetworkSecurityPolicySchedule结构中) 定时计划UUID;为空时取消当前设置 5.5.38
resourceType String body(包含在setNetworkSecurityPolicySchedule结构中) 目标资源类型
  • SecurityGroup
  • VpcFirewallRuleSet
5.5.38
resourceUuid String body(包含在setNetworkSecurityPolicySchedule结构中) 目标资源UUID 5.5.38
systemTags (可选) List body 系统标签 5.5.38
userTags (可选) List body 用户标签 5.5.38

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK示例

Java SDK
SetNetworkSecurityPolicyScheduleAction action = new SetNetworkSecurityPolicyScheduleAction();
action.scheduleUuid = "e789526dcde034068670924472952842";
action.resourceType = "SecurityGroup";
action.resourceUuid = "e32979f01e2f3f32a6eafcfb26b985d0";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetNetworkSecurityPolicyScheduleAction.Result res = action.call();
Python SDK
action = SetNetworkSecurityPolicyScheduleAction()
action.scheduleUuid = "e789526dcde034068670924472952842"
action.resourceType = "SecurityGroup"
action.resourceUuid = "e32979f01e2f3f32a6eafcfb26b985d0"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

全量修改安全策略定时计划(UpdateNetworkSecurityPolicySchedule)

API请求

URLs
PUT zstack/v1/network-security-policy-schedules/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateNetworkSecurityPolicySchedule": {
    "name": "office-hours",
    "description": "Weekday office hours",
    "timeType": "UTC",
    "repeatType": "Weekly",
    "startDate": "2026-01-01",
    "endDate": "2026-12-31",
    "startTime": "09:00",
    "endTime": "18:00",
    "weekDays": [
      1,
      2,
      3,
      4,
      5
    ]
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateNetworkSecurityPolicySchedule":{"name":"office-hours","description":"Weekday office hours","timeType":"UTC","repeatType":"Weekly","startDate":"2026-01-01","endDate":"2026-12-31","startTime":"09:00","endTime":"18:00","weekDays":[1,2,3,4,5]}}' \
http://localhost:8080/zstack/v1/network-security-policy-schedules/a293605961af30939fddccb54074b85e/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 定时计划UUID 5.5.38
name String body(包含在updateNetworkSecurityPolicySchedule结构中) 名称 5.5.38
description (可选) String body(包含在updateNetworkSecurityPolicySchedule结构中) 描述;不传则清空 5.5.38
timeType String body(包含在updateNetworkSecurityPolicySchedule结构中) 时间类型,Local 或 UTC
  • Local
  • UTC
5.5.38
repeatType String body(包含在updateNetworkSecurityPolicySchedule结构中) 计划类型
  • Once
  • Weekly
5.5.38
startDate String body(包含在updateNetworkSecurityPolicySchedule结构中) 开始日期,格式yyyy-MM-dd 5.5.38
endDate String body(包含在updateNetworkSecurityPolicySchedule结构中) 结束日期,格式yyyy-MM-dd 5.5.38
startTime String body(包含在updateNetworkSecurityPolicySchedule结构中) 开始时间,格式HH:mm 5.5.38
endTime String body(包含在updateNetworkSecurityPolicySchedule结构中) 结束时间,格式HH:mm;Weekly使用00:00至00:00表示全天 5.5.38
weekDays (可选) List body(包含在updateNetworkSecurityPolicySchedule结构中) Weekly生效星期,1表示周一,7表示周日 5.5.38
systemTags (可选) List body 系统标签 5.5.38
userTags (可选) List body 用户标签 5.5.38

API返回

返回示例
{
  "inventory": {
    "uuid": "4c4aa4f9b7254d76b48ad99f6a20c9ee",
    "name": "office-hours",
    "description": "Weekday office hours",
    "resourceType": "SecurityGroup",
    "resourceUuid": "f1a72f89f9624c92a84cbd07347be003",
    "timeType": "UTC",
    "repeatType": "Weekly",
    "startDate": "2026-01-01",
    "endDate": "2026-12-31",
    "startTime": "09:00",
    "endTime": "18:00",
    "weekDays": [
      1,
      2,
      3,
      4,
      5
    ],
    "timeStatus": "InWindow",
    "expiring": false,
    "createDate": "Jan 1, 2026 12:00:00 AM",
    "lastOpDate": "Jan 1, 2026 12:00:00 AM"
  }
}
名字 类型 描述 起始版本
success boolean 操作是否成功 5.5.38
error ErrorCode 详情参考error 5.5.38
inventory NetworkSecurityPolicyScheduleInventory 详情参考inventory 5.5.38
#inventory
名字 类型 描述 起始版本
uuid String 定时计划UUID 5.5.38
name String 名称 5.5.38
description String 描述 5.5.38
resourceType String 所属资源类型 5.5.38
resourceUuid String 所属资源UUID 5.5.38
timeType String 时间类型,Local 或 UTC 5.5.38
repeatType String Once 或 Weekly 5.5.38
startDate String 开始日期,格式yyyy-MM-dd 5.5.38
endDate String 结束日期,格式yyyy-MM-dd 5.5.38
startTime String 开始时间,格式HH:mm 5.5.38
endTime String 结束时间,格式HH:mm 5.5.38
weekDays List Weekly生效星期 5.5.38
expiring boolean 距离最后一个有效窗口结束大于0且不足24小时 5.5.38
createDate Timestamp 创建时间 5.5.38
lastOpDate Timestamp 最后修改时间 5.5.38
timeStatus NetworkSecurityPolicyScheduleTimeStatus 详情参考timeStatus 5.5.38
#timeStatus
名字 类型 描述 起始版本
NotStarted NetworkSecurityPolicyScheduleTimeStatus 尚未到整体开始边界 5.5.38
InWindow NetworkSecurityPolicyScheduleTimeStatus 当前分钟处于有效时间窗口 5.5.38
OutOfWindow NetworkSecurityPolicyScheduleTimeStatus 当前不在有效时间窗口,但仍存在后续有效窗口 5.5.38
Ended NetworkSecurityPolicyScheduleTimeStatus 已不存在后续有效窗口 5.5.38
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如 SYS.1000、HOST.1001 5.3.20
description String 错误的概要描述 5.3.20
details String 错误的详细信息 5.3.20
elaboration String 保留字段,默认为null 5.3.20
opaque LinkedHashMap 保留字段,默认为null 5.3.20
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 5.3.20

SDK示例

Java SDK
UpdateNetworkSecurityPolicyScheduleAction action = new UpdateNetworkSecurityPolicyScheduleAction();
action.uuid = "a293605961af30939fddccb54074b85e";
action.name = "office-hours";
action.description = "Weekday office hours";
action.timeType = "UTC";
action.repeatType = "Weekly";
action.startDate = "2026-01-01";
action.endDate = "2026-12-31";
action.startTime = "09:00";
action.endTime = "18:00";
action.weekDays = asList(1,2,3,4,5);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateNetworkSecurityPolicyScheduleAction.Result res = action.call();
Python SDK
action = UpdateNetworkSecurityPolicyScheduleAction()
action.uuid = "a293605961af30939fddccb54074b85e"
action.name = "office-hours"
action.description = "Weekday office hours"
action.timeType = "UTC"
action.repeatType = "Weekly"
action.startDate = "2026-01-01"
action.endDate = "2026-12-31"
action.startTime = "09:00"
action.endTime = "18:00"
action.weekDays = [1, 2, 3, 4, 5]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
开发手册 | 5.5.38 | ZStack Cloud · ZCF | ZStack 资源中心