9
9
from yarl import URL
10
10
11
11
from .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
15
15
from .user import User
16
16
17
17
DEFAULT_USER_AGENT = f"Python/{ '.' .join (map (str , sys .version_info [:2 ]))} metablock"
@@ -41,13 +41,13 @@ def __init__(
41
41
"user-agent" : user_agent ,
42
42
"accept" : "application/json" ,
43
43
}
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 )
45
49
self .domains = Domains (self )
46
- self .orgs : Orgs = Orgs (self )
47
- self .blocks : Blocks = Blocks (self , "services" )
48
50
self .services = self .blocks
49
- self .plugins : Plugins = Plugins (self )
50
- self .extensions : Extensions = Extensions (self )
51
51
52
52
def __repr__ (self ) -> str :
53
53
return self .url
@@ -69,9 +69,29 @@ async def __aexit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> None:
69
69
await self .close ()
70
70
71
71
async def spec (self ) -> dict :
72
- return await self .execute (f"{ self .url } /spec" )
72
+ return await self .request (f"{ self .url } /spec" )
73
73
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 (
75
95
self ,
76
96
url : str | URL ,
77
97
method : str = "" ,
0 commit comments