אתם יכולים להפעיל או להשבית באופן סלקטיבי את ההטמעה של היסטוריית השינויים בשילובים ספציפיים ברמת הפרויקט, התיקייה או הארגון.
מידע נוסף על אינטגרציות נתמכות ועל תרחישי הגדרה זמין במאמר שליטה בהטמעה של היסטוריית נתונים.
דרישות מוקדמות
כדי לשלוט בהטמעה של שושלת הנתונים, צריך להשתמש ב-Data Lineage API. חשוב לוודא שיש לכם פרויקט לקוח שמוגדר לחיוב ולמכסה, כי Data Lineage API הוא API שמבוסס על לקוח.
תפקידים והרשאות
כדי לקבל את ההרשאות שנדרשות להגדרה ולשליטה בהטמעה של שושלת הנתונים, צריך לבקש מהאדמין להקצות לכם את תפקידי ה-IAM הבאים:
כדי לקבל את ההרשאות שדרושות להגדרה ולשליטה בהטמעה של שושלת הנתונים, צריך לבקש מהאדמין להקצות לכם את תפקידי ה-IAM הבאים בפרויקט:
-
הגדרה וניהול של שושלת נתונים:
אדמין של שושלת נתונים (
roles/datalineage.admin)
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
התפקידים המוגדרים מראש האלה כוללים את ההרשאות שנדרשות להגדרה ולשליטה בהטמעה של מעקב אחר מקורות נתונים. כדי לראות בדיוק אילו הרשאות נדרשות, אפשר להרחיב את הקטע ההרשאות הנדרשות:
ההרשאות הנדרשות
כדי להגדיר ולשלוט בהטמעה של היסטוריית הנתונים, נדרשות ההרשאות הבאות:
-
קבלת עדכונים של הגדרות שושלת:
-
datalineage.configs.get -
datalineage.configs.update
-
יכול להיות שתקבלו את ההרשאות האלה באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש אחרים.
מפעילים את
datalineage.googleapis.comAPI בפרויקט הלקוח. מידע נוסף זמין במאמר בנושא הפעלת שושלת נתונים.מגדירים את פרויקט הלקוח. בדוגמאות הבאות משתמשים בכותרת
X-Goog-User-Project. מידע נוסף זמין במאמר בנושא פרמטרים של המערכת.
אחזור ההגדרה הנוכחית
כדי לבדוק אם הטמעת שושלת הנתונים מופעלת עבור משאב מסוים, או כדי לקבל את הערך etag לפני שמשנים את ההגדרה, מאחזרים את ההגדרה הנוכחית.
C#
C#
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי C#ההוראות להגדרה במאמר מדריך למתחילים לעבודה עם Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog C# API.
כדי לבצע אימות לקטלוג הידע, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
המשך
Go
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Goההוראות להגדרה במאמר מדריך למתחילים לעבודה עם Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Go API.
כדי לבצע אימות לקטלוג הידע, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Java
Java
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר מדריך למתחילים לעבודה עם Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Java API.
כדי לבצע אימות לקטלוג הידע, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Python
Python
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Pythonההוראות להגדרה במאמר מדריך למתחילים לעבודה עם Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Python API.
כדי לבצע אימות לקטלוג הידע, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
gcloud
כדי לראות את הגדרות השושלת הנוכחיות, משתמשים בפקודה gcloud datalineage config describe. אתם יכולים לאחזר את ההגדרה של פרויקט, תיקייה או ארגון.
בדוגמה הבאה אפשר לראות איך מקבלים את ההגדרות של הפרויקט הנוכחי:
gcloud datalineage config describe
לדוגמה, כדי לקבל את ההגדרה של פרויקט ספציפי, משתמשים בדגל --project:
gcloud datalineage config describe --project=PROJECT_ID
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט שאתם רוצים להציג את ההגדרות שלו.
כדי לראות את הגדרות ההטמעה הנוכחיות של שירות מסוים עבור תיקייה או ארגון, מחליפים את --project= באחת מהאפשרויות הבאות:PROJECT_ID
--folder=אם רוצים לראות את הגדרות הטמעת הנתונים בתיקייה.FOLDER_ID--organization=אם רוצים לראות את הגדרות הטמעת הנתונים בארגון.ORGANIZATION_ID
REST
כדי לראות את הגדרת שרשרת המקורות הנוכחית, משתמשים בשיטה projects.locations.config.get. אפשר לאחזר את ההגדרה של פרויקט, תיקייה או ארגון.
בדוגמה הבאה אפשר לראות איך מקבלים את ההגדרה של פרויקט:
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
-
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
PROJECT_ID: מזהה הפרויקט שרוצים להציג את ההגדרה שלו.
ה-method של ה-HTTP וכתובת ה-URL:
GET https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/global/config
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
הפקודה מחזירה את אחד מהפלט הבאים:
- אם לא תספקו הגדרות להעברת נתוני שושלת, תקבלו פלט עם אובייקט
ingestionריק:{ "name": "projects/123456789012/locations/global/config", "ingestion": {} }
כלומר, השירות משתמש בהגדרת ברירת המחדל להעברת נתוני שושלת. בדוגמה הזו, הגדרת הטמעת שרשרת המקורות בשירות המנוהל ל-Apache Spark היא
enabled. - אם מפעילים את הטמעת שושלת הנתונים באופן מפורש, מקבלים את הפלט הבא:
{ "name": "projects/123456789012/locations/global/config", "ingestion": { "rules": [ { "integrationSelector": { "integration": "DATAPROC" }, "lineageEnablement": { "enabled": true } } ] }, "etag": "1a2b3c4d5e" }
- אם השבתתם את הטמעת נתוני השושלת, תקבלו את הפלט הבא:
{ "name": "projects/123456789012/locations/global/config", "ingestion": { "rules": [ { "integrationSelector": { "integration": "DATAPROC" }, "lineageEnablement": { "enabled": false } } ] }, "etag": "1a2b3c4d5e" }
כדי לקבל את ההגדרה של תיקייה או ארגון, מחליפים את projects/ ב-"PROJECT_IDfolders/ או ב-FOLDER_IDorganizations/.ORGANIZATION_ID
השדה etag בתגובה הוא סכום ביקורת שנוצר על ידי השרת על סמך הערך הנוכחי של ההגדרה. כשמעדכנים הגדרה באמצעות ה-method patch, אפשר לכלול בגוף הבקשה את הערך etag שהוחזר מבקשת get מהזמן האחרון. אם תספקו את etag, Knowledge Catalog ישתמש בו כדי לוודא שההגדרה לא השתנתה מאז בקשת הקריאה האחרונה שלכם. אם יש אי-התאמה, בקשת העדכון נכשלת. כך לא יקרה ששינויים שתבצעו יחליפו בטעות הגדרות שמשתמשים אחרים ביצעו בתרחישים של קריאה, שינוי וכתיבה. אם לא תספקו etag בבקשת patch, Knowledge Catalog ידרוס את ההגדרה ללא תנאי.
השבתת הטמעה של שושלת נתונים בשירות
כדי לנהל את העלויות, לאכוף מדיניות של משילות מידע (data governance) או להחריג פרויקטים של פיתוח ועומסי עבודה אחרים שלא מפיקים תועלת ממעקב אחר שושלת נתונים, אפשר להשבית את ההטמעה של שושלת נתונים בשירות.
Java
package com.google.cloud.datacatalog.lineage.configmanagement.v1.samples;
import com.google.api.gax.rpc.NotFoundException;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementServiceClient;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.ConfigName;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.GetConfigRequest;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.UpdateConfigRequest;
public class DisableLineageIngestion {
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
String location = "global";
disableLineageIngestion(projectId, location);
}
// Disables lineage ingestion for a specific service
// (Managed Service for Apache Spark).
public static void disableLineageIngestion(String projectId, String location) throws Exception {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (ConfigManagementServiceClient client = ConfigManagementServiceClient.create()) {
// Format the resource name.
String name = ConfigName.ofProjectLocationName(projectId, location).toString();
Config.Builder configBuilder = Config.newBuilder().setName(name);
// It is a best practice to read the existing config to preserve other rules
// and use the etag for optimistic concurrency control.
try {
GetConfigRequest getRequest = GetConfigRequest.newBuilder().setName(name).build();
Config existingConfig = client.getConfig(getRequest);
configBuilder.mergeFrom(existingConfig);
} catch (NotFoundException e) {
// If config doesn't exist, we will proceed by creating a new one.
}
// Create an integration selector for the service you want to disable.
IntegrationSelector selector =
IntegrationSelector.newBuilder().setIntegration(Integration.DATAPROC).build();
// Set lineage enablement to false to disable tracking.
LineageEnablement enablement = LineageEnablement.newBuilder().setEnabled(false).build();
// Build the ingestion rule.
IngestionRule disableRule =
IngestionRule.newBuilder()
.setIntegrationSelector(selector)
.setLineageEnablement(enablement)
.build();
// Preserve existing rules except for the one we are modifying, then add the new rule.
// We clear the ingestion block out of the configBuilder entirely to reconstruct it.
Ingestion.Builder ingestionBuilder = Ingestion.newBuilder();
if (configBuilder.hasIngestion()) {
for (IngestionRule rule : configBuilder.getIngestion().getRulesList()) {
// Keep all existing rules EXCEPT the one targeting DATAPROC
if (rule.getIntegrationSelector().getIntegration() != Integration.DATAPROC) {
ingestionBuilder.addRules(rule);
}
}
}
ingestionBuilder.addRules(disableRule);
// Update the config builder with the reconstructed ingestion settings.
configBuilder.setIngestion(ingestionBuilder.build());
// Build the update request.
UpdateConfigRequest request = UpdateConfigRequest.newBuilder()
.setConfig(configBuilder.build())
.build();
// Update the config.
Config response = client.updateConfig(request);
System.out.printf("Successfully updated config: %s\n", response.getName());
}
}
}
Python
from google.api_core.exceptions import NotFound
from google.cloud.datacatalog.lineage import configmanagement_v1
def disable_lineage_ingestion(project_id: str, location: str = "global") -> configmanagement_v1.Config:
"""Disables lineage ingestion for a specific service.
Args:
project_id: The ID of your Google Cloud project.
location: The region location, usually 'global'.
Returns:
The updated Configuration object.
"""
# Initialize client that will be used to send requests.
client = configmanagement_v1.ConfigManagementServiceClient()
# The config name format
name = f"projects/{project_id}/locations/{location}/config"
try:
# Retrieve the existing config to preserve other configurations and
# obtain the latest etag for optimistic concurrency control.
config = client.get_config(name=name)
# Filter out existing rules for the integration we are updating
new_rules = [
rule for rule in config.ingestion.rules
if rule.integration_selector.integration != configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration.DATAPROC
]
except NotFound:
# If the config does not exist, start fresh
config = configmanagement_v1.Config(name=name)
new_rules = []
# Define the integration to disable tracking for (e.g., DATAPROC).
integration_selector = configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector(
integration=configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration.DATAPROC
)
# Set lineage enablement to False to disable tracking.
lineage_enablement = configmanagement_v1.Config.Ingestion.IngestionRule.LineageEnablement(
enabled=False
)
# Create the ingestion rule.
disable_rule = configmanagement_v1.Config.Ingestion.IngestionRule(
integration_selector=integration_selector,
lineage_enablement=lineage_enablement,
)
# Append the new disabling rule and assign it back to the config ingestion rules
new_rules.append(disable_rule)
config.ingestion = configmanagement_v1.Config.Ingestion(rules=new_rules)
# Create the update request using the config (which includes the etag if it existed).
request = configmanagement_v1.UpdateConfigRequest(
config=config,
)
# Make the request to update the config
response = client.update_config(request=request)
print(f"Successfully updated config: {response.name}")
return response
gcloud
כדי להשבית את הטמעת שושלת הנתונים בשירות ספציפי, משתמשים בפקודה gcloud datalineage config update עם מחרוזת JSON מוטבעת או עם נתיב לקובץ JSON שבו הערך של lineageEnablement.enabled מוגדר ל-false עבור integration ספציפי.
בדוגמה הבאה מוצג איך להשבית את ההטמעה של שושלת נתונים של שירות בפרויקט באמצעות מחרוזת JSON מוטמעת:
gcloud datalineage config update --project=PROJECT_ID \
--config='{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": false
}
}
]
},
"etag": "ETAG"
}'
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט שרוצים לעדכן את ההגדרות שלו. -
INTEGRATION: השילוב שעבורו הגדרתם את התצורה. לדוגמה,DATAPROCאוBIGQUERY. -
ETAG: הערךetagשמוחזר מבקשתgetעדכנית בגוף הבקשה. הערך הזה משמש לאימות שההגדרה לא השתנתה מאז בקשת הקריאה האחרונה.
כדי לעדכן את ההגדרה באמצעות קובץ JSON, מריצים את הפקודה:
gcloud datalineage config update --project=PROJECT_ID --config=CONFIG_FILE
מחליפים את מה שכתוב בשדות הבאים:
-
CONFIG_FILE: הנתיב לקובץ ה-JSON שמכיל את ההגדרה.
כדי להשבית את ההטמעה של נתוני השושלת של שירות בתיקייה או בארגון, מחליפים את --project= באחת מהאפשרויות הבאות:PROJECT_ID
--folder=אם רוצים לעדכן את הגדרות הטמעת הנתונים בתיקייה.FOLDER_ID--organization=אם רוצים לעדכן את הגדרות הטמעת הנתונים בארגון.ORGANIZATION_ID
REST
כדי להשבית את ההטמעה של נתוני שושלת עבור שירות ספציפי, צריך להשתמש בשיטה projects.locations.config.patch עם כלל הטמעה שמגדיר את lineageEnablement.enabled ל-false עבור integration ספציפי.
כדי למנוע החלפה לא מכוונת של הגדרות שמשתמשים אחרים יצרו בתרחישים של קריאה-שינוי-כתיבה, אפשר לכלול את השדה etag בגוף הבקשה. מידע נוסף מופיע במאמר בנושא קבלת ההגדרה הנוכחית.
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
-
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
PROJECT_ID: מזהה הפרויקט שרוצים לעדכן את ההגדרה שלו. -
ETAG: הערךetagשמוחזר מבקשתgetעדכנית. -
INTEGRATION:integrationשהגדרתם עבורו את התצורה. לדוגמה,DATAPROC.
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/global/config
תוכן בקשת JSON:
{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": false
}
}
]
},
"etag": "ETAG"
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"name": "projects/PROJECT_ID/locations/global/config",
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": false
}
}
]
},
"etag": "1a2b3c4d5e"
}
כדי להשבית את ההטמעה של שושלת הנתונים בתיקייה או בארגון, מחליפים את projects/ ב-"PROJECT_IDfolders/ או ב-FOLDER_IDorganizations/.ORGANIZATION_ID
הפעלת הטמעת שושלת נתונים לשירות
כדי להפעיל מחדש את המעקב אחרי השבתה, או כדי להפעיל שילוב שמושבת כברירת מחדל, צריך להפעיל את ההטמעה של היסטוריית השינויים בשירות.
Java
package com.google.cloud.datacatalog.lineage.configmanagement.v1.samples;
import com.google.api.gax.rpc.NotFoundException;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementServiceClient;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.ConfigName;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.GetConfigRequest;
import com.google.cloud.datacatalog.lineage.configmanagement.v1.UpdateConfigRequest;
public class EnableLineageIngestion {
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
String location = "global";
enableLineageIngestion(projectId, location);
}
// Enables lineage ingestion for a specific service
// (Managed Service for Apache Spark).
public static void enableLineageIngestion(String projectId, String location) throws Exception {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (ConfigManagementServiceClient client = ConfigManagementServiceClient.create()) {
// Format the resource name.
String name = ConfigName.ofProjectLocationName(projectId, location).toString();
Config.Builder configBuilder = Config.newBuilder().setName(name);
// It is a best practice to read the existing config to preserve other rules
// and use the etag for optimistic concurrency control.
try {
GetConfigRequest getRequest = GetConfigRequest.newBuilder().setName(name).build();
Config existingConfig = client.getConfig(getRequest);
configBuilder.mergeFrom(existingConfig);
} catch (NotFoundException e) {
// If config doesn't exist, we will proceed by creating a new one.
}
// Create an integration selector for the service you want to enable (e.g., DATAPROC).
IntegrationSelector selector =
IntegrationSelector.newBuilder().setIntegration(Integration.DATAPROC).build();
// Set lineage enablement to true to enable tracking.
LineageEnablement enablement = LineageEnablement.newBuilder().setEnabled(true).build();
// Build the ingestion rule.
IngestionRule enableRule =
IngestionRule.newBuilder()
.setIntegrationSelector(selector)
.setLineageEnablement(enablement)
.build();
// Preserve existing rules except for the one we are modifying, then add the new rule.
// We clear the ingestion block out of the configBuilder entirely to reconstruct it.
Ingestion.Builder ingestionBuilder = Ingestion.newBuilder();
if (configBuilder.hasIngestion()) {
for (IngestionRule rule : configBuilder.getIngestion().getRulesList()) {
// Keep all existing rules EXCEPT the one targeting DATAPROC
if (rule.getIntegrationSelector().getIntegration() != Integration.DATAPROC) {
ingestionBuilder.addRules(rule);
}
}
}
ingestionBuilder.addRules(enableRule);
// Update the config builder with the reconstructed ingestion settings.
configBuilder.setIngestion(ingestionBuilder.build());
// Build the update request.
UpdateConfigRequest request = UpdateConfigRequest.newBuilder()
.setConfig(configBuilder.build())
.build();
// Update the config.
Config response = client.updateConfig(request);
System.out.printf("Successfully updated config: %s\n", response.getName());
}
}
}
Python
from google.api_core.exceptions import NotFound
from google.cloud.datacatalog.lineage import configmanagement_v1
def enable_lineage_ingestion(project_id: str, location: str = "global") -> configmanagement_v1.Config:
"""Enables lineage ingestion for a specific service like Dataproc
(Managed Service for Apache Spark).
Args:
project_id: The ID of your Google Cloud project.
location: The region location, usually 'global'.
Returns:
The updated Configuration object.
"""
# Initialize client that will be used to send requests.
client = configmanagement_v1.ConfigManagementServiceClient()
# The config name format
name = f"projects/{project_id}/locations/{location}/config"
try:
# Retrieve the existing config to preserve other configurations and
# obtain the latest etag for optimistic concurrency control.
config = client.get_config(name=name)
# Filter out existing rules for the integration we are updating
new_rules = [
rule for rule in config.ingestion.rules
if rule.integration_selector.integration != configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration.DATAPROC
]
except NotFound:
# If the config does not exist, start fresh
config = configmanagement_v1.Config(name=name)
new_rules = []
# Define the integration to enable tracking for (e.g., DATAPROC).
integration_selector = configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector(
integration=configmanagement_v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration.DATAPROC
)
# Set lineage enablement to True to enable tracking.
lineage_enablement = configmanagement_v1.Config.Ingestion.IngestionRule.LineageEnablement(
enabled=True
)
# Create the ingestion rule.
enable_rule = configmanagement_v1.Config.Ingestion.IngestionRule(
integration_selector=integration_selector,
lineage_enablement=lineage_enablement,
)
# Append the new enabling rule and assign it back to the config ingestion rules
new_rules.append(enable_rule)
config.ingestion = configmanagement_v1.Config.Ingestion(rules=new_rules)
# Create the update request using the config (which includes the etag if it existed).
request = configmanagement_v1.UpdateConfigRequest(
config=config,
)
# Make the request to update the config
response = client.update_config(request=request)
print(f"Successfully updated config: {response.name}")
return response
gcloud
כדי להפעיל את ההטמעה של שושלת הנתונים בשירות ספציפי, משתמשים בפקודה gcloud datalineage config update עם מחרוזת JSON מוטבעת או עם נתיב לקובץ JSON שבו הערך של lineageEnablement.enabled מוגדר ל-true עבור integration ספציפי. השילובים הקיימים כוללים Managed Service for Apache Spark, BigQuery ו-Managed Airflow.
בדוגמה הבאה מוצג אופן ההפעלה של הטמעת שירות ב-Data Lineage של פרויקט באמצעות מחרוזת JSON מוטבעת:
gcloud datalineage config update --project=PROJECT_ID \
--config='{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "ETAG"
}'
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט שרוצים לעדכן את ההגדרות שלו. -
INTEGRATION: השילוב שהגדרתם עבורו את התצורה (לדוגמה,DATAPROCאוBIGQUERY). -
ETAG: הערךetagשמוחזר מבקשתgetעדכנית בגוף הבקשה, ומשמש לאימות שההגדרה לא השתנתה מאז בקשת הקריאה האחרונה.
כדי לעדכן את ההגדרה באמצעות קובץ JSON, מריצים את הפקודה:
gcloud datalineage config update --project=PROJECT_ID --config=CONFIG_FILE
מחליפים את מה שכתוב בשדות הבאים:
-
CONFIG_FILE: הנתיב לקובץ ה-JSON שמכיל את ההגדרה.
כדי להפעיל את ההטמעה של שירות לתיעוד מקורות נתונים בתיקייה או בארגון, מחליפים את --project= באחת מהאפשרויות הבאות:PROJECT_ID
--folder=אם רוצים לעדכן את הגדרות הטמעת הנתונים בתיקייה.FOLDER_ID--organization=אם רוצים לעדכן את הגדרות הטמעת הנתונים בארגון.ORGANIZATION_ID
REST
כדי להפעיל את ההטמעה של שושלת הנתונים בשירות ספציפי, צריך להשתמש בשיטה projects.locations.config.patch עם כלל הטמעה שמגדיר את lineageEnablement.enabled ל-true עבור integration ספציפי.
כדי למנוע החלפה לא מכוונת של הגדרות שמשתמשים אחרים יצרו בתרחישים של קריאה-שינוי-כתיבה, אפשר לכלול את השדה etag בגוף הבקשה. מידע נוסף מופיע במאמר בנושא קבלת ההגדרה הנוכחית.
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
-
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
PROJECT_ID: מזהה הפרויקט שרוצים לעדכן את ההגדרה שלו. -
ETAG: הערךetagשמוחזר מבקשתgetעדכנית. -
INTEGRATION:integrationשהגדרתם עבורו את התצורה. לדוגמה,DATAPROC.
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/global/config
תוכן בקשת JSON:
{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "ETAG"
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"name": "projects/PROJECT_ID/locations/global/config",
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "INTEGRATION"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "1a2b3c4d5e"
}
כדי להפעיל את הטמעת נתוני שושלת הנתונים של שירות לתיקייה או לארגון, מחליפים את projects/ ב-PROJECT_IDfolders/ או ב-FOLDER_IDorganizations/.ORGANIZATION_ID
הגדרת הטמעת שושלת נתונים לכמה שירותים
כדי להגדיר הטמעה של נתוני מקורות נתונים לכמה אינטגרציות בו-זמנית, משתמשים בשיטות projects.locations.config.patch, folders.locations.config.patch או organizations.locations.config.patch. אפשר לעדכן את ההגדרה ברמת הפרויקט, התיקייה או הארגון על ידי הגדרת כמה כללים בגוף הבקשה. מידע נוסף זמין במאמר איך עובדת ההגדרה של העברת נתונים באינטגרציות עם כמה שירותים.
ברמת הארגון
מגדירים את הארגון כך שיופעל בו ייבוא של נתוני שושלת ל-Managed Service for Apache Spark:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-H "X-Goog-User-Project: CLIENT_PROJECT_ID" \
"https://datalineage.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/config" \
-d '{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "DATAPROC"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "ORGANIZATION_CONFIG_ETAG"
}'
מחליפים את מה שכתוב בשדות הבאים:
-
ORGANIZATION_ID: המזהה של הארגון שרוצים לעדכן את ההגדרות שלו. -
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
ORGANIZATION_CONFIG_ETAG: הערךetagשמוחזר מבקשתgetעדכנית להגדרות הארגון.
ברמת התיקייה
מגדירים את התיקייה להפעלת הטמעה של שושלת נתונים ב-BigQuery:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-H "X-Goog-User-Project: CLIENT_PROJECT_ID" \
"https://datalineage.googleapis.com/v1/folders/FOLDER_ID/locations/global/config" \
-d '{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "BIGQUERY"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "FOLDER_CONFIG_ETAG"
}'
מחליפים את מה שכתוב בשדות הבאים:
-
FOLDER_ID: המזהה של התיקייה שרוצים לעדכן את ההגדרות שלה. -
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
FOLDER_CONFIG_ETAG: הערךetagשמוחזר מבקשתgetעדכנית לתצורה של התיקייה.
ברמת הפרויקט
מגדירים את הפרויקט כך שהטמעת שושלת הנתונים ב-BigQuery תושבת והטמעת שושלת הנתונים ב-Managed Service for Apache Airflow תופעל בו-זמנית:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-H "X-Goog-User-Project: CLIENT_PROJECT_ID" \
"https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/global/config" \
-d '{
"ingestion": {
"rules": [
{
"integrationSelector": {
"integration": "BIGQUERY"
},
"lineageEnablement": {
"enabled": false
}
},
{
"integrationSelector": {
"integration": "MANAGED_AIRFLOW"
},
"lineageEnablement": {
"enabled": true
}
}
]
},
"etag": "PROJECT_CONFIG_ETAG"
}'
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט שרוצים לעדכן את ההגדרות שלו. -
CLIENT_PROJECT_ID: המזהה של פרויקט הלקוח שמשמש לחיוב או למכסות. -
PROJECT_CONFIG_ETAG: הערךetagשמוחזר מבקשתgetעדכנית להגדרות הפרויקט.