Schema API
Mappings & Contracts

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

PropertyTypeDescription
idintUnique mappings type ID
namestrDisplay name
entryListIdintAssociated 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

ParameterTypeDescription
mappings_type_idintThe mappings type ID (from get_mappings_types())

Mapping Properties

PropertyTypeDescription
idintUnique mapping ID
namestrMapping display name
entryListIdintAssociated 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

ParameterTypeDescription
schema_contract_global_idstrThe UUID of the schema contract

Returns

TypeDescription
strSchema 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