10
10
from .replicate import ObjectReplicationProxy
11
11
12
12
13
- async def handle_get_object (
14
- request : aiohttp .web .Request
15
- ) -> aiohttp .web .StreamResponse :
13
+ async def handle_get_object (request : aiohttp .web .Request ) -> aiohttp .web .StreamResponse :
16
14
"""Handle a request for getting object content."""
17
15
auth = get_auth_instance (request )
18
16
@@ -21,7 +19,7 @@ async def handle_get_object(
21
19
await download .a_begin_download (
22
20
request .match_info ["project" ],
23
21
request .match_info ["container" ],
24
- request .match_info ["object_name" ]
22
+ request .match_info ["object_name" ],
25
23
)
26
24
27
25
resp = aiohttp .web .StreamResponse ()
@@ -39,7 +37,7 @@ async def handle_get_object(
39
37
40
38
41
39
async def handle_replicate_container (
42
- request : aiohttp .web .Request
40
+ request : aiohttp .web .Request ,
43
41
) -> aiohttp .web .Response :
44
42
"""Handle request to replicating a container from a source."""
45
43
auth = get_auth_instance (request )
@@ -51,22 +49,15 @@ async def handle_replicate_container(
51
49
source_container = request .query ["from_container" ]
52
50
53
51
replicator = ObjectReplicationProxy (
54
- auth ,
55
- request .app ["client" ],
56
- project ,
57
- container ,
58
- source_project ,
59
- source_container
52
+ auth , request .app ["client" ], project , container , source_project , source_container
60
53
)
61
54
62
55
asyncio .ensure_future (replicator .a_copy_from_container ())
63
56
64
57
return aiohttp .web .Response (status = 202 )
65
58
66
59
67
- async def handle_replicate_object (
68
- request : aiohttp .web .Request
69
- ) -> aiohttp .web .Response :
60
+ async def handle_replicate_object (request : aiohttp .web .Request ) -> aiohttp .web .Response :
70
61
"""Handle a request to replicating an object from a source."""
71
62
auth = get_auth_instance (request )
72
63
@@ -78,22 +69,15 @@ async def handle_replicate_object(
78
69
source_object = request .query ["from_object" ]
79
70
80
71
replicator = ObjectReplicationProxy (
81
- auth ,
82
- request .app ["client" ],
83
- project ,
84
- container ,
85
- source_project ,
86
- source_container
72
+ auth , request .app ["client" ], project , container , source_project , source_container
87
73
)
88
74
89
75
asyncio .ensure_future (replicator .a_copy_object (source_object ))
90
76
91
77
return aiohttp .web .Response (status = 202 )
92
78
93
79
94
- async def handle_post_object_chunk (
95
- request : aiohttp .web .Request
96
- ) -> aiohttp .web .Response :
80
+ async def handle_post_object_chunk (request : aiohttp .web .Request ) -> aiohttp .web .Response :
97
81
"""Handle a request for posting an object chunk."""
98
82
if "from_object" in request .query .keys ():
99
83
return await handle_replicate_object (request )
@@ -105,22 +89,12 @@ async def handle_post_object_chunk(
105
89
106
90
query , data = await parse_multipart_in (request )
107
91
108
- upload_session = await get_upload_instance (
109
- request ,
110
- project ,
111
- container ,
112
- p_query = query
113
- )
92
+ upload_session = await get_upload_instance (request , project , container , p_query = query )
114
93
115
- return await upload_session .a_add_chunk (
116
- query ,
117
- data
118
- )
94
+ return await upload_session .a_add_chunk (query , data )
119
95
120
96
121
- async def handle_get_object_chunk (
122
- request : aiohttp .web .Request
123
- ) -> aiohttp .web .Response :
97
+ async def handle_get_object_chunk (request : aiohttp .web .Request ) -> aiohttp .web .Response :
124
98
"""Handle a request for checking if a chunk exists."""
125
99
get_auth_instance (request )
126
100
@@ -134,19 +108,13 @@ async def handle_get_object_chunk(
134
108
except KeyError :
135
109
raise aiohttp .web .HTTPBadRequest (reason = "Malformed query string" )
136
110
137
- upload_session = await get_upload_instance (
138
- request ,
139
- project ,
140
- container
141
- )
111
+ upload_session = await get_upload_instance (request , project , container )
142
112
143
- return await upload_session .a_check_segment (
144
- chunk_number
145
- )
113
+ return await upload_session .a_check_segment (chunk_number )
146
114
147
115
148
116
async def handle_post_object_options (
149
- request : aiohttp .web .Request
117
+ request : aiohttp .web .Request ,
150
118
) -> aiohttp .web .Response :
151
119
"""Handle options request for posting the object chunk."""
152
120
resp = aiohttp .web .Response (
@@ -160,7 +128,7 @@ async def handle_post_object_options(
160
128
161
129
162
130
async def handle_get_container (
163
- request : aiohttp .web .Request
131
+ request : aiohttp .web .Request ,
164
132
) -> aiohttp .web .StreamResponse :
165
133
"""Handle a request for getting container contents as an archive."""
166
134
if "resumableChunkNumber" in request .query .keys ():
@@ -183,11 +151,7 @@ async def handle_get_container(
183
151
184
152
await resp .prepare (request )
185
153
186
- download = ContainerArchiveDownloadProxy (
187
- auth ,
188
- project ,
189
- container
190
- )
154
+ download = ContainerArchiveDownloadProxy (auth , project , container )
191
155
192
156
await download .a_begin_container_download ()
193
157
@@ -197,13 +161,13 @@ async def handle_get_container(
197
161
return resp
198
162
199
163
200
- async def handle_health_check (
201
- request : aiohttp .web .Request
202
- ) -> aiohttp .web .Response :
164
+ async def handle_health_check (request : aiohttp .web .Request ) -> aiohttp .web .Response :
203
165
"""Answer a service health check."""
204
166
# Case degraded
205
167
206
168
# Case nominal
207
- return aiohttp .web .json_response ({
208
- "status" : "Ok" ,
209
- })
169
+ return aiohttp .web .json_response (
170
+ {
171
+ "status" : "Ok" ,
172
+ }
173
+ )
0 commit comments