Update README.md

pull/1/head
Langenfeld 2019-06-27 13:43:57 +02:00
rodzic 7ea7166400
commit 8caa2a0f5a
1 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -12,27 +12,27 @@ Teams in Organizations and adding Repositories to Teams.
First get a `gitea` object wrapping access and authentication (via an api token) for your gitea instance: First get a `gitea` object wrapping access and authentication (via an api token) for your gitea instance:
``` ```python
gitea = Gitea(URL, TOKEN) gitea = Gitea(URL, TOKEN)
``` ```
Operations like requesting the Gitea version or authentication user can be requested directly from the `gitea` object: Operations like requesting the Gitea version or authentication user can be requested directly from the `gitea` object:
``` ```python
print("Gitea Version: " + gitea.get_version()) print("Gitea Version: " + gitea.get_version())
print("API-Token belongs to user: " + gitea.get_user().username) print("API-Token belongs to user: " + gitea.get_user().username)
``` ```
Adding entities like Users, Organizations, ... also is done via the gitea object. Adding entities like Users, Organizations, ... also is done via the gitea object.
``` ```python
user = gitea.create_user("Test Testson", "test@test.test", "password") user = gitea.create_user("Test Testson", "test@test.test", "password")
``` ```
All operations on entities in gitea are then accomplished via the according wrapper objects for those entities. All operations on entities in gitea are then accomplished via the according wrapper objects for those entities.
Each of those objects has a `.request` method that creates an entity according to your gitea instance. Each of those objects has a `.request` method that creates an entity according to your gitea instance.
``` ```python
other_user = User.request(gitea, "OtherUserName") other_user = User.request(gitea, "OtherUserName")
print(other_user.username) print(other_user.username)
``` ```
@ -42,7 +42,7 @@ Note that the fields of the User, Organization,... classes are dynamically creat
Fields that can not be altered via gitea-api, are read only. After altering a field, the `.commit` method of the according object must be called to synchronize the changed fields with your gitea instance. Fields that can not be altered via gitea-api, are read only. After altering a field, the `.commit` method of the according object must be called to synchronize the changed fields with your gitea instance.
``` ```python
org = Organization.request(gitea, test_org) org = Organization.request(gitea, test_org)
org.description = "some new description" org.description = "some new description"
org.location = "some new location" org.location = "some new location"
@ -50,12 +50,12 @@ org.commit()
``` ```
An entity in gitea can be deleted by calling delete. An entity in gitea can be deleted by calling delete.
``` ```python
org.delete() org.delete()
``` ```
All entity objects do have methods to execute some of the requests possible though the gitea-api: All entity objects do have methods to execute some of the requests possible though the gitea-api:
``` ```python
org = Organization.request(gitea, ORGNAME) org = Organization.request(gitea, ORGNAME)
teams = org.get_teams() teams = org.get_teams()
for team in teams: for team in teams: