Mappings & Contracts
The Schema API provides methods to query object mappings, mapping types, and schema contracts. These are useful for managing external system integrations and schema versioning. HTTP uses intapp-rest-client.
Method names are get_mappings_types() and get_mappings(mappings_type_id) (plural mappings in both).
get_mappings_types()
Returns all object mappings types configured in the site. Mappings types define the categories of object-to-object mappings available (e.g., external system mappings).
from dealcloud_sdk import DealCloud, DealCloudConfig
config = DealCloudConfig(
siteUrl="yoursite.dealcloud.com",
clientId=12345,
clientSecret="your-secret",
)
dc = DealCloud.from_config_object(config)
mapping_types = dc.get_mappings_types()
for mt in mapping_types:
print(f"{mt.id}: {mt.name}")MappingsType Properties
| Property | Type | Description |
|---|---|---|
id | int | Unique mappings type ID |
name | str | Display name |
entryListId | int | Associated entry list ID |
get_mappings()
Returns all object mappings for a given mappings type:
# First, discover available mapping types
mapping_types = dc.get_mappings_types()
# Then retrieve mappings for a specific type
for mt in mapping_types:
mappings = dc.get_mappings(mappings_type_id=mt.id)
print(f"\n{mt.name} ({len(mappings)} mappings):")
for m in mappings:
print(f" {m.id}: {m.name}")Parameters
| Parameter | Type | Description |
|---|---|---|
mappings_type_id | int | The mappings type ID (from get_mappings_types()) |
Mapping Properties
| Property | Type | Description |
|---|---|---|
id | int | Unique mapping ID |
name | str | Mapping display name |
entryListId | int | Associated entry list ID |
Example: Build Complete Mappings Index
def get_all_mappings(dc):
"""Build a complete index of all mappings by type."""
mapping_types = dc.get_mappings_types()
index = {}
for mt in mapping_types:
mappings = dc.get_mappings(mt.id)
index[mt.name] = {
"type_id": mt.id,
"mappings": {m.name: m.id for m in mappings}
}
return index
mappings_index = get_all_mappings(dc)
for type_name, data in mappings_index.items():
print(f"\n{type_name}:")
for mapping_name, mapping_id in data["mappings"].items():
print(f" {mapping_name} (ID: {mapping_id})")get_contract()
Retrieves a schema contract by its global UUID. Schema contracts define the structure and validation rules for a particular schema version.
contract = dc.get_contract("a1b2c3d4-e5f6-7890-abcd-ef1234567890")
print(contract)Parameters
| Parameter | Type | Description |
|---|---|---|
schema_contract_global_id | str | The UUID of the schema contract |
Returns
| Type | Description |
|---|---|
str | Schema contract content |
Use Cases
Integration Field Mapping
Use mappings to maintain a mapping between DealCloud objects and external system entities:
def get_integration_mappings(dc, integration_name: str):
"""Get all mappings for a specific integration."""
mapping_types = dc.get_mappings_types()
# Find the integration mapping type
integration_type = next(
(mt for mt in mapping_types if mt.name == integration_name),
None
)
if not integration_type:
print(f"No mapping type found for '{integration_name}'")
return {}
mappings = dc.get_mappings(integration_type.id)
return {m.name: m.id for m in mappings}
# Get mappings for a specific external system
salesforce_mappings = get_integration_mappings(dc, "Salesforce")
for name, mapping_id in salesforce_mappings.items():
print(f" {name}: {mapping_id}")Audit Mapping Configuration
import pandas as pd
def export_mappings_report(dc, filepath: str):
"""Export a full report of all mappings configuration."""
mapping_types = dc.get_mappings_types()
rows = []
for mt in mapping_types:
mappings = dc.get_mappings(mt.id)
for m in mappings:
rows.append({
"Mapping Type": mt.name,
"Mapping Type ID": mt.id,
"Mapping Name": m.name,
"Mapping ID": m.id,
"Entry List ID": m.entryListId,
})
df = pd.DataFrame(rows)
df.to_excel(filepath, index=False)
print(f"Exported {len(rows)} mappings to {filepath}")
export_mappings_report(dc, "mappings_report.xlsx")Related
- Objects - Object metadata
- Fields - Field metadata
- Metadata Types - Field types and system types
- Schema Export - Export to Excel