Content-Length: 543405 | pFad | https://github.com/apache/airflow/commit/f6b48ac6dfaf931a5433ec16369302f68f038c65

A0 Memorystore assets & system tests migration (AIP-47) (#25361) · apache/airflow@f6b48ac · GitHub
Skip to content

Commit f6b48ac

Browse files
author
Wojciech Januszek
authored
Memorystore assets & system tests migration (AIP-47) (#25361)
1 parent ad0a496 commit f6b48ac

File tree

11 files changed

+533
-219
lines changed

11 files changed

+533
-219
lines changed

airflow/providers/google/cloud/hooks/cloud_memorystore.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ def update_instance(
478478
timeout=timeout,
479479
metadata=metadata,
480480
)
481-
result.result()
481+
updated_instance = result.result()
482482
self.log.info("Instance updated: %s", instance.name)
483+
return updated_instance
483484

484485

485486
class CloudMemorystoreMemcachedHook(GoogleBaseHook):
@@ -833,8 +834,9 @@ def update_instance(
833834
result = client.update_instance(
834835
update_mask=update_mask, resource=instance, retry=retry, timeout=timeout, metadata=metadata or ()
835836
)
836-
result.result()
837+
updated_instance = result.result()
837838
self.log.info("Instance updated: %s", instance.name)
839+
return updated_instance
838840

839841
@GoogleBaseHook.fallback_to_default_project_id
840842
def update_parameters(
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
"""This module contains Cloud Memorystore links."""
19+
from typing import TYPE_CHECKING, Optional
20+
21+
from airflow.models import BaseOperator
22+
from airflow.providers.google.cloud.links.base import BaseGoogleLink
23+
24+
if TYPE_CHECKING:
25+
from airflow.utils.context import Context
26+
27+
BASE_LINK = "https://console.cloud.google.com/memorystore"
28+
MEMCACHED_LINK = (
29+
BASE_LINK + "/memcached/locations/{location_id}/instances/{instance_id}/details?project={project_id}"
30+
)
31+
MEMCACHED_LIST_LINK = BASE_LINK + "/memcached/instances?project={project_id}"
32+
REDIS_LINK = (
33+
BASE_LINK + "/redis/locations/{location_id}/instances/{instance_id}/details/overview?project={project_id}"
34+
)
35+
REDIS_LIST_LINK = BASE_LINK + "/redis/instances?project={project_id}"
36+
37+
38+
class MemcachedInstanceDetailsLink(BaseGoogleLink):
39+
"""Helper class for constructing Memorystore Memcached Instance Link"""
40+
41+
name = "Memorystore Memcached Instance"
42+
key = "memcached_instance"
43+
format_str = MEMCACHED_LINK
44+
45+
@staticmethod
46+
def persist(
47+
context: "Context",
48+
task_instance: BaseOperator,
49+
instance_id: str,
50+
location_id: str,
51+
project_id: Optional[str],
52+
):
53+
task_instance.xcom_push(
54+
context,
55+
key=MemcachedInstanceDetailsLink.key,
56+
value={"instance_id": instance_id, "location_id": location_id, "project_id": project_id},
57+
)
58+
59+
60+
class MemcachedInstanceListLink(BaseGoogleLink):
61+
"""Helper class for constructing Memorystore Memcached List of Instances Link"""
62+
63+
name = "Memorystore Memcached List of Instances"
64+
key = "memcached_instances"
65+
format_str = MEMCACHED_LIST_LINK
66+
67+
@staticmethod
68+
def persist(
69+
context: "Context",
70+
task_instance: BaseOperator,
71+
project_id: Optional[str],
72+
):
73+
task_instance.xcom_push(
74+
context,
75+
key=MemcachedInstanceListLink.key,
76+
value={"project_id": project_id},
77+
)
78+
79+
80+
class RedisInstanceDetailsLink(BaseGoogleLink):
81+
"""Helper class for constructing Memorystore Redis Instance Link"""
82+
83+
name = "Memorystore Redis Instance"
84+
key = "redis_instance"
85+
format_str = REDIS_LINK
86+
87+
@staticmethod
88+
def persist(
89+
context: "Context",
90+
task_instance: BaseOperator,
91+
instance_id: str,
92+
location_id: str,
93+
project_id: Optional[str],
94+
):
95+
task_instance.xcom_push(
96+
context,
97+
key=RedisInstanceDetailsLink.key,
98+
value={"instance_id": instance_id, "location_id": location_id, "project_id": project_id},
99+
)
100+
101+
102+
class RedisInstanceListLink(BaseGoogleLink):
103+
"""Helper class for constructing Memorystore Redis List of Instances Link"""
104+
105+
name = "Memorystore Redis List of Instances"
106+
key = "redis_instances"
107+
format_str = REDIS_LIST_LINK
108+
109+
@staticmethod
110+
def persist(
111+
context: "Context",
112+
task_instance: BaseOperator,
113+
project_id: Optional[str],
114+
):
115+
task_instance.xcom_push(
116+
context,
117+
key=RedisInstanceListLink.key,
118+
value={"project_id": project_id},
119+
)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/apache/airflow/commit/f6b48ac6dfaf931a5433ec16369302f68f038c65

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy