Skip to content

Commit e9cae34

Browse files
committed
Minor improvements
1 parent d5502d1 commit e9cae34

11 files changed

Lines changed: 157 additions & 7 deletions

File tree

.github/scripts/generate.ps1

-16 Bytes
Binary file not shown.

.github/scripts/generate.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
3+
# Clean up
4+
5+
generated_files_path="./.openapi-generator/FILES"
6+
7+
if [ -f "$generated_files_path" ]; then
8+
while IFS= read -r generated_file; do
9+
10+
generated_file="$(echo "$generated_file" | tr -d '\r\n')"
11+
12+
if [[ "$generated_file" == ".gitignore" || "$generated_file" == ".openapi-generator-ignore" || "$generated_file" == "README.md" || "$generated_file" == ".github" ]]; then
13+
continue
14+
fi
15+
16+
if [ -f "$generated_file" ]; then
17+
rm -f "$generated_file"
18+
fi
19+
done < "$generated_files_path"
20+
fi
21+
22+
# Download generator
23+
24+
if [ ! -f "./.openapi-generator/openapi-generator-cli.jar" ]; then
25+
xml_string=$(curl -s "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml")
26+
27+
if [ -z "$xml_string" ]; then
28+
echo "Unable to fetch XML metadata."
29+
exit 1
30+
fi
31+
32+
latest_version=$(echo "$xml_string" | grep -oPm1 "(?<=<latest>)[^<]+")
33+
latest_version_url="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${latest_version}/openapi-generator-cli-${latest_version}.jar"
34+
35+
curl -o "./.openapi-generator/openapi-generator-cli.jar" "$latest_version_url"
36+
fi
37+
38+
# Check Java
39+
40+
output=$(java -version 2>&1)
41+
if [[ "$output" == *"java version"* || "$output" == *"openjdk version"* ]]; then
42+
echo "Java version: $output"
43+
else
44+
echo "Java is not found."
45+
exit 1
46+
fi
47+
48+
# Check Generator Version
49+
50+
output=$(java -jar ./.openapi-generator/openapi-generator-cli.jar version)
51+
if [[ "$output" == "$latest_version" ]]; then
52+
echo "OpenAPI Generator version: $output"
53+
else
54+
echo "Unable to verify OpenAPI Generator version"
55+
exit 1
56+
fi
57+
58+
# Generate
59+
60+
java -jar ./.openapi-generator/openapi-generator-cli.jar generate \
61+
--input-spec "./.github/specs/openapi.yml" \
62+
--generator-name "python" \
63+
--output ./ \
64+
--enable-post-process-file \
65+
--git-host "github.com" \
66+
--git-repo-id "forgejo-python" \
67+
--git-user-id "client-api" \
68+
--package-name "clientapi_forgejo" \
69+
--additional-properties "packageName=clientapi_forgejo,packageUrl=https://github.com/client-api/forgejo-python,packageVersion=1.1.1,projectName=forgejo-python"
70+
71+
# Check if the command was successful
72+
if [ $? -eq 0 ]; then
73+
echo "Done"
74+
exit 0
75+
else
76+
echo "Failed"
77+
exit 1
78+
fi
79+
80+
81+

.openapi-generator-ignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
2424

25-
.github/
25+
.github/
26+
.gitignore
27+
clientapi_forgejo/forgejo.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This documentation describes the Forgejo API.
44
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
55

66
- API version: 10.0.0-93-60eedb9+gitea-1.22.0
7-
- Package version: 1.1.0
7+
- Package version: 1.1.1
88
- Generator version: 7.11.0
99
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1010

clientapi_forgejo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
""" # noqa: E501
1515

1616

17-
__version__ = "1.1.0"
17+
__version__ = "1.1.1"
1818

1919
# import apis into sdk package
2020
from clientapi_forgejo.api.activitypub_api import ActivitypubApi

clientapi_forgejo/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(
9090
self.default_headers[header_name] = header_value
9191
self.cookie = cookie
9292
# Set default User-Agent.
93-
self.user_agent = 'OpenAPI-Generator/1.1.0/python'
93+
self.user_agent = 'OpenAPI-Generator/1.1.1/python'
9494
self.client_side_validation = configuration.client_side_validation
9595

9696
def __enter__(self):

clientapi_forgejo/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def to_debug_report(self) -> str:
598598
"OS: {env}\n"\
599599
"Python Version: {pyversion}\n"\
600600
"Version of the API: 10.0.0-93-60eedb9+gitea-1.22.0\n"\
601-
"SDK Package Version: 1.1.0".\
601+
"SDK Package Version: 1.1.1".\
602602
format(env=sys.platform, pyversion=sys.version)
603603

604604
def get_host_settings(self) -> List[HostSetting]:

clientapi_forgejo/forgejo.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import clientapi_forgejo
2+
from clientapi_forgejo import ActivitypubApi, AdminApi, IssueApi, MiscellaneousApi, NotificationApi, OrganizationApi, PackageApi, RepositoryApi, SettingsApi, UserApi
3+
4+
class Forgejo:
5+
6+
def __init__(self, host: str, api_key: str):
7+
self.configuration = clientapi_forgejo.Configuration(
8+
host=host,
9+
)
10+
self.configuration.api_key['Token'] = api_key
11+
self.validate()
12+
13+
def validate(self):
14+
if not self.configuration.api_key:
15+
raise Exception("The Forgejo API key is not set.")
16+
17+
def ActivitypubApi(self) -> ActivitypubApi:
18+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
19+
return clientapi_forgejo.ActivitypubApi(api_client)
20+
21+
def AdminApi(self) -> AdminApi:
22+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
23+
return clientapi_forgejo.AdminApi(api_client)
24+
25+
def IssueApi(self) -> IssueApi:
26+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
27+
return clientapi_forgejo.IssueApi(api_client)
28+
29+
def MiscellaneousApi(self) -> MiscellaneousApi:
30+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
31+
return clientapi_forgejo.MiscellaneousApi(api_client)
32+
33+
def NotificationApi(self) -> NotificationApi:
34+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
35+
return clientapi_forgejo.NotificationApi(api_client)
36+
37+
def OrganizationApi(self) -> OrganizationApi:
38+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
39+
return clientapi_forgejo.OrganizationApi(api_client)
40+
41+
def PackageApi(self) -> PackageApi:
42+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
43+
return clientapi_forgejo.PackageApi(api_client)
44+
45+
def RepositoryApi(self) -> RepositoryApi:
46+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
47+
return clientapi_forgejo.RepositoryApi(api_client)
48+
49+
def SettingsApi(self) -> SettingsApi:
50+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
51+
return clientapi_forgejo.SettingsApi(api_client)
52+
53+
def UserApi(self) -> UserApi:
54+
with clientapi_forgejo.ApiClient(self.configuration) as api_client:
55+
return clientapi_forgejo.UserApi(api_client)

examples/repository_search.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pprint import pprint
2+
3+
from clientapi_forgejo.forgejo import Forgejo
4+
from clientapi_forgejo.exceptions import UnauthorizedException
5+
6+
try:
7+
forgejo = Forgejo(host="https://<domain>/api/v1", api_key="<your_api_key>")
8+
repository = forgejo.RepositoryApi()
9+
result = repository.repo_search(q="Search...")
10+
pprint(result)
11+
except UnauthorizedException as e:
12+
print(e)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "clientapi_forgejo"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = "Forgejo API"
55
authors = ["OpenAPI Generator Community <team@openapitools.org>"]
66
license = "This file is distributed under the MIT license for the purpose of interoperability"

0 commit comments

Comments
 (0)