##// END OF EJS Templates
deps: bumped aiohttp==3.11.4 for security fix
deps: bumped aiohttp==3.11.4 for security fix

File last commit:

r5608:6d33e504 default
r5637:170d54a7 default
Show More
api_utils.py
47 lines | 1.9 KiB | text/x-python | PythonLexer
core: updated copyright to 2024
r5608 # Copyright (C) 2010-2024 RhodeCode GmbH
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import urllib.parse
from rhodecode.lib.vcs import CurlSession
from rhodecode.lib.ext_json import json
refactor(ssh-wrapper): changed SSHVcsServer to SshVcsServer, updated call_service_api method.
r5326 from rhodecode.lib.vcs.exceptions import ImproperlyConfiguredError
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325
refactor(ssh-wrapper): changed SSHVcsServer to SshVcsServer, updated call_service_api method.
r5326 def call_service_api(settings, payload):
try:
api_host = settings['app.service_api.host']
api_token = settings['app.service_api.token']
api_url = settings['rhodecode.api.url']
except KeyError as exc:
raise ImproperlyConfiguredError(
f"{str(exc)} is missing. "
"Please ensure that app.service_api.host, app.service_api.token and rhodecode.api.url are "
"defined inside of .ini configuration file."
)
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325 payload.update({
'id': 'service',
refactor(ssh-wrapper): changed SSHVcsServer to SshVcsServer, updated call_service_api method.
r5326 'auth_token': api_token
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325 })
refactor(ssh-wrapper): changed SSHVcsServer to SshVcsServer, updated call_service_api method.
r5326 service_api_url = urllib.parse.urljoin(api_host, api_url)
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325 response = CurlSession().post(service_api_url, json.dumps(payload))
if response.status_code != 200:
raise Exception(f"Service API at {service_api_url} responded with error: {response.status_code}")
return json.loads(response.content)['result']