Skip to main content
Astra Automation
简体中文版经机器翻译而成,仅供参考。如与英语版出现任何冲突,应以英语版为准。

创建新的 hook 源

POST /accounts/{account_id}/core/v1/hookSources

指示要创建的 Hook Source API 资源的所需值。

参数

名称 Type Required Description

account_id

string

path

True

包含帐户资源的 ID

  • 示例:{{.Account}}

请求正文

指示要创建的 Hook Source API 资源的所需值。

名称 Type Required Description

type

string

True

资源的媒体类型。定义的值为:

  • "application/astra-hookSource"

version

string

True

资源的版本。定义的值为:

  • "1.0"

name

string

True

包含用户指定的资源名称的 JSON 字符串。定义的值是:

  • 最小长度:1

  • 最大长度:63 在所有挂钩源资源中,名称必须是唯一的。

sourceType

string

True

定义钩子源类型的 JSON 字符串。定义的值为:

  • "script" - Shell 脚本。明文源不得包含二进制数据或回车字符,否则返回错误。

string

True

包含要以 base64 格式运行的脚本的 JSON 字符串。定义的值为:

  • 最小长度:0

  • 最大长度:131072

  • 符合 base64 编码数据架构,使用 base64 编码时,源值的最大大小为 128 KiB。

description

string

False

包含用户指定的钩子源描述的 JSON 字符串。已定义的值为:

  • 最小长度:0

  • 最大长度:511

元数据

"type_astra_metadata_update"

False

与资源关联的客户端和服务指定的元数据。定义的值为:

  • 符合 Astra 元数据架构如果在创建时未指定,则将创建没有标签的元数据对象。如果在更新时未指定,则元数据对象的标签、creationTimestamp 和 createdBy 将保留而不进行修改。

请求示例
{
  "type": "application/astra-hookSource",
  "version": "1.0",
  "name": "Payroll script",
  "sourceType": "script",
  "source": "ZWNobyAiVkhKaGJuTWdVbWxuYUhSeklRPT0iIHwgYmFzZTY0IC1k",
  "description": "Pre and post hook script for payroll"
}

响应

Status: 201, Returns the newly created hookSource resource in the JSON response body.
名称 Type Required Description

type

string

True

资源的媒体类型。定义的值为:

  • "application/astra-hookSource"

version

string

True

资源的版本。定义的值为:

  • "1.0"

id

string

True

资源的全局唯一标识符。定义的值为:

  • 符合 UUIDv4 架构

name

string

True

包含用户指定的资源名称的 JSON 字符串。定义的值是:

  • 最小长度:1

  • 最大长度:63 在所有挂钩源资源中,名称必须是唯一的。

专用

string

True

JSON 字符串,指示源字段是在 API 中公开还是有意留空。定义的值为:

  • "true" - 源值是私有的,不会通过 API 公开。

  • "false" - 源值不是私有的,将通过 API 公开。

预加载

string

True

用于指示源是否已预加载的 JSON 字符串。定义的值是:

  • "true" - 源已预加载。

  • "false" - 未预加载源。预加载的挂钩源资源为只读。

sourceType

string

True

定义钩子源类型的 JSON 字符串。定义的值为:

  • "script" - Shell 脚本。明文源不得包含二进制数据或回车字符,否则返回错误。

string

False

包含要以 base64 格式运行的脚本的 JSON 字符串。定义的值为:

  • 最小长度:0

  • 最大长度:131072

  • 符合 base64 编码数据架构,使用 base64 编码时,源值的最大大小为 128 KiB。

sourceMD5Checksum

string

True

包含为"source"键值计算的 MD5 校验和的 JSON 字符串。定义的值为:

  • 定义的正则表达式为:"^([0-9a-fA-F]){32}$"

description

string

False

包含用户指定的钩子源描述的 JSON 字符串。已定义的值为:

  • 最小长度:0

  • 最大长度:511

元数据

"type_astra_metadata_update"

