Skip to content

Commit ac9fd7e

Browse files
committed
Created synchronization policy resources for server and auth zone level configuration.
Updated the server and authoritative zone server resources to include synchronization policy fields.
1 parent cf10c35 commit ac9fd7e

3 files changed

Lines changed: 127 additions & 0 deletions

File tree

src/dnsmin/models/servers/server.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pydantic import BaseModel, Field
66

77
from dnsmin.enums import ServerTypeEnum, AuthServerModeEnum
8+
from dnsmin.models.sync import ServerSyncPolicy
89

910

1011
class Server(BaseModel):
@@ -68,6 +69,14 @@ class Server(BaseModel):
6869
)
6970
"""Indicates whether the server is shared between tenants."""
7071

72+
sync_policy: Optional[ServerSyncPolicy] = Field(
73+
title='Synchronization Policy',
74+
description='The synchronization policy of the server.',
75+
default=None,
76+
examples=[ServerSyncPolicy()],
77+
)
78+
"""The synchronization policy of the server."""
79+
7180
created_at: datetime = Field(
7281
title='Created At',
7382
description='The timestamp representing when the server was created.',
@@ -139,6 +148,14 @@ class CreateServer(BaseModel):
139148
)
140149
"""Indicates whether the server is shared between tenants."""
141150

151+
sync_policy: Optional[ServerSyncPolicy] = Field(
152+
title='Synchronization Policy',
153+
description='The synchronization policy of the server.',
154+
default=None,
155+
examples=[ServerSyncPolicy()],
156+
)
157+
"""The synchronization policy of the server."""
158+
142159

143160
class UpdateServer(CreateServer):
144161
"""Provides an API input model for updating servers."""

src/dnsmin/models/sync.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from pydantic import BaseModel, Field
2+
3+
4+
class ZoneSyncPolicy(BaseModel):
5+
"""Defines a synchronization policy for zones that are synchronized with DNS servers."""
6+
7+
create_missing_zones_in_server: bool = Field(
8+
title='Create Missing Zones In Server',
9+
description='Whether to create zones in a DNS server that are present in the database.',
10+
default=False,
11+
)
12+
"""Whether to create zones in a DNS server that are present in the database."""
13+
14+
update_zones_in_db: bool = Field(
15+
title='Update Zones In Database',
16+
description='Whether to update zones in the database from updates in a DNS server.',
17+
default=False,
18+
)
19+
"""Whether to update zones in the database from updates in a DNS server."""
20+
21+
update_zones_in_server: bool = Field(
22+
title='Update Zones In Server',
23+
description='Whether to update zones in a DNS server from updates in the database.',
24+
default=False,
25+
)
26+
"""Whether to update zones in a DNS server from updates in the database."""
27+
28+
purge_missing_zones_in_db: bool = Field(
29+
title='Purge Missing Zones In Database',
30+
description='Whether to purge zones in the database that are not present in a DNS server.',
31+
default=False,
32+
)
33+
"""Whether to purge zones in the database that are not present in a DNS server."""
34+
35+
purge_missing_zones_in_server: bool = Field(
36+
title='Purge Missing Zones In Server',
37+
description='Whether to purge zones in a DNS server that are not present in the database.',
38+
default=False,
39+
)
40+
"""Whether to purge zones in a DNS server that are not present in the database."""
41+
42+
create_missing_records_in_db: bool = Field(
43+
title='Create Missing Records In Database',
44+
description='Whether to create records in the database that are present in a DNS server.',
45+
default=False,
46+
)
47+
"""Whether to create records in the database that are present in a DNS server."""
48+
49+
create_missing_records_in_server: bool = Field(
50+
title='Create Missing Records In Server',
51+
description='Whether to create records in a DNS server that are present in the database.',
52+
default=False,
53+
)
54+
"""Whether to create records in a DNS server that are present in the database."""
55+
56+
update_records_in_db: bool = Field(
57+
title='Update Records In Database',
58+
description='Whether to update records in the database from updates in a DNS server.',
59+
default=False,
60+
)
61+
"""Whether to update records in the database from updates in a DNS server."""
62+
63+
update_records_in_server: bool = Field(
64+
title='Update Records In Server',
65+
description='Whether to update records in a DNS server from updates in the database.',
66+
default=False,
67+
)
68+
"""Whether to update records in a DNS server from updates in the database."""
69+
70+
purge_missing_records_in_db: bool = Field(
71+
title='Purge Missing Records In Database',
72+
description='Whether to purge records in the database that are not present in a DNS server.',
73+
default=False,
74+
)
75+
"""Whether to purge records in the database that are not present in a DNS server."""
76+
77+
purge_missing_records_in_server: bool = Field(
78+
title='Purge Missing Records In Server',
79+
description='Whether to purge records in a DNS server that are not present in the database.',
80+
default=False,
81+
)
82+
"""Whether to purge records in a DNS server that are not present in the database."""
83+
84+
85+
class ServerSyncPolicy(ZoneSyncPolicy):
86+
"""Defines a zone synchronization policy for servers."""
87+
88+
create_missing_zones_in_db: bool = Field(
89+
title='Create Missing Zones In Database',
90+
description='Whether to create zones in the database that are present in a DNS server.',
91+
default=False,
92+
)
93+
"""Whether to create zones in the database that are present in a DNS server."""

src/dnsmin/models/zones/azone_server.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pydantic import BaseModel, Field
66

77
from dnsmin.enums import ZoneServerStateEnum
8+
from dnsmin.models.sync import ZoneSyncPolicy
89

910

1011
class AZoneServer(BaseModel):
@@ -39,6 +40,14 @@ class AZoneServer(BaseModel):
3940
)
4041
"""The synchronization state of the relationship."""
4142

43+
sync_policy: Optional[ZoneSyncPolicy] = Field(
44+
title='Synchronization Policy',
45+
description='The synchronization policy of the relationship.',
46+
default=None,
47+
examples=[ZoneSyncPolicy()],
48+
)
49+
"""The synchronization policy of the relationship."""
50+
4251
created_at: datetime = Field(
4352
title='Created At',
4453
description='The timestamp representing when the authoritative zone record was created.',
@@ -88,6 +97,14 @@ class CreateAZoneServer(BaseModel):
8897
)
8998
"""The synchronization state of the relationship."""
9099

100+
sync_policy: Optional[ZoneSyncPolicy] = Field(
101+
title='Synchronization Policy',
102+
description='The synchronization policy of the relationship.',
103+
default=None,
104+
examples=[ZoneSyncPolicy()],
105+
)
106+
"""The synchronization policy of the relationship."""
107+
91108

92109
class UpdateAZoneServer(CreateAZoneServer):
93110
"""Provides an API input model for updating authoritative zone records."""

0 commit comments

Comments
 (0)