Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
a5232a7f
"web/app/vscode:/vscode.git/clone" did not exist on "dc642aa07d98aa805a1921648cb1b3f928f45224"
Unverified
Commit
a5232a7f
authored
Dec 21, 2024
by
Antoine Kaufmann
Browse files
symphony/client: add UMA support to base client
parent
26efc226
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
45 deletions
+54
-45
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+54
-45
No files found.
symphony/client/simbricks/client/client.py
View file @
a5232a7f
...
...
@@ -64,66 +64,75 @@ class BaseClient:
await
session
.
close
()
@
contextlib
.
asynccontextmanager
async
def
post
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
,
async
def
request
(
self
,
meth
:
str
,
url
:
str
,
data
:
typing
.
Any
=
None
,
retry
:
bool
=
True
,
**
kwargs
:
typing
.
Any
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
session
()
as
session
:
async
with
session
.
po
st
(
url
=
self
.
build_url
(
url
),
data
=
data
,
**
kwargs
async
with
session
.
reque
st
(
method
=
meth
,
url
=
self
.
build_url
(
url
),
data
=
data
,
**
kwargs
)
as
resp
:
# TODO: handel connection error
# print(await resp.text())
if
resp
.
status
==
401
and
'WWW-Authenticate'
in
resp
.
headers
\
and
retry
:
wwa
=
resp
.
headers
[
'WWW-Authenticate'
]
parts
=
wwa
.
split
(
','
)
ticket
=
None
for
p
in
parts
:
p
=
p
.
strip
()
if
p
.
startswith
(
"ticket=
\"
"
):
ticket
=
p
[
8
:
-
1
]
if
ticket
:
await
self
.
_token_provider
.
resource_token
(
ticket
)
async
with
self
.
request
(
meth
,
url
,
data
,
False
,
**
kwargs
)
as
resp
:
yield
resp
else
:
resp
.
raise_for_status
()
# TODO: handel gracefully
yield
resp
@
contextlib
.
asynccontextmanager
async
def
put
(
self
,
url
:
str
,
overwrite_headers
:
dict
[
str
,
typing
.
Any
]
|
None
=
None
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
,
async
def
get
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
,
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
session
(
overwrite_headers
=
overwrite_headers
)
as
session
:
async
with
session
.
put
(
url
=
self
.
build_url
(
url
),
data
=
data
,
**
kwargs
)
as
resp
:
# TODO: handel connection error
# print(await resp.text())
resp
.
raise_for_status
()
# TODO: handel gracefully
async
with
self
.
request
(
meth
=
aiohttp
.
hdrs
.
METH_GET
,
url
=
url
,
data
=
data
,
**
kwargs
)
as
resp
:
yield
resp
@
contextlib
.
asynccontextmanager
async
def
p
atch
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
async
def
p
ost
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
,
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
session
()
as
session
:
async
with
session
.
patch
(
url
=
self
.
build_url
(
url
),
data
=
data
,
**
kwargs
)
as
resp
:
# TODO: handel connection error
# print(await resp.text())
resp
.
raise_for_status
()
# TODO: handel gracefully
async
with
self
.
request
(
meth
=
aiohttp
.
hdrs
.
METH_POST
,
url
=
url
,
data
=
data
,
**
kwargs
)
as
resp
:
yield
resp
@
contextlib
.
asynccontextmanager
async
def
get
(
async
def
put
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
,
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
request
(
meth
=
aiohttp
.
hdrs
.
METH_PUT
,
url
=
url
,
data
=
data
,
**
kwargs
)
as
resp
:
yield
resp
@
contextlib
.
asynccontextmanager
async
def
patch
(
self
,
url
:
str
,
data
:
typing
.
Any
=
None
,
**
kwargs
:
typing
.
Any
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
session
()
as
session
:
async
with
session
.
get
(
url
=
self
.
build_url
(
url
),
data
=
data
,
**
kwargs
)
as
resp
:
# TODO: handel connection error
# print(await resp.text())
resp
.
raise_for_status
()
# TODO: handel gracefully
async
with
self
.
request
(
meth
=
aiohttp
.
hdrs
.
METH_PATCH
,
url
=
url
,
data
=
data
,
**
kwargs
)
as
resp
:
yield
resp
@
contextlib
.
asynccontextmanager
async
def
delete
(
self
,
url
:
str
,
**
kwargs
:
typing
.
Any
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
async
with
self
.
session
()
as
session
:
async
with
session
.
delete
(
url
=
self
.
build_url
(
url
),
**
kwargs
)
as
resp
:
# TODO: handel connection error
# print(await resp.text())
resp
.
raise_for_status
()
# TODO: handel gracefully
async
with
self
.
request
(
meth
=
aiohttp
.
hdrs
.
METH_DELETE
,
url
=
url
,
**
kwargs
)
as
resp
:
yield
resp
async
def
info
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment