Giter Club home page Giter Club logo

py-gitea's Introduction

py-gitea

A very simple API client for Gitea > 1.16.1

This has been somewhat tested (and used), so most things should work as expected.

Note that not the full Swagger-API is accessible. The whole implementation is focused on making access and working with Organizations, Teams, Repositories and Users as pain free as possible.

Originally forked from https://github.com/m301/py-gitea.

Usage

First get a gitea object wrapping access and authentication (via an api token) for your gitea instance:

from gitea import *

gitea = Gitea(URL, TOKEN)

Operations like requesting the Gitea version or authentication user can be requested directly from the gitea object:

print("Gitea Version: " + gitea.get_version())
print("API-Token belongs to user: " + gitea.get_user().username)

Adding entities like Users, Organizations, ... also is done via the gitea object.

user = gitea.create_user("Test Testson", "[email protected]", "password")

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.

other_user = User.request(gitea, "OtherUserName")
print(other_user.username)

Note that the fields of the User, Organization,... classes are dynamically created at runtime, and thus not visible during divelopment. Refer to the Gitea-API documentation for the fields names.

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.

org = Organization.request(gitea, test_org)
org.description = "some new description"
org.location = "some new location"
org.commit()

An entity in gitea can be deleted by calling delete.

org.delete()

All entity objects do have methods to execute some of the requests possible though the gitea-api:

org = Organization.request(gitea, ORGNAME)
teams = org.get_teams()
for team in teams:
    repos = team.get_repos()
    for repo in repos:
        print(repo.name)

Installation

Use pip install py-gitea to install.

Tests

Tests can be run with:

python3 -m pytest test_api.py

Make sure to have a gitea-instance running on http://localhost:3000, and an admin-user token at .token. The admin user must be named test, with email [email protected].

py-gitea's People

Contributors

langenfeld avatar fkarg avatar danieldietsch avatar etienne-monier avatar oyvindkolbu avatar breee avatar laromicas avatar holgi avatar m301 avatar lunik avatar specialunderwear avatar stephenhouser avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.