### List System Webhooks using AdminApi Source: https://github.com/client-api/forgejo-python/blob/main/docs/AdminApi.md This example demonstrates how to list all system webhooks using the AdminApi. It includes setup for various authentication methods supported by the API, such as TOTPHeader, AuthorizationHeaderToken, SudoHeader, BasicAuth, AccessToken, SudoParam, and Token. The code configures the API client with the chosen authentication method before making the call. Dependencies include `clientapi_forgejo`, `os`, and `pprint`. ```python import clientapi_forgejo import os from clientapi_forgejo.models.hook import Hook from clientapi_forgejo.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' # Configure API key authorization: SudoParam configuration.api_key['SudoParam'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoParam'] = 'Bearer' # Configure API key authorization: Token configuration.api_key['Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Token'] = 'Bearer' # Example of calling the API (assuming configuration is set up) # with clientapi_forgejo.ApiClient(configuration) as api_client: # api_instance = clientapi_forgejo.AdminApi(api_client) # page = 1 # int | page number of results to return (optional) # limit = 50 # int | maximum number of results to return (optional) # # try: # list_of_hooks = api_instance.admin_list_hooks(page=page, limit=limit) # pprint(list_of_hooks) # except ApiException as e: # print("Exception when calling AdminApi->admin_list_hooks: %s\n" % e) ``` -------------------------------- ### Forgejo Python Client: Create Organization Example Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This Python code snippet illustrates how to create a new organization using the Forgejo client library. It shows the necessary imports, configuration of the API host, and the setup for various authentication methods. The example utilizes the `CreateOrgOption` model to define the organization's details before making the `org_create` API call. ```python import clientapi_forgejo from clientapi_forgejo.models.create_org_option import CreateOrgOption from clientapi_forgejo.models.organization import Organization from clientapi_forgejo.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to /api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' # Configure API key authorization: SudoParam configuration.api_key['SudoParam'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoParam'] = 'Bearer' # Configure API key authorization: Token configuration.api_key['Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Token'] = 'Bearer' # Enter a context with an instance of the API client with clientapi_forgejo.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = clientapi_forgejo.OrganizationApi(api_client) # example passing only required values which depends on the user configuration organization = CreateOrgOption(name='example_org') try: # Create an organization api_response = api_instance.org_create(organization) pprint(api_response) except ApiException as e: print("Exception when calling OrganizationApi->org_create: %s\n" % e) ``` -------------------------------- ### Install Forgejo Python SDK Source: https://context7.com/client-api/forgejo-python/llms.txt Install the Forgejo Python client library directly from the GitHub repository using pip. ```bash pip install git+https://github.com/client-api/forgejo-python.git ``` -------------------------------- ### Install Forgejo Python Client Source: https://github.com/client-api/forgejo-python/blob/main/README.md Methods for installing the Forgejo Python package using pip or setuptools. ```bash pip install git+https://github.com/client-api/forgejo-python.git ``` ```bash python setup.py install --user ``` -------------------------------- ### Delete Team using Forgejo API Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md Provides an example of how to delete a team within a Forgejo organization using the Python client. This operation requires the ID of the team to be deleted. The example shows the setup for various authentication methods. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # ... (authentication configuration as above) ... # Example for deleting a team (assuming 'id' is the team ID) # api_instance.org_delete_team(id=team_id) ``` -------------------------------- ### Configure API Key Authorization and Add Public Key Source: https://github.com/client-api/forgejo-python/blob/main/docs/AdminApi.md This example shows how to set up multiple authentication methods including API keys (TOTPHeader, AuthorizationHeaderToken, SudoHeader, AccessToken, SudoParam, Token) and Basic Authentication. It then prepares to add a public key on behalf of a user using the AdminApi. ```python import clientapi_forgejo import os from pprint import pprint # Defining the host is optional and defaults to /api/v1 configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' # Configure API key authorization: SudoParam configuration.api_key['SudoParam'] = os.environ["API_KEY"] # Configure API key authorization: Token configuration.api_key['Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Token'] = 'Bearer' # Example usage for admin_create_public_key would follow here, requiring a CreateKeyOption object. ``` -------------------------------- ### Call Forgejo Admin Delete User API (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/AdminApi.md Provides an example of how to call the 'admin_delete_user' function from the Forgejo AdminApi. It requires the username and optionally accepts a 'purge' parameter. The example shows the initial setup for the client configuration, including various authentication methods. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Example for API Key Authentication (TOTPHeader) configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Example for Basic Authentication # configuration = clientapi_forgejo.Configuration( # username = os.environ["USERNAME"], # password = os.environ["PASSWORD"] # ) # To use the API client: # api_client = clientapi_forgejo.ApiClient(configuration) # api_instance = clientapi_forgejo.AdminApi(api_client) # username = 'test_user' # try: # api_instance.admin_delete_user(username) # except ApiException as e: # pprint(e) ``` -------------------------------- ### Initialize Forgejo Python Client with Host and Authentication Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This example demonstrates initializing the Forgejo Python client, setting the host URL, and configuring API key authorization for TOTPHeader. It includes necessary imports and shows how to set the API key from an environment variable. ```python import os import clientapi_forgejo from clientapi_forgejo.models.create_repo_option import CreateRepoOption from clientapi_forgejo.models.repository import Repository from clientapi_forgejo.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' ``` -------------------------------- ### Get Version (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/MiscellaneousApi.md Returns the version information of the Gitea application. This endpoint is public and provides details about the installed Gitea version. No authentication is needed. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Example usage: # with clientapi_forgejo.ApiClient(configuration) as api_client: # miscellaneous_api = clientapi_forgejo.MiscellaneousApi(api_client) # try: # response = miscellaneous_api.get_version() # pprint(response) # except ApiException as e: # print(f"Exception when calling MiscellaneousApi->get_version: {e}") ``` -------------------------------- ### Delete a repository milestone using Forgejo API Source: https://github.com/client-api/forgejo-python/blob/main/docs/IssueApi.md Shows the process of deleting a milestone by its ID or name. Includes comprehensive authentication setup examples for various security policies. ```python configuration = clientapi_forgejo.Configuration(host = "/api/v1") with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.IssueApi(api_client) owner = 'owner_example' repo = 'repo_example' id = 'id_example' try: api_instance.issue_delete_milestone(owner, repo, id) except Exception as e: print("Exception when calling IssueApi->issue_delete_milestone: %s\n" % e) ``` -------------------------------- ### Create a repository using Forgejo Python Client Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md Demonstrates how to initialize the Forgejo API client with various authentication methods and call the create_current_user_repo endpoint. It includes the setup of the configuration object and handling of the CreateRepoOption model. ```python import clientapi_forgejo from clientapi_forgejo.models.create_repo_option import CreateRepoOption from clientapi_forgejo.models.repository import Repository from clientapi_forgejo.rest import ApiException from pprint import pprint configuration = clientapi_forgejo.Configuration(host = "/api/v1") configuration.api_key['AccessToken'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.UserApi(api_client) body = clientapi_forgejo.CreateRepoOption() try: api_response = api_instance.create_current_user_repo(body=body) pprint(api_response) except Exception as e: print("Exception when calling UserApi->create_current_user_repo: %s\n" % e) ``` -------------------------------- ### Instantiate and Convert EditHookOption Source: https://github.com/client-api/forgejo-python/blob/main/docs/EditHookOption.md Demonstrates how to initialize an EditHookOption instance from a JSON string or dictionary, and how to serialize the object back to JSON or a Python dictionary. ```python from clientapi_forgejo.models.edit_hook_option import EditHookOption # TODO update the JSON string below json = "{}" # create an instance of EditHookOption from a JSON string edit_hook_option_instance = EditHookOption.from_json(json) # print the JSON string representation of the object print(EditHookOption.to_json()) # convert the object into a dict edit_hook_option_dict = edit_hook_option_instance.to_dict() # create an instance of EditHookOption from a dict edit_hook_option_from_dict = EditHookOption.from_dict(edit_hook_option_dict) ``` -------------------------------- ### Retrieve Label Template Information Source: https://github.com/client-api/forgejo-python/blob/main/docs/MiscellaneousApi.md Shows how to retrieve all labels associated with a specific template. This example includes the setup of various authentication methods such as API keys and Basic Auth. ```python configuration = clientapi_forgejo.Configuration(host = "/api/v1") configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.MiscellaneousApi(api_client) name = 'name_example' try: api_response = api_instance.get_label_template_info(name) print(api_response) except Exception as e: print("Exception: %s" % e) ``` -------------------------------- ### Create Organization Repository with Python Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md Demonstrates how to initialize the Forgejo API client and configure authentication to create a new repository within an organization. It requires setting up a configuration object with the host URL and appropriate API credentials. ```python import clientapi_forgejo from clientapi_forgejo.models.create_repo_option import CreateRepoOption from clientapi_forgejo.models.repository import Repository from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] ``` -------------------------------- ### Issue API - Get Comments Source: https://github.com/client-api/forgejo-python/blob/main/docs/IssueApi.md This snippet demonstrates how to list all comments on a specific issue using the Forgejo Python client. It includes setup for different authentication methods and error handling. ```APIDOC ## POST /api/v1/repos/{owner}/{repo}/issues/{index}/comments ### Description Lists all comments on an issue. ### Method GET ### Endpoint /api/v1/repos/{owner}/{repo}/issues/{index}/comments ### Parameters #### Path Parameters - **owner** (str) - Required - owner of the repo - **repo** (str) - Required - name of the repo - **index** (int) - Required - index of the issue #### Query Parameters - **since** (datetime) - Optional - if provided, only comments updated since the specified time are returned. - **before** (datetime) - Optional - if provided, only comments updated before the provided time are returned. ### Request Example ```python import clientapi_forgejo from clientapi_forgejo.models.comment import Comment from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ.get("API_KEY") # Configure HTTP basic authorization: BasicAuth # configuration = clientapi_forgejo.Configuration( # username = os.environ["USERNAME"], # password = os.environ["PASSWORD"] # ) with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.IssueApi(api_client) owner = 'owner_example' repo = 'repo_example' index = 56 since = '2013-10-20T19:20:30+01:00' before = '2013-10-20T19:20:30+01:00' try: api_response = api_instance.issue_get_comments(owner, repo, index, since=since, before=before) pprint(api_response) except ApiException as e: print(f"Exception when calling IssueApi->issue_get_comments: {e}") ``` ### Response #### Success Response (200) - **List[Comment]** - A list of comments. #### Response Example ```json [ { "id": 1, "created_at": "2023-01-01T10:00:00Z", "updated_at": "2023-01-01T10:00:00Z", "body": "This is a comment.", "user": { "id": 1, "login": "user1", "avatar_url": "http://example.com/avatar.png" } } ] ``` ### Authorization Supports TOTPHeader, AuthorizationHeaderToken, SudoHeader, BasicAuth, AccessToken, SudoParam, Token. ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | |-------------|-------------| | **200** | CommentList | | **404** | APINotFound is a not found error response | ``` -------------------------------- ### Configure API Key Authentication (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/IssueApi.md Demonstrates how to configure API key authorization for different headers (e.g., SudoHeader, AccessToken, Token) using environment variables. It also shows how to set up basic HTTP authentication. ```python import clientapi_forgejo import os # Configure API key authorization: SudoHeader configuration = clientapi_forgejo.Configuration() configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' # Configure API key authorization: SudoParam configuration.api_key['SudoParam'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoParam'] = 'Bearer' # Configure API key authorization: Token configuration.api_key['Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Token'] = 'Bearer' ``` -------------------------------- ### Get User Quota Information (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md This example shows how to retrieve quota information for the authenticated user using the Forgejo Python client. It requires setting up the API client with appropriate authentication. ```python import clientapi_forgejo from clientapi_forgejo.models.quota_info import QuotaInfo from clientapi_forgejo.rest import ApiException from pprint import pprint import os # Assuming configuration is already set up for authentication configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) configuration.api_key['AccessToken'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = clientapi_forgejo.UserApi(api_client) try: # Get quota information for the authenticated user api_response = api_instance.user_get_quota() print("The response of UserApi->user_get_quota:\n") pprint(api_response) except ApiException as e: print("Exception when calling UserApi->user_get_quota: %s\n" % e) ``` -------------------------------- ### Configure Forgejo API Authentication and Create OAuth2 Application (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md This example shows how to set up authentication for the Forgejo Python client using various methods like API Key and Basic Auth, and then proceeds to create a new OAuth2 application. It highlights the use of environment variables for credentials. ```python import os import clientapi_forgejo from clientapi_forgejo.models.create_o_auth2_application_options import CreateOAuth2ApplicationOptions from clientapi_forgejo.models.o_auth2_application import OAuth2Application from clientapi_forgejo.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' ``` -------------------------------- ### Organization API - List Current User Organizations Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This snippet demonstrates how to list organizations that the current user belongs to using the Forgejo Python client. It covers authentication setup and an example API call. ```APIDOC ## GET /api/v1/user/orgs ### Description Lists the current user's organizations. ### Method GET ### Endpoint /api/v1/user/orgs ### Parameters #### Query Parameters - **page** (int) - Optional - The page number of results to return (1-based). - **limit** (int) - Optional - The page size of results. ### Request Example ```python import clientapi_forgejo from clientapi_forgejo.models.organization import Organization from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.OrganizationApi(api_client) page = 1 limit = 10 try: api_response = api_instance.org_list_current_user_orgs(page=page, limit=limit) pprint(api_response) except ApiException as e: print(f"Exception when calling OrganizationApi->org_list_current_user_orgs: {e}") ``` ### Response #### Success Response (200) - **OrganizationList** (List[Organization]) - A list of organizations the user belongs to. #### Response Example ```json [ { "id": 1, "name": "example-org", "username": "example-org", "full_name": "Example Organization", "description": "This is an example organization.", "avatar_url": "https://example.com/avatars/example-org" } ] ``` ``` -------------------------------- ### Instantiate and Serialize DeployKey Model Source: https://github.com/client-api/forgejo-python/blob/main/docs/DeployKey.md Demonstrates how to create a DeployKey instance from a JSON string or dictionary, and how to serialize the instance back into those formats. This is essential for handling API responses and preparing data for requests. ```python from clientapi_forgejo.models.deploy_key import DeployKey # TODO update the JSON string below json = "{}" # create an instance of DeployKey from a JSON string deploy_key_instance = DeployKey.from_json(json) # print the JSON string representation of the object print(DeployKey.to_json()) # convert the object into a dict deploy_key_dict = deploy_key_instance.to_dict() # create an instance of DeployKey from a dict deploy_key_from_dict = DeployKey.from_dict(deploy_key_dict) ``` -------------------------------- ### Organization API - List Blocked Users Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This snippet demonstrates how to list the blocked users for a specific organization using the Forgejo Python client. It includes setup for different authentication methods and an example API call. ```APIDOC ## GET /api/v1/orgs/{org}/blocks ### Description Lists the organization's blocked users. ### Method GET ### Endpoint /api/v1/orgs/{org}/blocks ### Parameters #### Path Parameters - **org** (str) - Required - The name of the organization. #### Query Parameters - **page** (int) - Optional - The page number of results to return (1-based). - **limit** (int) - Optional - The page size of results. ### Request Example ```python import clientapi_forgejo from clientapi_forgejo.models.blocked_user import BlockedUser from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.OrganizationApi(api_client) org = 'org_example' page = 1 limit = 10 try: api_response = api_instance.org_list_blocked_users(org, page=page, limit=limit) pprint(api_response) except ApiException as e: print(f"Exception when calling OrganizationApi->org_list_blocked_users: {e}") ``` ### Response #### Success Response (200) - **BlockedUserList** (List[BlockedUser]) - A list of blocked users. #### Response Example ```json [ { "blocked_at": "2023-10-27T10:00:00Z", "block_expire_at": null, "id": 1, "login": "user1", "full_name": "User One", "avatar_url": "https://example.com/avatars/user1" } ] ``` ``` -------------------------------- ### Instantiate and Convert ServerVersion Model Source: https://github.com/client-api/forgejo-python/blob/main/docs/ServerVersion.md Demonstrates how to create a ServerVersion instance from a JSON string or dictionary, and how to export the instance back to those formats. This is useful for interacting with API responses. ```python from clientapi_forgejo.models.server_version import ServerVersion # TODO update the JSON string below json = "{}" # create an instance of ServerVersion from a JSON string server_version_instance = ServerVersion.from_json(json) # print the JSON string representation of the object print(ServerVersion.to_json()) # convert the object into a dict server_version_dict = server_version_instance.to_dict() # create an instance of ServerVersion from a dict server_version_from_dict = ServerVersion.from_dict(server_version_dict) ``` -------------------------------- ### Configure Authentication and Edit Organization - Python Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This example shows how to set up various authentication schemes including TOTPHeader, AuthorizationHeaderToken, SudoHeader, BasicAuth, AccessToken, SudoParam, and Token. It prepares the client to edit an organization, though the actual edit call is not shown in this snippet. ```python import clientapi_forgejo from clientapi_forgejo.models.edit_org_option import EditOrgOption from clientapi_forgejo.models.organization import Organization from clientapi_forgejo.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to /api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # Configure API key authorization: AccessToken configuration.api_key['AccessToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AccessToken'] = 'Bearer' # Configure API key authorization: SudoParam configuration.api_key['SudoParam'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['SudoParam'] = 'Bearer' # Configure API key authorization: Token configuration.api_key['Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['Token'] = 'Bearer' ``` -------------------------------- ### Issue API - Get Issue Reactions Source: https://github.com/client-api/forgejo-python/blob/main/docs/IssueApi.md This snippet demonstrates how to retrieve a list of reactions for a specific issue in a repository using the Forgejo Python client. It includes setup for different authentication methods and error handling. ```APIDOC ## GET /repos/{owner}/{repo}/issues/{index}/reactions ### Description Retrieves a list of reactions for a specific issue. ### Method GET ### Endpoint /repos/{owner}/{repo}/issues/{index}/reactions ### Parameters #### Path Parameters - **owner** (str) - Required - The owner of the repository. - **repo** (str) - Required - The name of the repository. - **index** (int) - Required - The index of the issue. #### Query Parameters - **page** (int) - Optional - The page number of results to return (1-based). - **limit** (int) - Optional - The page size of results. ### Request Example ```json { "example": "Not applicable for this GET request" } ``` ### Response #### Success Response (200) - **List[Reaction]** - A list of reactions associated with the issue. #### Response Example ```json { "example": "[\n {\n \"id\": 1,\n "user": {\n "avatar_url": \"https://example.com/avatar.png\",\n "id": 1,\n "login": \"user1\"\n },\n "content": \"+1\",\n "created_at": \"2023-10-27T10:00:00Z\"\n }\n]" } ``` ### Authorization - TOTPHeader - AuthorizationHeaderToken - SudoHeader - BasicAuth - AccessToken - SudoParam - Token ``` -------------------------------- ### Configure Forgejo Client and Authenticate Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md Demonstrates how to configure the Forgejo client's host and set up different authentication methods including TOTPHeader, AuthorizationHeaderToken, SudoHeader, BasicAuth, AccessToken, SudoParam, and Token using environment variables. ```python import clientapi_forgejo import os # Configuration with default host configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # API Key Authentication examples configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Optional prefix configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Basic HTTP Authentication configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) # More API Key examples configuration.api_key['AccessToken'] = os.environ["API_KEY"] # configuration.api_key_prefix['AccessToken'] = 'Bearer' configuration.api_key['SudoParam'] = os.environ["API_KEY"] # configuration.api_key_prefix['SudoParam'] = 'Bearer' configuration.api_key['Token'] = os.environ["API_KEY"] # configuration.api_key_prefix['Token'] = 'Bearer' ``` -------------------------------- ### Configure Forgejo API Authentication and Delete Public Key Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md Demonstrates how to initialize the Forgejo configuration with different authentication providers and execute a user-specific API call. It includes examples for TOTP, Token, and Basic Authentication setups. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException import os configuration = clientapi_forgejo.Configuration(host = "/api/v1") # Configure various auth methods configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # Configure HTTP basic authorization configuration = clientapi_forgejo.Configuration( username = os.environ["USERNAME"], password = os.environ["PASSWORD"] ) with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.UserApi(api_client) key_id = 56 try: api_instance.user_current_delete_key(key_id) except Exception as e: print("Exception when calling UserApi->user_current_delete_key: %s" % e) ``` -------------------------------- ### Call Organization API to Get Quota (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md An example of how to instantiate the Forgejo API client with a given configuration and call the `org_get_quota` method to retrieve an organization's quota information. It includes error handling for API exceptions. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) configuration.api_key['AccessToken'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.OrganizationApi(api_client) org = 'org_example' try: api_response = api_instance.org_get_quota(org) print("The response of OrganizationApi->org_get_quota:\n") pprint(api_response) except Exception as e: print("Exception when calling OrganizationApi->org_get_quota: %s\n" % e) ``` -------------------------------- ### Instantiate and Convert CreateKeyOption Model Source: https://github.com/client-api/forgejo-python/blob/main/docs/CreateKeyOption.md Demonstrates how to initialize a CreateKeyOption instance from a JSON string or dictionary, and how to serialize the object back to JSON or a dictionary format. This is useful for handling API request payloads. ```python from clientapi_forgejo.models.create_key_option import CreateKeyOption # TODO update the JSON string below json = "{}" # create an instance of CreateKeyOption from a JSON string create_key_option_instance = CreateKeyOption.from_json(json) # print the JSON string representation of the object print(CreateKeyOption.to_json()) # convert the object into a dict create_key_option_dict = create_key_option_instance.to_dict() # create an instance of CreateKeyOption from a dict create_key_option_from_dict = CreateKeyOption.from_dict(create_key_option_dict) ``` -------------------------------- ### User API - List Quota Artifacts Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md This snippet demonstrates how to list artifacts affecting the authenticated user's quota using the Forgejo Python client. It includes setup for different authentication methods and an example API call. ```APIDOC ## GET /api/v1/users/artifacts/list_quota ### Description Lists the artifacts affecting the authenticated user's quota. ### Method GET ### Endpoint /api/v1/users/artifacts/list_quota ### Parameters #### Query Parameters - **page** (int) - Optional - Page number of results to return (1-based) - **limit** (int) - Optional - Page size of results ### Request Example ```python import clientapi_forgejo from clientapi_forgejo.models.quota_used_artifact import QuotaUsedArtifact from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ.get("API_KEY") # Configure HTTP basic authorization: BasicAuth configuration = clientapi_forgejo.Configuration( username = os.environ.get("USERNAME"), password = os.environ.get("PASSWORD") ) with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.UserApi(api_client) page = 1 # Example page number limit = 10 # Example limit try: api_response = api_instance.user_list_quota_artifacts(page=page, limit=limit) pprint(api_response) except ApiException as e: print(f"Exception when calling UserApi->user_list_quota_artifacts: {e}") ``` ### Response #### Success Response (200) - **list** (List[QuotaUsedArtifact]) - A list of artifacts affecting the user's quota. #### Response Example ```json { "artifacts": [ { "id": 1, "name": "example-artifact", "size": 1024, "created_at": "2023-10-27T10:00:00Z" } ], "total": 1 } ``` ### Authorization Supports TOTPHeader, AuthorizationHeaderToken, SudoHeader, BasicAuth, AccessToken, SudoParam, and Token authentication methods. ``` -------------------------------- ### Python NodeInfoSoftware Instantiation and Conversion Source: https://github.com/client-api/forgejo-python/blob/main/docs/NodeInfoSoftware.md Demonstrates how to create a NodeInfoSoftware instance from a JSON string, convert it to a dictionary, and create an instance from a dictionary. It utilizes the from_json, to_json, and from_dict methods. ```python from clientapi_forgejo.models.node_info_software import NodeInfoSoftware # TODO update the JSON string below json = "{}" # create an instance of NodeInfoSoftware from a JSON string node_info_software_instance = NodeInfoSoftware.from_json(json) # print the JSON string representation of the object print(NodeInfoSoftware.to_json()) # convert the object into a dict node_info_software_dict = node_info_software_instance.to_dict() # create an instance of NodeInfoSoftware from a dict node_info_software_from_dict = NodeInfoSoftware.from_dict(node_info_software_dict) ``` -------------------------------- ### Get User Runner Registration Token with Forgejo API Source: https://github.com/client-api/forgejo-python/blob/main/docs/UserApi.md This example shows how to set up the Forgejo API client configuration, including authentication, and then demonstrates the call to user_get_runner_registration_token to obtain a runner registration token for the user. It covers multiple authentication methods. ```python import os import clientapi_forgejo from pprint import pprint configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Configure API key authorization: SudoHeader configuration.api_key['SudoHeader'] = os.environ["API_KEY"] # configuration.api_key_prefix['SudoHeader'] = 'Bearer' # Example usage (actual call would follow configuration): # with clientapi_forgejo.ApiClient(configuration) as api_client: # api_instance = clientapi_forgejo.UserApi(api_client) # try: # api_response = api_instance.user_get_runner_registration_token() # pprint(api_response) # except ApiException as e: # print("Exception when calling UserApi->user_get_runner_registration_token: %s\n" % e) ``` -------------------------------- ### Initialize and Authenticate Forgejo API Client Source: https://github.com/client-api/forgejo-python/blob/main/README.md Demonstrates how to configure the Forgejo API client with various authentication methods and execute a sample API call. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint import os configuration = clientapi_forgejo.Configuration(host = "/api/v1") configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] with clientapi_forgejo.ApiClient(configuration) as api_client: api_instance = clientapi_forgejo.ActivitypubApi(api_client) try: api_response = api_instance.activitypub_instance_actor() pprint(api_response) except ApiException as e: print("Exception: %s" % e) ``` -------------------------------- ### Get Organization Runner Registration Token (Python) Source: https://github.com/client-api/forgejo-python/blob/main/docs/OrganizationApi.md This example demonstrates how to authenticate with the Forgejo API using various methods (API Key or Basic Auth) and then call the `org_get_runner_registration_token` method to obtain a registration token for an organization's actions runner. ```python import clientapi_forgejo from clientapi_forgejo.rest import ApiException from pprint import pprint configuration = clientapi_forgejo.Configuration( host = "/api/v1" ) # Configure API key authorization: TOTPHeader configuration.api_key['TOTPHeader'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['TOTPHeader'] = 'Bearer' # Configure API key authorization: AuthorizationHeaderToken configuration.api_key['AuthorizationHeaderToken'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['AuthorizationHeaderToken'] = 'Bearer' # Example for Basic Auth (if used instead of API Key) # configuration = clientapi_forgejo.Configuration( # username = os.environ["USERNAME"], # password = os.environ["PASSWORD"] # ) # The actual call to org_get_runner_registration_token would follow here, # similar to the org_get_quota example, using the configured client. ```