@@ -21,17 +21,25 @@ def __init__(
2121 self ,
2222 * ,
2323 id : Optional [str ] = None ,
24- is_production : str = True ,
25- genesis_transactions : Optional [str ] = None ,
26- genesis_file : Optional [str ] = None ,
27- genesis_url : Optional [str ] = None ,
24+ is_production : bool = True ,
25+ is_write : bool = False ,
26+ keepalive : int = 5 ,
27+ read_only : bool = False ,
28+ socks_proxy : Optional [str ] = None ,
29+ pool_name : Optional [str ] = None ,
30+ endorser_alias : Optional [str ] = None ,
31+ endorser_did : Optional [str ] = None ,
2832 ):
2933 """Initialize LedgerConfigInstance."""
30- self .id = id
34+ self .id = id or str ( uuid4 ())
3135 self .is_production = is_production
32- self .genesis_transactions = genesis_transactions
33- self .genesis_file = genesis_file
34- self .genesis_url = genesis_url
36+ self .is_write = is_write
37+ self .keepalive = keepalive
38+ self .read_only = read_only
39+ self .socks_proxy = socks_proxy
40+ self .pool_name = pool_name or self .id
41+ self .endorser_alias = endorser_alias
42+ self .endorser_did = endorser_did
3543
3644
3745class LedgerConfigInstanceSchema (BaseModelSchema ):
@@ -43,13 +51,46 @@ class Meta:
4351 model_class = LedgerConfigInstance
4452 unknown = EXCLUDE
4553
46- id = fields .Str (required = False , metadata = {"description" : "ledger_id" })
47- is_production = fields .Bool (required = False , metadata = {"description" : "is_production" })
48- genesis_transactions = fields .Str (
49- required = False , metadata = {"description" : "genesis_transactions" }
54+ id = fields .Str (
55+ required = True ,
56+ metadata = {
57+ "description" : "Ledger identifier. Auto-generated UUID4 if not provided" ,
58+ "example" : "f47ac10b-58cc-4372-a567-0e02b2c3d479" ,
59+ },
60+ )
61+ is_production = fields .Bool (
62+ required = True , metadata = {"description" : "Production-grade ledger (true/false)" }
63+ )
64+ is_write = fields .Bool (
65+ required = False ,
66+ metadata = {"description" : "Write capability enabled (default: False)" },
67+ )
68+ keepalive = fields .Int (
69+ required = False ,
70+ metadata = {
71+ "description" : "Keep-alive timeout in seconds for idle connections" ,
72+ "default" : 5 ,
73+ },
74+ )
75+ read_only = fields .Bool (
76+ required = False , metadata = {"description" : "Read-only access (default: False)" }
77+ )
78+ socks_proxy = fields .Str (
79+ required = False , metadata = {"description" : "SOCKS proxy URL (optional)" }
80+ )
81+ pool_name = fields .Str (
82+ required = False ,
83+ metadata = {
84+ "description" : "Ledger pool name (defaults to ledger ID if not specified)" ,
85+ "example" : "bcovrin-test-pool" ,
86+ },
87+ )
88+ endorser_alias = fields .Str (
89+ required = False , metadata = {"description" : "Endorser service alias (optional)" }
90+ )
91+ endorser_did = fields .Str (
92+ required = False , metadata = {"description" : "Endorser DID (optional)" }
5093 )
51- genesis_file = fields .Str (required = False , metadata = {"description" : "genesis_file" })
52- genesis_url = fields .Str (required = False , metadata = {"description" : "genesis_url" })
5394
5495 @pre_load
5596 def validate_id (self , data , ** kwargs ):
@@ -58,12 +99,27 @@ def validate_id(self, data, **kwargs):
5899 data ["id" ] = str (uuid4 ())
59100 return data
60101
102+ @pre_load
103+ def set_defaults (self , data , ** kwargs ):
104+ """Set default values for optional fields."""
105+ data .setdefault ("is_write" , False )
106+ data .setdefault ("keepalive" , 5 )
107+ data .setdefault ("read_only" , False )
108+ return data
109+
61110
62111class LedgerConfigListSchema (OpenAPISchema ):
63112 """Schema for Ledger Config List."""
64113
65- ledger_config_list = fields .List (
66- fields .Nested (LedgerConfigInstanceSchema (), required = True ), required = True
114+ production_ledgers = fields .List ( # Changed from ledger_config_list
115+ fields .Nested (LedgerConfigInstanceSchema (), required = True ),
116+ required = True ,
117+ metadata = {"description" : "Production ledgers (may be empty)" },
118+ )
119+ non_production_ledgers = fields .List ( # Added new field
120+ fields .Nested (LedgerConfigInstanceSchema (), required = True ),
121+ required = True ,
122+ metadata = {"description" : "Non-production ledgers (may be empty)" },
67123 )
68124
69125
0 commit comments