Skip to content

Commit e6ecf88

Browse files
author
Datata1
committed
feat(domain): stash changes for later
1 parent 0d9d07c commit e6ecf88

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

examples/domains/create_domain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import asyncio
2+
import logging
3+
from codesphere import CodesphereSDK
4+
5+
logging.basicConfig(level=logging.INFO)
6+
7+
8+
async def main():
9+
async with CodesphereSDK() as sdk:
10+
domain = await sdk.domains.create(team_id=35663, domain_name="test.com")
11+
print(domain.model_dump_json(indent=2))
12+
13+
14+
if __name__ == "__main__":
15+
asyncio.run(main())

examples/domains/get_domain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import asyncio
2+
import logging
3+
from codesphere import CodesphereSDK
4+
5+
logging.basicConfig(level=logging.INFO)
6+
7+
8+
async def main():
9+
async with CodesphereSDK() as sdk:
10+
domain = await sdk.domains.get(team_id=35663, domain_name="test.com")
11+
print(domain.model_dump_json(indent=2))
12+
13+
14+
if __name__ == "__main__":
15+
asyncio.run(main())

examples/domains/update_domain.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import asyncio
2+
import logging
3+
from codesphere import CodesphereSDK, CustomDomainConfig
4+
5+
logging.basicConfig(level=logging.INFO)
6+
7+
8+
async def main():
9+
async with CodesphereSDK() as sdk:
10+
domain = await sdk.domains.get(team_id=35663, domain_name="test.com")
11+
print(domain.model_dump_json(indent=2))
12+
newConfig = CustomDomainConfig(
13+
max_body_size_mb=24, max_connection_timeout_s=50, restricted=True
14+
)
15+
await domain.update_domain(data=newConfig)
16+
print(domain.model_dump_json(indent=2))
17+
18+
19+
if __name__ == "__main__":
20+
asyncio.run(main())

src/codesphere/resources/domain/models.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ class DomainVerificationStatus(BaseModel):
5353

5454

5555
class CustomDomainConfig(BaseModel):
56-
max_body_size_mb: int
57-
max_connection_timeout: int
58-
use_regex: bool
59-
restricted: bool
56+
model_config = camel_config
57+
restricted: Optional[bool] = None
58+
max_body_size_mb: Optional[int] = None
59+
max_connection_timeout_s: Optional[int] = None
60+
use_regex: Optional[bool] = None
6061

6162

6263
class Domain(DomainBase, _APIOperationExecutor):
@@ -73,6 +74,7 @@ class Domain(DomainBase, _APIOperationExecutor):
7374
default=APIOperation(
7475
method="PUT",
7576
endpoint_template="/domains/team/{team_id}/domain/{name}/workspace-connections",
77+
input_model=CustomDomainConfig,
7678
response_model=DomainBase,
7779
),
7880
exclude=True,
@@ -97,8 +99,10 @@ class Domain(DomainBase, _APIOperationExecutor):
9799
)
98100

99101
async def update_domain(self, data: CustomDomainConfig) -> DomainBase:
100-
await self.update_domain_op(data=data)
101-
update_model_fields(target=self.custom_config, source=data)
102+
payload = data.model_dump(exclude_unset=True, by_alias=True)
103+
response = await self.update_domain_op(data=payload)
104+
update_model_fields(target=self, source=response)
105+
return response
102106

103107
async def update_workspace_connections(
104108
self, data: dict[str, list[int]]

0 commit comments

Comments
 (0)