Skip to content

Commit 92fb65e

Browse files
committed
Utility methods
1 parent 60a67ac commit 92fb65e

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

metablock/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async def _apply(path: str, space_name: str, token: str, dry_run: bool) -> None:
132132
block = by_name.get(name)
133133
if block:
134134
# update
135-
await mb.blocks.patch(block.id, **config)
135+
await mb.blocks.update(block.id, **config)
136136
click.echo(f"updated block {name}")
137137
else:
138138
# create

metablock/orgs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ async def get_list(
2626
)
2727
return [Space(root=self.cli.spaces, root_path=s["name"], **s) for s in data]
2828

29+
async def get(self, space_id_or_name: str) -> Space:
30+
return await self.cli.spaces.get(space_id_or_name)
31+
32+
async def update(self, space_id_or_name: str, **kwargs: Any) -> Space:
33+
return await self.cli.spaces.update(space_id_or_name, **kwargs)
34+
2935
async def create(self, **data: Any) -> Space:
3036
data = await self.cli.post(f"{self.url}", json=data)
3137
return Space(root=self.cli.spaces, root_path=data["name"], **data)

metablock/spaces.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Space(MetablockEntity):
1717
domain: str = Field(description="The domain of the space")
1818
org_id: str = Field(description="The organization id of the space")
1919
org_name: str = Field(description="The organization name of the space")
20+
hosted: bool = Field(
21+
description="Whether the space is hosted in metablock or self-hosted",
22+
)
2023

2124
@property
2225
def blocks(self) -> SpaceBlocks:
@@ -34,6 +37,10 @@ async def get(self, space_id_or_name: str) -> Space:
3437
data = await self.cli.get(f"{self.url}/{space_id_or_name}")
3538
return Space(root=self, root_path=data["id"], **data)
3639

40+
async def update(self, space_id_or_name: str, **kwargs: Any) -> Space:
41+
data = await self.cli.patch(f"{self.url}/{space_id_or_name}", json=kwargs)
42+
return Space(root=self, root_path=data["id"], **data)
43+
3744

3845
class Route(BaseModel):
3946
id: str = Field(description="The unique identifier of the route")
@@ -76,6 +83,10 @@ class Block(MetablockEntity):
7683
default_factory=list,
7784
description="The routes of the block",
7885
)
86+
tags: list[str] = Field(
87+
default_factory=list,
88+
description="An optional set of strings",
89+
)
7990
# space: Space = Field(description="The space of the block")
8091

8192
@property
@@ -127,7 +138,7 @@ async def get(self, block_id: str) -> Block:
127138
**data,
128139
)
129140

130-
async def patch(self, block_id: str, **kwargs: Any) -> Block:
141+
async def update(self, block_id: str, **kwargs: Any) -> Block:
131142
"""Update a block by id"""
132143
data = await self.cli.patch(f"{self.url}/{block_id}", json=kwargs)
133144
return Block(

0 commit comments

Comments
 (0)