Source code for airflow.providers.google.cloud.links.cloud_storage_transfer
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""This module contains Google Storage Transfer Service links."""
from __future__ import annotations
from typing import TYPE_CHECKING
from airflow.providers.google.cloud.links.base import BaseGoogleLink
if TYPE_CHECKING:
from airflow.utils.context import Context
[docs]
CLOUD_STORAGE_TRANSFER_BASE_LINK = "https://console.cloud.google.com/transfer"
[docs]
CLOUD_STORAGE_TRANSFER_LIST_LINK = CLOUD_STORAGE_TRANSFER_BASE_LINK + "/jobs?project={project_id}"
[docs]
CLOUD_STORAGE_TRANSFER_JOB_LINK = (
CLOUD_STORAGE_TRANSFER_BASE_LINK + "/jobs/transferJobs%2F{transfer_job}/runs?project={project_id}"
)
[docs]
CLOUD_STORAGE_TRANSFER_OPERATION_LINK = (
CLOUD_STORAGE_TRANSFER_BASE_LINK
+ "/jobs/transferJobs%2F{transfer_job}/runs/transferOperations%2F{transfer_operation}"
+ "?project={project_id}"
)
[docs]
class CloudStorageTransferLinkHelper:
"""Helper class for Storage Transfer links."""
@staticmethod
[docs]
class CloudStorageTransferListLink(BaseGoogleLink):
"""Helper class for constructing Cloud Storage Transfer Link."""
[docs]
name = "Cloud Storage Transfer"
[docs]
key = "cloud_storage_transfer"
[docs]
class CloudStorageTransferJobLink(BaseGoogleLink):
"""Helper class for constructing Storage Transfer Job Link."""
[docs]
name = "Cloud Storage Transfer Job"
[docs]
key = "cloud_storage_transfer_job"
[docs]
class CloudStorageTransferDetailsLink(BaseGoogleLink):
"""Helper class for constructing Cloud Storage Transfer Operation Link."""
[docs]
name = "Cloud Storage Transfer Details"
[docs]
key = "cloud_storage_transfer_details"
@staticmethod
@classmethod
[docs]
def persist(cls, context: Context, **value):
operation_name = value.get("operation_name")
transfer_operation, transfer_job = cls.extract_parts(operation_name)
super().persist(
context,
project_id=value.get("project_id"),
transfer_job=transfer_job,
transfer_operation=transfer_operation,
)