pub struct ODCSContract {Show 24 fields
pub api_version: String,
pub kind: String,
pub id: String,
pub version: String,
pub name: String,
pub status: Option<String>,
pub domain: Option<String>,
pub data_product: Option<String>,
pub tenant: Option<String>,
pub description: Option<Description>,
pub schema: Vec<SchemaObject>,
pub servers: Vec<Server>,
pub team: Option<Team>,
pub support: Option<Support>,
pub roles: Vec<Role>,
pub service_levels: Vec<ServiceLevel>,
pub quality: Vec<QualityRule>,
pub price: Option<Price>,
pub terms: Option<Terms>,
pub links: Vec<Link>,
pub authoritative_definitions: Vec<AuthoritativeDefinition>,
pub tags: Vec<String>,
pub custom_properties: Vec<CustomProperty>,
pub contract_created_ts: Option<String>,
}Expand description
ODCSContract - the root data contract document (ODCS v3.1.0)
This is the top-level structure that represents an entire ODCS data contract. It contains all contract-level metadata plus one or more schema objects (tables).
§Example
use data_modelling_core::models::odcs::{ODCSContract, SchemaObject, Property};
let contract = ODCSContract::new("customer-contract", "v1.0.0")
.with_domain("retail")
.with_status("active")
.with_schema(
SchemaObject::new("customers")
.with_physical_type("table")
.with_properties(vec![
Property::new("id", "integer").with_primary_key(true),
Property::new("name", "string").with_required(true),
])
);Fields§
§api_version: StringAPI version (e.g., “v3.1.0”)
kind: StringKind identifier (always “DataContract”)
id: StringUnique contract ID (UUID or other identifier)
version: StringContract version (semantic versioning recommended)
name: StringContract name
status: Option<String>Contract status: “draft”, “active”, “deprecated”, “retired”
domain: Option<String>Domain this contract belongs to
data_product: Option<String>Data product this contract belongs to
tenant: Option<String>Tenant identifier for multi-tenant systems
description: Option<Description>Contract description (can be simple string or structured object)
schema: Vec<SchemaObject>Schema objects (tables, views, topics) in this contract
servers: Vec<Server>Server configurations
team: Option<Team>Team information
support: Option<Support>Support information
roles: Vec<Role>Role definitions
service_levels: Vec<ServiceLevel>Service level agreements
quality: Vec<QualityRule>Contract-level quality rules
price: Option<Price>Price information
terms: Option<Terms>Terms and conditions
links: Vec<Link>External links
Authoritative definitions
Contract-level tags
custom_properties: Vec<CustomProperty>Custom properties for format-specific metadata
contract_created_ts: Option<String>Contract creation timestamp (ISO 8601)
Implementations§
Source§impl ODCSContract
impl ODCSContract
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> ODCSContract
pub fn new(name: impl Into<String>, version: impl Into<String>) -> ODCSContract
Create a new contract with the given name and version
Sourcepub fn new_with_id(
id: impl Into<String>,
name: impl Into<String>,
version: impl Into<String>,
) -> ODCSContract
pub fn new_with_id( id: impl Into<String>, name: impl Into<String>, version: impl Into<String>, ) -> ODCSContract
Create a new contract with a specific ID
Sourcepub fn with_api_version(self, api_version: impl Into<String>) -> ODCSContract
pub fn with_api_version(self, api_version: impl Into<String>) -> ODCSContract
Set the API version
Sourcepub fn with_status(self, status: impl Into<String>) -> ODCSContract
pub fn with_status(self, status: impl Into<String>) -> ODCSContract
Set the status
Sourcepub fn with_domain(self, domain: impl Into<String>) -> ODCSContract
pub fn with_domain(self, domain: impl Into<String>) -> ODCSContract
Set the domain
Sourcepub fn with_data_product(self, data_product: impl Into<String>) -> ODCSContract
pub fn with_data_product(self, data_product: impl Into<String>) -> ODCSContract
Set the data product
Sourcepub fn with_tenant(self, tenant: impl Into<String>) -> ODCSContract
pub fn with_tenant(self, tenant: impl Into<String>) -> ODCSContract
Set the tenant
Sourcepub fn with_description(self, description: impl Into<String>) -> ODCSContract
pub fn with_description(self, description: impl Into<String>) -> ODCSContract
Set the description (simple string)
Sourcepub fn with_structured_description(
self,
description: Description,
) -> ODCSContract
pub fn with_structured_description( self, description: Description, ) -> ODCSContract
Set a structured description
Sourcepub fn with_schema(self, schema: SchemaObject) -> ODCSContract
pub fn with_schema(self, schema: SchemaObject) -> ODCSContract
Add a schema object
Sourcepub fn with_schemas(self, schemas: Vec<SchemaObject>) -> ODCSContract
pub fn with_schemas(self, schemas: Vec<SchemaObject>) -> ODCSContract
Set all schema objects
Sourcepub fn with_server(self, server: Server) -> ODCSContract
pub fn with_server(self, server: Server) -> ODCSContract
Add a server configuration
Sourcepub fn with_team(self, team: Team) -> ODCSContract
pub fn with_team(self, team: Team) -> ODCSContract
Set the team information
Sourcepub fn with_support(self, support: Support) -> ODCSContract
pub fn with_support(self, support: Support) -> ODCSContract
Set the support information
Sourcepub fn with_role(self, role: Role) -> ODCSContract
pub fn with_role(self, role: Role) -> ODCSContract
Add a role
Sourcepub fn with_service_level(self, service_level: ServiceLevel) -> ODCSContract
pub fn with_service_level(self, service_level: ServiceLevel) -> ODCSContract
Add a service level
Sourcepub fn with_quality_rule(self, rule: QualityRule) -> ODCSContract
pub fn with_quality_rule(self, rule: QualityRule) -> ODCSContract
Add a quality rule
Sourcepub fn with_price(self, price: Price) -> ODCSContract
pub fn with_price(self, price: Price) -> ODCSContract
Set the price
Sourcepub fn with_terms(self, terms: Terms) -> ODCSContract
pub fn with_terms(self, terms: Terms) -> ODCSContract
Set the terms
Sourcepub fn with_link(self, link: Link) -> ODCSContract
pub fn with_link(self, link: Link) -> ODCSContract
Add a link
Add an authoritative definition
Sourcepub fn with_tag(self, tag: impl Into<String>) -> ODCSContract
pub fn with_tag(self, tag: impl Into<String>) -> ODCSContract
Add a tag
Set all tags
Sourcepub fn with_custom_property(
self,
custom_property: CustomProperty,
) -> ODCSContract
pub fn with_custom_property( self, custom_property: CustomProperty, ) -> ODCSContract
Add a custom property
Sourcepub fn with_contract_created_ts(
self,
timestamp: impl Into<String>,
) -> ODCSContract
pub fn with_contract_created_ts( self, timestamp: impl Into<String>, ) -> ODCSContract
Set the contract creation timestamp
Sourcepub fn schema_count(&self) -> usize
pub fn schema_count(&self) -> usize
Get the number of schema objects
Sourcepub fn get_schema(&self, name: &str) -> Option<&SchemaObject>
pub fn get_schema(&self, name: &str) -> Option<&SchemaObject>
Get a schema object by name
Sourcepub fn get_schema_mut(&mut self, name: &str) -> Option<&mut SchemaObject>
pub fn get_schema_mut(&mut self, name: &str) -> Option<&mut SchemaObject>
Get a mutable schema object by name
Sourcepub fn schema_names(&self) -> Vec<&str>
pub fn schema_names(&self) -> Vec<&str>
Get all schema names
Sourcepub fn is_multi_table(&self) -> bool
pub fn is_multi_table(&self) -> bool
Check if this is a multi-table contract
Sourcepub fn first_schema(&self) -> Option<&SchemaObject>
pub fn first_schema(&self) -> Option<&SchemaObject>
Get the first schema (for single-table contracts)
Sourcepub fn description_string(&self) -> Option<String>
pub fn description_string(&self) -> Option<String>
Get the description as a simple string
Source§impl ODCSContract
impl ODCSContract
Sourcepub fn to_tables(&self) -> Vec<Table>
pub fn to_tables(&self) -> Vec<Table>
Convert the contract to a vector of Tables
Each SchemaObject becomes a Table, with contract-level metadata stored in each table’s odcl_metadata.
Sourcepub fn from_tables(tables: &[Table]) -> ODCSContract
pub fn from_tables(tables: &[Table]) -> ODCSContract
Create a contract from a vector of Tables
Contract-level metadata is extracted from the first table’s odcl_metadata. Each table becomes a SchemaObject.
Sourcepub fn to_table_data(&self) -> Vec<TableData>
pub fn to_table_data(&self) -> Vec<TableData>
Convert contract to TableData for API responses
Trait Implementations§
Source§impl Clone for ODCSContract
impl Clone for ODCSContract
Source§fn clone(&self) -> ODCSContract
fn clone(&self) -> ODCSContract
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more