이 페이지에서는 Financial Services API 장기 실행 작업(LRO)의 수명 주기를 관리하는 방법을 설명합니다.
메서드 호출이 완료되는 데 오래 걸릴 수 있으면 장기 실행 작업이 반환됩니다. 예를 들어 Financial Services API는 projects.locations.instances.create를 호출할 때마다 LRO를 만듭니다.
LRO는 처리 작업의 상태를 추적합니다.
Financial Services API가 제공하는 projects.locations.operations 메서드를 사용하여 LRO 상태를 확인할 수 있습니다. LRO를 나열, 취소 또는 삭제도 할 수 있습니다.
LRO는 Google Cloud 프로젝트 및 위치 수준에서 관리됩니다. API에 요청을 수행할 때는 Google Cloud 프로젝트 및 LRO가 실행되는 위치를 포함하세요.
LRO 레코드는 LRO가 완료된 후 약 30일 동안 유지됩니다. 이 시점 이후에는 LRO를 보거나 나열할 수 없습니다.
장기 실행 작업에 대한 세부정보 가져오기
인스턴스를 만들었다고 가정해 보겠습니다.
응답의 name 값은 Financial Services API가 projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID라는 LRO를 만들었음을 보여줍니다.
인스턴스가 생성되었는지 확인하려면 projects.locations.operations.get 메서드를 사용합니다. 응답에 "done": false가 포함되어 있으면 응답에 "done": true가 포함될 때까지 명령어를 반복합니다.
이 작업은 완료하는 데 몇 분 정도 걸릴 수 있습니다.
또한 장기 실행 작업을 나열하여 LRO를 검색할 수 있습니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID: IAM 설정에 나열된 Google Cloud 프로젝트 ID입니다.LOCATION: 인스턴스의 위치. 지원되는 리전 중 하나를 사용합니다.위치 표시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.operations.list 메서드를 사용하여 지정된 위치의 모든 작업을 나열합니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID: IAM 설정에 나열된 Google Cloud 프로젝트 ID입니다.LOCATION: 작업의 위치입니다. 지원되는 리전 중 하나를 사용합니다.위치 표시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/operations"
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" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
{
"operations": [
{
"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/engineConfigs/ENGINE_CONFIG_ID",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
},
{
"name": "projects/PROJECT_ID/locations/LOCATION/operations/my-other-operation",
"metadata": {
"@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
"createTime": CREATE_TIME,
"endTime": END_TIME,
"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.operations.cancel 메서드를 사용하여 장기 실행 작업에 대한 비동기 취소를 시작합니다. 서버는 작업이 취소되도록 최선을 다하지만 성공이 보장되지는 않습니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID: IAM 설정에 나열된 Google Cloud 프로젝트 ID입니다.LOCATION: 작업의 위치입니다. 지원되는 리전 중 하나를 사용합니다.위치 표시us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
OPERATION_ID: 작업의 식별자
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
다음 명령어를 실행합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID:cancel"
PowerShell
다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID:cancel" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
{}
장기 실행 작업 삭제
projects.locations.operations.delete 메서드를 사용하여 완료된 장기 실행 작업을 삭제합니다. 이 메서드는 클라이언트가 작업 결과에 더 이상 관심이 없음을 나타냅니다. 작업을 취소하지는 않습니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID: IAM 설정에 나열된 Google Cloud 프로젝트 ID입니다.LOCATION: 작업의 위치입니다. 지원되는 리전 중 하나를 사용합니다.위치 표시us-central1us-east1asia-south1europe-west1europe-west2europe-west4northamerica-northeast1southamerica-east1australia-southeast1
OPERATION_ID: 작업의 식별자
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
다음 명령어를 실행합니다.
curl -X DELETE \
-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 DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
{}