אתם יכולים להפעיל או להשבית באופן סלקטיבי את הטמעת שושלת הנתונים לשילובים ספציפיים ברמת הפרויקט, התיקייה או הארגון.
למידע נוסף על שילובים נתמכים ותרחישי הגדרה, קראו את המאמר שליטה בהטמעה של שושלת נתונים.
דרישות מוקדמות
כדי לשלוט בהטמעת שושלת הנתונים, צריך להשתמש ב-Data Lineage API. חשוב לוודא שיש לכם פרויקט לקוח שמוגדר לחיוב ולמכסה, כי Data Lineage API הוא ממשק API שמבוסס על לקוחות.
תפקידים והרשאות
כדי לקבל את ההרשאות שנדרשות להגדרה ולשליטה בהטמעה של שושלת נתונים, צריך לבקש מהאדמין להקצות לכם את התפקידים הבאים ב-Identity and Access Management (IAM):
כדי לקבל את ההרשאות שדרושות להגדרה ולשליטה בהטמעת שושלת הנתונים, בקשו מהאדמין להקצות לכם את התפקידים הבאים ב-IAM בפרויקט:
-
להגדיר ולנהל את שושלת הנתונים:
אדמין של שושלת נתונים (
roles/datalineage.admin)
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
התפקידים המוגדרים מראש האלה כוללים את ההרשאות שנדרשות כדי להגדיר ולשלוט בהטמעת שושלת הנתונים. כדי לראות בדיוק אילו הרשאות נדרשות, אפשר להרחיב את הקטע ההרשאות הנדרשות:
ההרשאות הנדרשות
כדי להגדיר ולשלוט בהטמעה של שושלת נתונים, נדרשות ההרשאות הבאות:
-
קבלת הגדרות של שושלת נתונים ועדכון שלהן:
-
datalineage.configs.get -
datalineage.configs.update
-
יכול להיות שתקבלו את ההרשאות האלה באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש אחרים.
מפעילים את ה-API של
datalineage.googleapis.comבפרויקט הלקוח. למידע נוסף, קראו את המאמר הפעלת שושלת נתונים.מגדירים את הפרויקט של הלקוח. בדוגמאות הבאות, משתמשים בכותרת
X-Goog-User-Project. מידע נוסף זמין במאמר פרמטרים של המערכת.
קבלת ההגדרות הנוכחיות
כדי לבדוק אם הטמעת שושלת הנתונים מופעלת במשאב, או כדי לקבל את הערך של etag לפני שמשנים את ההגדרות, צריך לאחזר את ההגדרות הנוכחיות.
C#
C#
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי הוראות ההגדרה של C# במדריך למתחילים של Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog C# API.
כדי לבצע אימות ב-Knowledge Catalog, צריך להגדיר את Application Default Credentials. למידע נוסף, ראו הגדרת אימות לסביבת פיתוח מקומית.
המשך
Go
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי הוראות ההגדרה של Go במדריך למתחילים של Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Go API.
כדי לבצע אימות ב-Knowledge Catalog, צריך להגדיר את Application Default Credentials. למידע נוסף, ראו הגדרת אימות לסביבת פיתוח מקומית.
Java
Java
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי הוראות ההגדרה של Java במדריך למתחילים של Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Java API.
כדי לבצע אימות ב-Knowledge Catalog, צריך להגדיר את Application Default Credentials. למידע נוסף, ראו הגדרת אימות לסביבת פיתוח מקומית.
Python
Python
לפני שמנסים את הדוגמה הזו, צריך לפעול לפי הוראות ההגדרה של Python במדריך למתחילים של Knowledge Catalog באמצעות ספריות לקוח. מידע נוסף מופיע במאמרי העזרה של Knowledge Catalog Python API.
כדי לבצע אימות ב-Knowledge Catalog, צריך להגדיר את 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
כדי לראות את הגדרת השושלת הנוכחית, משתמשים ב-method 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": {} }
כלומר, השירות משתמש בהגדרת ברירת המחדל להטמעת שושלת נתונים. בדוגמה הזו, הגדרת הטמעת שושלת הנתונים של Managed Service for 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 בתגובה הוא סיכום ביקורת (checksum) שנוצר על ידי השרת על סמך הערך הנוכחי של ההגדרה. כשמעדכנים הגדרה באמצעות ה-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
כדי להשבית את הטמעת שושלת היוחסין בשירות ספציפי, משתמשים ב-method 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.
בדוגמה הבאה מוסבר איך להפעיל הטמעת שושלת נתונים של שירות לפרויקט באמצעות מחרוזת 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
כדי להפעיל הטמעת שושלת נתונים בשירות ספציפי, משתמשים ב-method 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
הגדרת הטמעת שושלת נתונים לכמה שירותים
כדי להגדיר הטמעת שושלת נתונים לכמה שילובים בו-זמנית, משתמשים ב-methods 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שבוצעה לאחרונה להגדרות הפרויקט.