99from yarl import URL
1010
1111from .components import Callback , HttpComponent , MetablockResponseError
12- from .extensions import Extensions , Plugins
13- from .orgs import Orgs
14- from .spaces import Blocks , Domains , Space , Spaces
12+ from .extensions import Extension , Extensions , Plugin , Plugins
13+ from .orgs import Org , Orgs
14+ from .spaces import Block , Blocks , Domains , Space , Spaces
1515from .user import User
1616
1717DEFAULT_USER_AGENT = f"Python/{ '.' .join (map (str , sys .version_info [:2 ]))} metablock"
@@ -41,13 +41,13 @@ def __init__(
4141 "user-agent" : user_agent ,
4242 "accept" : "application/json" ,
4343 }
44- self .spaces : Spaces = Spaces (self )
44+ self .orgs : Orgs = Orgs (self , Org )
45+ self .spaces : Spaces = Spaces (self , Space )
46+ self .blocks : Blocks = Blocks (self , Block , "services" )
47+ self .plugins : Plugins = Plugins (self , Plugin )
48+ self .extensions : Extensions = Extensions (self , Extension )
4549 self .domains = Domains (self )
46- self .orgs : Orgs = Orgs (self )
47- self .blocks : Blocks = Blocks (self , "services" )
4850 self .services = self .blocks
49- self .plugins : Plugins = Plugins (self )
50- self .extensions : Extensions = Extensions (self )
5151
5252 def __repr__ (self ) -> str :
5353 return self .url
@@ -69,9 +69,29 @@ async def __aexit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> None:
6969 await self .close ()
7070
7171 async def spec (self ) -> dict :
72- return await self .execute (f"{ self .url } /spec" )
72+ return await self .request (f"{ self .url } /spec" )
7373
74- async def execute (
74+ async def get (self , url : str | URL , ** kwargs : Any ) -> Any :
75+ kwargs ["method" ] = "GET"
76+ return await self .request (url , ** kwargs )
77+
78+ async def patch (self , url : str | URL , ** kwargs : Any ) -> Any :
79+ kwargs ["method" ] = "PATCH"
80+ return await self .request (url , ** kwargs )
81+
82+ async def post (self , url : str | URL , ** kwargs : Any ) -> Any :
83+ kwargs ["method" ] = "POST"
84+ return await self .request (url , ** kwargs )
85+
86+ async def put (self , url : str | URL , ** kwargs : Any ) -> Any :
87+ kwargs ["method" ] = "PUT"
88+ return await self .request (url , ** kwargs )
89+
90+ async def delete (self , url : str | URL , ** kwargs : Any ) -> Any :
91+ kwargs ["method" ] = "DELETE"
92+ return await self .request (url , ** kwargs )
93+
94+ async def request (
7595 self ,
7696 url : str | URL ,
7797 method : str = "" ,
0 commit comments