Automatically generated Python client for Gitea. DO NOT UPDATE MANUALLY!!!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

741 lines
29 KiB

# coding: utf-8
"""
Gitea API.
This documentation describes the Gitea API. # noqa: E501
OpenAPI spec version: 1.1.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import re # noqa: F401
# python 2 and python 3 compatibility library
import six
from swagger_client.api_client import ApiClient
class AdminApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def admin_create_org(self, username, organization, **kwargs): # noqa: E501
"""Create an organization # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_org(username, organization, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user that will own the created organization (required)
:param CreateOrgOption organization: (required)
:return: Organization
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_create_org_with_http_info(username, organization, **kwargs) # noqa: E501
else:
(data) = self.admin_create_org_with_http_info(username, organization, **kwargs) # noqa: E501
return data
def admin_create_org_with_http_info(self, username, organization, **kwargs): # noqa: E501
"""Create an organization # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_org_with_http_info(username, organization, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user that will own the created organization (required)
:param CreateOrgOption organization: (required)
:return: Organization
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username', 'organization'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_create_org" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_create_org`") # noqa: E501
# verify the required parameter 'organization' is set
if ('organization' not in params or
params['organization'] is None):
raise ValueError("Missing the required parameter `organization` when calling `admin_create_org`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'organization' in params:
body_params = params['organization']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}/orgs', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Organization', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_create_public_key(self, username, **kwargs): # noqa: E501
"""Add a public key on behalf of a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_public_key(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user (required)
:param CreateKeyOption key:
:return: PublicKey
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_create_public_key_with_http_info(username, **kwargs) # noqa: E501
else:
(data) = self.admin_create_public_key_with_http_info(username, **kwargs) # noqa: E501
return data
def admin_create_public_key_with_http_info(self, username, **kwargs): # noqa: E501
"""Add a public key on behalf of a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_public_key_with_http_info(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user (required)
:param CreateKeyOption key:
:return: PublicKey
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username', 'key'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_create_public_key" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_create_public_key`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'key' in params:
body_params = params['key']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}/keys', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='PublicKey', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_create_repo(self, username, repository, **kwargs): # noqa: E501
"""Create a repository on behalf a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_repo(username, repository, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user. This user will own the created repository (required)
:param CreateRepoOption repository: (required)
:return: Repository
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_create_repo_with_http_info(username, repository, **kwargs) # noqa: E501
else:
(data) = self.admin_create_repo_with_http_info(username, repository, **kwargs) # noqa: E501
return data
def admin_create_repo_with_http_info(self, username, repository, **kwargs): # noqa: E501
"""Create a repository on behalf a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_repo_with_http_info(username, repository, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of the user. This user will own the created repository (required)
:param CreateRepoOption repository: (required)
:return: Repository
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username', 'repository'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_create_repo" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_create_repo`") # noqa: E501
# verify the required parameter 'repository' is set
if ('repository' not in params or
params['repository'] is None):
raise ValueError("Missing the required parameter `repository` when calling `admin_create_repo`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'repository' in params:
body_params = params['repository']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}/repos', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Repository', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_create_user(self, **kwargs): # noqa: E501
"""Create a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_user(async_req=True)
>>> result = thread.get()
:param async_req bool
:param CreateUserOption body:
:return: User
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_create_user_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.admin_create_user_with_http_info(**kwargs) # noqa: E501
return data
def admin_create_user_with_http_info(self, **kwargs): # noqa: E501
"""Create a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_create_user_with_http_info(async_req=True)
>>> result = thread.get()
:param async_req bool
:param CreateUserOption body:
:return: User
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['body'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_create_user" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='User', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_delete_user(self, username, **kwargs): # noqa: E501
"""Delete a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_delete_user(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user to delete (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_delete_user_with_http_info(username, **kwargs) # noqa: E501
else:
(data) = self.admin_delete_user_with_http_info(username, **kwargs) # noqa: E501
return data
def admin_delete_user_with_http_info(self, username, **kwargs): # noqa: E501
"""Delete a user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_delete_user_with_http_info(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user to delete (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_delete_user" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_delete_user`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json', 'text/plain']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}', 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_delete_user_public_key(self, username, id, **kwargs): # noqa: E501
"""Delete a user's public key # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_delete_user_public_key(username, id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user (required)
:param int id: id of the key to delete (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_delete_user_public_key_with_http_info(username, id, **kwargs) # noqa: E501
else:
(data) = self.admin_delete_user_public_key_with_http_info(username, id, **kwargs) # noqa: E501
return data
def admin_delete_user_public_key_with_http_info(self, username, id, **kwargs): # noqa: E501
"""Delete a user's public key # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_delete_user_public_key_with_http_info(username, id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user (required)
:param int id: id of the key to delete (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username', 'id'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_delete_user_public_key" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_delete_user_public_key`") # noqa: E501
# verify the required parameter 'id' is set
if ('id' not in params or
params['id'] is None):
raise ValueError("Missing the required parameter `id` when calling `admin_delete_user_public_key`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
if 'id' in params:
path_params['id'] = params['id'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json', 'text/plain']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}/keys/{id}', 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def admin_edit_user(self, username, **kwargs): # noqa: E501
"""Edit an existing user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_edit_user(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user to edit (required)
:param EditUserOption body:
:return: User
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.admin_edit_user_with_http_info(username, **kwargs) # noqa: E501
else:
(data) = self.admin_edit_user_with_http_info(username, **kwargs) # noqa: E501
return data
def admin_edit_user_with_http_info(self, username, **kwargs): # noqa: E501
"""Edit an existing user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.admin_edit_user_with_http_info(username, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str username: username of user to edit (required)
:param EditUserOption body:
:return: User
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['username', 'body'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method admin_edit_user" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'username' is set
if ('username' not in params or
params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `admin_edit_user`") # noqa: E501
collection_formats = {}
path_params = {}
if 'username' in params:
path_params['username'] = params['username'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['AccessToken', 'AuthorizationHeaderToken', 'BasicAuth', 'SudoHeader', 'SudoParam', 'Token'] # noqa: E501
return self.api_client.call_api(
'/admin/users/{username}', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='User', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)