True

与资源关联的客户端和服务指定的元数据。定义的值为:

  • 符合 Astra 元数据架构如果在创建时未指定,则将创建没有标签的元数据对象。如果在更新时未指定,则元数据对象的标签、creationTimestamp 和 createdBy 将保留而不进行修改。

响应示例
{
  "type": "application/astra-hookSource",
  "version": "1.0",
  "id": "fae6dfbb-ecb8-58ff-a116-6357eb7c956a",
  "name": "Payroll script",
  "private": "false",
  "preloaded": "false",
  "sourceType": "script",
  "source": "ZWNobyAiVkhKaGJuTWdVbWxuYUhSeklRPT0iIHwgYmFzZTY0IC1k",
  "sourceMD5Checksum": "b1a4b8b0144c3f6be553b626130ca145",
  "description": "Pre and post hook script for payroll",
  "metadata": {
    "labels": [],
    "creationTimestamp": "2022-10-06T20:58:16.305662Z",
    "modificationTimestamp": "2022-10-06T20:58:16.305662Z",
    "createdBy": "8f84cf09-8036-51e4-b579-bd30cb07b269"
  }
}

响应

Status: 401, Unauthorized
名称 Type Required Description

type

string

True

标题

string

True

详细信息

string

True

状态

string

True

correlationID

string

False

响应示例
{
  "type": "https://astra.netapp.io/problems/3",
  "title": "Missing bearer token",
  "detail": "The request is missing the required bearer token.",
  "status": "401"
}

响应

Status: 400, Bad request
名称 Type Required Description

type

string

True

标题

string

True

详细信息

string

True

状态

string

True

correlationID

string

False

invalidFields

数组["invalidFields"]

False

无效请求正文字段列表

响应示例
{
  "type": "https://astra.netapp.io/problems/5",
  "title": "Invalid query parameters",
  "detail": "The supplied query parameters are invalid.",
  "status": "400"
}

响应

Status: 409, Conflict
名称 Type Required Description

type

string

True

标题

string

True

详细信息

string

True

状态

string

True

correlationID

string

False

invalidFields

数组["invalidFields"]

False

无效请求正文字段列表

响应示例
{
  "type": "https://astra.netapp.io/problems/10",
  "title": "JSON resource conflict",
  "detail": "The request body JSON contains a field that conflicts with an idempotent value.",
  "status": "409"
}

响应

Status: 403, Forbidden
名称 Type Required Description

type

string

True

标题

string

True

详细信息

string

True

状态

string

True

correlationID

string

False

响应示例
{
  "type": "https://astra.netapp.io/problems/11",
  "title": "Operation not permitted",
  "detail": "The requested operation isn't permitted.",
  "status": "403"
}

错误

Status: 404, Not found
名称 Type Required Description

type

string

True

标题

string

True

详细信息

string

True

状态

string

True

correlationID

string

False

错误响应示例
{
  "type": "https://astra.netapp.io/problems/2",
  "title": "Collection not found",
  "detail": "The collection specified in the request URI wasn't found.",
  "status": "404"
}

定义

查看定义

类型 Astra 标签

名称 Type Required Description

name

string

True

value

string

True

type_astra_metadata_update

与资源关联的客户端和服务指定的元数据。定义的值为:

  • 符合 Astra 元数据架构如果在创建时未指定,则将创建没有标签的元数据对象。如果在更新时未指定,则元数据对象的标签、creationTimestamp 和 createdBy 将保留而不进行修改。

名称 Type Required Description

labels

数组["类型 Astra 标签"]

False

creationTimestamp

string

False

modificationTimestamp

string

False

已创建

string

False

modifiedBy

string

False

invalidParams

名称 Type Required Description

name

string

True

无效查询参数的名称

原因

string

True

查询参数无效的原因

invalidFields

名称 Type Required Description

name

string

True

无效请求正文字段的名称

原因

string

True

请求正文字段无效的原因