운영 세부정보 가져오기

작업에 대한 자세한 정보를 검색합니다.

더 살펴보기

이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.

코드 샘플

Python

VMware Engine에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import vmwareengine_v1
from google.longrunning.operations_pb2 import GetOperationRequest


def get_operation_by_name(operation_name: str) -> Operation:
    """
    Retrieve detailed information about an operation.

    Args:
        operation_name: name identifying an operation you want to check.
            Expected format: projects/{project_id}/locations/{region}/operations/{operation_id}

    Returns:
        Operation object with details.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    request = GetOperationRequest()
    request.name = operation_name
    return client.get_operation(request)


def get_operation(project_id: str, region: str, operation_id: str) -> Operation:
    """
    Retrieve detailed information about an operation.

    Args:
        project_id: name of the project running the operation.
        region: name of the region in which the operation is running.
        operation_id: identifier of the operation.

    Returns:
        Operation object with details.
    """
    return get_operation_by_name(
        f"projects/{project_id}/locations/{region}/operations/{operation_id}"
    )

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기