Repository: apache/airflow
File: providers/google/src/airflow/providers/google/cloud/triggers/cloud_run.py (Python)

Code before:
    :param impersonation_chain: Optional. Service account to impersonate using short-term
        credentials, or chained list of accounts required to get the access_token of the last account
        in the list, which will be impersonated in the request.
        If set as a string, the account must grant the originating account
        the Service Account Token Creator IAM role.
        If set as a sequence, the identities from the list must grant
        Service Account Token Creator IAM role to the directly preceding identity, with first
        account from the list granting this role to the originating account (templated).
    :param poll_sleep: Polling period in seconds to check for the status.
    :timeout: The time to wait before failing the operation.
    :param transport: Optional. The transport to use for API requests. Can be 'rest' or 'grpc'.
        Defaults to 'grpc'. Use 'rest' if gRPC is not available or fails in your environment
        (e.g., Docker containers with certain network configurations).
    """

    def __init__(
        self,
        operation_name: str,
        job_name: str,
        project_id: str | None,
        location: str = DEFAULT_BATCH_LOCATION,
        gcp_conn_id: str = "google_cloud_default",
        impersonation_chain: str | Sequence[str] | None = None,
        polling_period_seconds: float = 10,
        timeout: float | None = None,
        transport: str | None = None,
    ):
        super().__init__()
        self.project_id = project_id
        self.job_name = job_name
        self.operation_name = operation_name
        self.location = location
        self.gcp_conn_id = gcp_conn_id
        self.polling_period_seconds = polling_period_seconds
        self.timeout = timeout
        self.impersonation_chain = impersonation_chain
        self.transport = transport

    def serialize(self) -> tuple[str, dict[str, Any]]:
        """Serialize class arguments and classpath."""
        return (
            "airflow.providers.google.cloud.triggers.cloud_run.CloudRunJobFinishedTrigger",
            {
                "project_id": self.project_id,
                "operation_name": self.operation_name,
                "job_name": self.job_name,
                "location": self.location,
                "gcp_conn_id": self.gcp_conn_id,
                "polling_period_seconds": self.polling_period_seconds,
                "timeout": self.timeout,
                "impersonation_chain": self.impersonation_chain,

Review comment (suggestion):
If this defaults to "grpc", why not just do `transport: str = "grpc"`?

Also it might be a good idea to use Literal here? I’m not sure if the transports supported by these operators a static or not.

Code after:
    :param impersonation_chain: Optional. Service account to impersonate using short-term
        credentials, or chained list of accounts required to get the access_token of the last account
        in the list, which will be impersonated in the request.
        If set as a string, the account must grant the originating account
        the Service Account Token Creator IAM role.
        If set as a sequence, the identities from the list must grant
        Service Account Token Creator IAM role to the directly preceding identity, with first
        account from the list granting this role to the originating account (templated).
    :param poll_sleep: Polling period in seconds to check for the status.
    :timeout: The time to wait before failing the operation.
    :param transport: Optional. The transport to use for API requests. Can be 'rest' or 'grpc'.
        Defaults to 'grpc'. Use 'rest' if gRPC is not available or fails in your environment
        (e.g., Docker containers with certain network configurations).
    """

    def __init__(
        self,
        operation_name: str,
        job_name: str,
        project_id: str | None,
        location: str = DEFAULT_BATCH_LOCATION,
        gcp_conn_id: str = "google_cloud_default",
        impersonation_chain: str | Sequence[str] | None = None,
        polling_period_seconds: float = 10,
        timeout: float | None = None,
        transport: Literal["rest", "grpc"] | None = None,
    ):
        super().__init__()
        self.project_id = project_id
        self.job_name = job_name
        self.operation_name = operation_name
        self.location = location
        self.gcp_conn_id = gcp_conn_id
        self.polling_period_seconds = polling_period_seconds
        self.timeout = timeout
        self.impersonation_chain = impersonation_chain
        self.transport = transport

    def serialize(self) -> tuple[str, dict[str, Any]]:
        """Serialize class arguments and classpath."""
        return (
            "airflow.providers.google.cloud.triggers.cloud_run.CloudRunJobFinishedTrigger",
            {
                "project_id": self.project_id,
                "operation_name": self.operation_name,
                "job_name": self.job_name,
                "location": self.location,
                "gcp_conn_id": self.gcp_conn_id,
                "polling_period_seconds": self.polling_period_seconds,
                "timeout": self.timeout,
                "impersonation_chain": self.impersonation_chain,