-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_python_client.sh
More file actions
executable file
·49 lines (43 loc) · 1.41 KB
/
install_python_client.sh
File metadata and controls
executable file
·49 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Settings
dir_name="temp_dir"
default_api_url="https://gitlab.indiscale.com/fdo/fdo-manager-service/-/raw/main/api/src/main/resources/api.yaml"
# Check openapi-python-client and install if necessary
if [ -z "$(which openapi-python-client)" ]; then
echo 'openapi-python-client not found, installing'
pip install openapi-python-client
fi
# Create temporary folder
if [ -d "$dir_name" ]
then
echo 'Temporary folder already exists, aborting.'
exit 0
else
echo 'creating temporary folder'
mkdir $dir_name
fi
# Generate client code
# Uses local path if specified, otherwise specified url. Fallback is api.yaml in the gitlab project main branch.
if [ -n "$API_CLIENT_PATH" ]; then
echo 'generating python client code from path specified by environment variable'
openapi-python-client generate \
--path "$API_CLIENT_PATH" \
--output-path "$dir_name/client_code"
elif [ -n "$API_CLIENT_URL" ]; then
echo 'generating python client code from url specified by environment variable'
openapi-python-client generate \
--url "$API_CLIENT_URL" \
--output-path "$dir_name/client_code"
else
echo 'generating python client code from default url'
openapi-python-client generate \
--url $default_api_url \
--output-path "$dir_name/client_code"
fi
# Install client as library
echo 'installing python client'
pip install "$dir_name/client_code/"
# Cleanup
echo 'starting cleanup'
rm -r $dir_name
echo 'Finished.'