本页面介绍如何创建和管理 AML AI 实例,可用作快速参考指南。
准备工作
-
如需获得创建和管理实例所需的权限,请让您的管理员为您授予项目的 Financial Services Admin (
financialservices.admin) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。 - 创建加密密钥并授予对该密钥的访问权限
创建实例
某些 API 方法会返回长时间运行的操作 (LRO)。这些方法是异步执行的,并会返回一个 Operation 对象;如需了解详情,请参阅 REST 参考。当方法返回响应时,操作可能尚未完成。对于这些方法,请发送请求,然后检查结果。一般来说,所有 POST、PUT、UPDATE 和 DELETE 操作都是长时间运行的操作。
发送请求
如需创建实例,请使用 projects.locations.instances.create 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:密钥环和实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符KMS_PROJECT_ID:包含密钥环的项目的 Google Cloud 项目 IDKEY_RING_ID:用户定义的密钥环标识符KEY_ID:密钥的用户定义标识符
请求 JSON 正文:
{
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID"
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
cat > request.json << 'EOF'
{
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID"
}
EOF然后,执行以下命令以发送 REST 请求:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=INSTANCE_ID"
PowerShell
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
@'
{
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID"
}
'@ | Out-File -FilePath request.json -Encoding utf8然后,执行以下命令以发送 REST 请求:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=INSTANCE_ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
检查结果
使用 projects.locations.operations.get 方法检查实例是否已创建。如果响应包含 "done": false,请重复执行该命令,直到响应包含 "done": true。此操作可能需要几分钟才能完成。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
OPERATION_ID:操作的标识符
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID"
PowerShell
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"endTime": "2023-03-14T16:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.Instance",
"name": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"createTime": CREATE_TIME,
"updateTime": UPDATE_TIME,
"state": "ACTIVE",
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID"
}
}
获取实例
如需获取实例,请使用 projects.locations.instances.get 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID"
PowerShell
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"createTime": "2023-03-14T15:52:55.358979323Z",
"updateTime": "2023-03-15T15:52:55.358979323Z",
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID",
"state": "ACTIVE"
}
更新实例
如需更新实例,请使用 projects.locations.instances.patch 方法。
并非实例中的所有字段都可以更新。以下示例会更新与实例关联的键值对用户标签。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符KEY:用于整理实例的键值对中的键。如需了解详情,请参阅labels。VALUE:用于整理实例的键值对中的值。如需了解详情,请参阅labels。
请求 JSON 正文:
{
"labels": {
"KEY": "VALUE"
}
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
cat > request.json << 'EOF'
{
"labels": {
"KEY": "VALUE"
}
}
EOF然后,执行以下命令以发送 REST 请求:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID?updateMask=labels"
PowerShell
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
@'
{
"labels": {
"KEY": "VALUE"
}
}
'@ | Out-File -FilePath request.json -Encoding utf8然后,执行以下命令以发送 REST 请求:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID?updateMask=labels" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "update",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
如需详细了解如何获取长时间运行的操作 (LRO) 的结果,请参阅检查结果。
列出实例
如需列出给定实例的实例,请使用 projects.locations.instances.list 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用某个受支持的地区显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances"
PowerShell
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"instances": [
{
"name": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"createTime": "2023-03-14T15:52:55.358979323Z",
"updateTime": "2023-03-15T15:52:55.358979323Z",
"kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID",
"state": "ACTIVE"
}
]
}
导入已注册的当事方
如需导入已注册的当事方,请先为要注册当事方的业务线准备一个 BigQuery 表。如需了解详情,请参阅注册客户。 请使用以下任一架构:
零售方架构
列 类型 说明 party_idSTRING实例数据集中的当事方的唯一标识符 party_sizeSTRINGNULL;对于零售方注册,系统会忽略相应内容 商业方架构
列 类型 说明 party_idSTRING实例数据集中的当事方的唯一标识符 party_sizeSTRING请求的聚会人数。会员等级取决于相关方在过去 365 天内的平均每月交易次数: SMALL,适用于平均每月交易次数少于 500 次的小型商业方LARGE适用于平均每月交易次数不低于 500 次的大型商业方
所有值都区分大小写。
如需导入已注册的当事方,请使用 projects.locations.instances.importRegisteredParties 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符BQ_INPUT_REGISTERED_PARTIES_DATASET_NAME:包含描述已注册方的表的 BigQuery 数据集PARTY_REGISTRATION_TABLE:列出已注册方的表格UPDATE_MODE:使用REPLACE将注册当事方表中可移除的当事方替换为新当事方,或使用APPEND将新当事方添加到注册当事方表中LINE_OF_BUSINESS:此字段必须与引擎配置所用引擎版本中的lineOfBusiness值相匹配;对于商业银行客户(法人实体和自然实体),请使用COMMERCIAL;对于零售银行客户,请使用RETAIL
请求 JSON 正文:
{
"partyTables": [
"bq://PROJECT_ID.BQ_INPUT_REGISTERED_PARTIES_DATASET_NAME.PARTY_REGISTRATION_TABLE"
],
"mode": "UPDATE_MODE",
"lineOfBusiness": "LINE_OF_BUSINESS"
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
cat > request.json << 'EOF'
{
"partyTables": [
"bq://PROJECT_ID.BQ_INPUT_REGISTERED_PARTIES_DATASET_NAME.PARTY_REGISTRATION_TABLE"
],
"mode": "UPDATE_MODE",
"lineOfBusiness": "LINE_OF_BUSINESS"
}
EOF然后,执行以下命令以发送 REST 请求:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:importRegisteredParties"
PowerShell
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
@'
{
"partyTables": [
"bq://PROJECT_ID.BQ_INPUT_REGISTERED_PARTIES_DATASET_NAME.PARTY_REGISTRATION_TABLE"
],
"mode": "UPDATE_MODE",
"lineOfBusiness": "LINE_OF_BUSINESS"
}
'@ | Out-File -FilePath request.json -Encoding utf8然后,执行以下命令以发送 REST 请求:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:importRegisteredParties" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "importRegisteredParties",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
如需详细了解如何获取长时间运行的操作 (LRO) 的结果,请参阅检查结果。
LRO 完成后,响应会指明相应操作添加、移除或更新的当事方数量。
| 响应字段 | 类型 | 说明 |
|---|---|---|
partiesAdded | integer |
相应操作添加的参与方数量 |
partiesRemoved | integer |
相应操作移除的当事人数量 |
partiesTotal | integer |
更新操作完成后,相应实例中注册的当事方总数 |
partiesUptiered | integer |
从小型升级为大型的商业方的总数 |
partiesDowntiered | integer |
从大型商业方降级为小型商业方的商业方总数 |
partiesFailedToDowntier | integer |
从大型商业方降级为小型商业方的商业方总数 |
partiesFailedToRemove | integer |
相应操作未能移除的当事方数量 |
导出已注册的当事方
如需导出已注册的当事方,请使用 projects.locations.instances.exportRegisteredParties 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符BQ_OUTPUT_DATASET_NAME:用于导出描述已注册方的表的 BigQuery 数据集PARTY_REGISTRATION_TABLE:用于写入已注册方的表WRITE_DISPOSITION:如果目标表已存在,则执行的操作;请使用以下某个值:-
WRITE_EMPTY:仅当 BigQuery 表为空时才导出数据。 -
WRITE_TRUNCATE:在写入 BigQuery 表之前,先清空该表中的所有现有数据。
-
LINE_OF_BUSINESS:对于商业银行客户(法人实体和自然实体),请使用COMMERCIAL;对于零售银行客户,请使用RETAIL
请求 JSON 正文:
{
"dataset": {
"tableUri": "bq://PROJECT_ID.BQ_OUTPUT_DATASET_NAME.PARTY_REGISTRATION_TABLE",
"writeDisposition": "WRITE_DISPOSITION"
},
"lineOfBusiness": "LINE_OF_BUSINESS"
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
cat > request.json << 'EOF'
{
"dataset": {
"tableUri": "bq://PROJECT_ID.BQ_OUTPUT_DATASET_NAME.PARTY_REGISTRATION_TABLE",
"writeDisposition": "WRITE_DISPOSITION"
},
"lineOfBusiness": "LINE_OF_BUSINESS"
}
EOF然后,执行以下命令以发送 REST 请求:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:exportRegisteredParties"
PowerShell
将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:
@'
{
"dataset": {
"tableUri": "bq://PROJECT_ID.BQ_OUTPUT_DATASET_NAME.PARTY_REGISTRATION_TABLE",
"writeDisposition": "WRITE_DISPOSITION"
},
"lineOfBusiness": "LINE_OF_BUSINESS"
}
'@ | Out-File -FilePath request.json -Encoding utf8然后,执行以下命令以发送 REST 请求:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:exportRegisteredParties" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "exportRegisteredParties",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
如需详细了解如何获取长时间运行的操作 (LRO) 的结果,请参阅检查结果。
此方法会输出具有以下架构的 BigQuery 表:
| 列 | 类型 | 说明 |
|---|---|---|
party_id | STRING | 实例数据集中的当事方的唯一标识符 |
party_size | STRING |
指定商业客户的层级(大型与小型)。此字段不适用于零售客户。
所有值都区分大小写。 |
earliest_remove_time | STRING | 可以移除当事方的最早时间 |
party_with_prediction_intent | STRING | 指示自注册以来是否已预测过某个当事方 |
registration_or_uptier_time | STRING | 相应方注册或升级的时间 |
如需了解详情,请参阅注册客户。
删除实例
如需删除实例,请使用 projects.locations.instances.delete 方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID:IAM 设置中列出的 Google Cloud 项目 IDLOCATION:实例的位置;请使用其中一个受支持的区域显示位置us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
INSTANCE_ID:用户定义的实例标识符
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID"
PowerShell
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": "2023-03-14T15:52:55.358979323Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "delete",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
如需详细了解如何获取长时间运行的操作 (LRO) 的结果,请参阅检查结果。