Giter Site home page Giter Site logo

go-gogs-client's Introduction

Gogs API client in Go

This package is still in experiment, see Wiki for documentation.

License

This project is under the MIT License. See the LICENSE file for the full license text.

go-gogs-client's People

Contributors

6543 avatar 7byte avatar achilleas-k avatar beanow avatar bkcsoft avatar compressed avatar eriknstevenson avatar guyzmo avatar iwanbk avatar kmadel avatar lstahlman avatar m-pavel avatar martinhpedersen avatar mruschmann avatar richmahn avatar roblabla avatar rubenv avatar sapk avatar syndbg avatar unknwon avatar xmonader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-gogs-client's Issues

Get Organization members

Use case: send an email to all Organization Owners when code is pushed to any of the Organization repos. I got it all working except I have to hardcode the recipients for now since the API does not exist yet. Would gladly help by I only know PHP ... so maybe I can write the documentation ... Thanks.

v1/users/:username/tokens

Hi, there seems to be an issue with the authorisation of access tokens using the API. Regardless of username/password combination, basic authorisation headers, or URL based tokens all from admins and not, the post and get commands return a 401.

Am i missing something? and has anyone had this working?

Regards

Specifying "uid" when search after repo doesnt work

When searching for repositories within a user, with e.g the user id 44, will return results for other users as well and not be restricted to the user with user id = 44.

Query example:
GET https://git.giaever.org/api/v1/repos/search?q=gogs&user=44&limit=10

Result example:

{"data":[{"id":41,"owner":{"id":2,"login":"GiaeverPubl","full_name":"Giaever Publishing","email":"","avatar_url":"https://git.giaever.org/avatars/2","username":"GiaeverPubl"},"name":"git.giaever.org","full_name":"GiaeverPubl/git.giaever.org","description":"Git.giaever.org Gogs setup","private":true,"fork":false,"parent":null,"empty":false,"mirror":false,"size":16381952,"html_url":"https://git.giaever.org/GiaeverPubl/git.giaever.org","ssh_url":"[email protected]:GiaeverPubl/git.giaever.org.git","clone_url":"https://git.giaever.org/GiaeverPubl/git.giaever.org.git","website":"https://git.giaever.org","stars_count":0,"forks_count":0,"watchers_count":2,"open_issues_count":0,"default_branch":"master","created_at":"2016-11-18T03:54:55+01:00","updated_at":"2016-11-18T06:45:06+01:00"},{"id":153,"owner":{"id":1,"login":"joachimmg","full_name":"Joachim Marthinsen Giæver","email":"[email protected]","avatar_url":"https://git.giaever.org/avatars/1","username":"joachimmg"},"name":"gogs-api-wpp","full_name":"joachimmg/gogs-api-wpp","description":"Gogs API wordpress plugin","private":true,"fork":false,"parent":null,"empty":false,"mirror":false,"size":90112,"html_url":"https://git.giaever.org/joachimmg/gogs-api-wpp","ssh_url":"[email protected]:joachimmg/gogs-api-wpp.git","clone_url":"https://git.giaever.org/joachimmg/gogs-api-wpp.git","website":"","stars_count":0,"forks_count":0,"watchers_count":1,"open_issues_count":0,"default_branch":"master","created_at":"2017-10-17T10:40:14+02:00","updated_at":"2017-10-20T09:40:35+02:00"},{"id":180,"owner":{"id":1,"login":"joachimmg","full_name":"Joachim Marthinsen Giæver","email":"[email protected]","avatar_url":"https://git.giaever.org/avatars/1","username":"joachimmg"},"name":"gogs-php-api-client","full_name":"joachimmg/gogs-php-api-client","description":"Gogs PHP API Client is a client written in PHP, to easily query a Gogs (Go Git Service) API client.","private":false,"fork":false,"parent":null,"empty":false,"mirror":false,"size":848896,"html_url":"https://git.giaever.org/joachimmg/gogs-php-api-client","ssh_url":"[email protected]:joachimmg/gogs-php-api-client.git","clone_url":"https://git.giaever.org/joachimmg/gogs-php-api-client.git","website":"","stars_count":0,"forks_count":0,"watchers_count":1,"open_issues_count":0,"default_branch":"master","created_at":"2017-10-19T16:44:04+02:00","updated_at":"2017-10-20T09:52:36+02:00"},{"id":183,"owner":{"id":30,"login":"bje007","full_name":"Birger Christoffer Jensen","email":"[email protected]","avatar_url":"https://secure.gravatar.com/avatar/12285f0af02782093a4d18c6fcdfb8a5","username":"bje007"},"name":"test-gogs-api-repo-70","full_name":"bje007/test-gogs-api-repo-70","description":"This is test repo #70 created with Gogs PHP API Client","private":false,"fork":false,"parent":null,"empty":false,"mirror":false,"size":0,"html_url":"https://git.giaever.org/bje007/test-gogs-api-repo-70","ssh_url":"[email protected]:bje007/test-gogs-api-repo-70.git","clone_url":"https://git.giaever.org/bje007/test-gogs-api-repo-70.git","website":"","stars_count":0,"forks_count":0,"watchers_count":2,"open_issues_count":0,"default_branch":"master","created_at":"2017-10-20T11:06:03+02:00","updated_at":"2017-10-20T13:30:02+02:00"}],"ok":true}

Contains at least 2 different owners and none of them has id = 44!

Gogs Version: 0.11.29.0727

Attach a file when creating issue

Hello.

Currently in the web client one can attach a file when creating issue. Do you have plans to expose this functionality by rest as well ?

Regards, B.

How to create organization using gogs API?

I POST to this url, but nothing feedback

/api/v1/admin/users/htfang/orgs
{
"username":"htfang",
"full_name":"tttest",
"description":"nothing",
"website":"nothing",
"location":"location"
}

Error when loading shared libraries libpam.so.0

After I have downloaded the zip to Linux 64 bits (Im in Ubuntu 14.04, 64 bits), I runned:
$ ./gogs web
And got:
./gogs: error while loading shared libraries: libpam.so.0: cannot open shared object file: No such file or directory

Someone can help me about this?

Pull requests API

It would be very useful to have endpoints allowing to collaborate with PR.

Issues API

As mentioned in my comment (gogs/gogs#1692 (comment)), i'd like to implement issues API, started with comments part.

Please let me know if there is someone already working on it.

If not, i will come with API specification proposal.

how to install

I don't understand how I should install go gogs client, can you add it in the wiki please?

Migration fails due to self signed certificate

I am currently using a self hosted instance of Stash for my repositories.

Trying gogs it would be crucial for me to migrate all my repositories. At the moment these fails due to a self signed certificate I am using. Is there a way around it? I could only find a "SKIP_VERIFY" option for the Mailer.

Migration failed: Clone: exit status 128 - fatal: unable to access 'https://@URL_TO_HOST:443/scm/go/my_repository.git/': SSL certificate problem: self signed certificate

Error on Repositories Wiki page

Hello,
the wiki page describing repositories endpoints incorrectly states that in order to create an organization repository, one should use the POST /orgs/:org/repos while in reality the endpoint is POST /org/:org/repos :).

Problems with Creating SSH Public Keys via the API

Hi Guys using GOGS in docker (Gogs Version: 0.11.6.0407), trying to use the API , to create SSH Public Keys:

  • I have created API Token and can confirm that I can create repositories using the API

I run the command to attempt to create keys:

curl -k -H "Content-Type: application/json" -d '{
"title": "Test SSH Keys",
"key": "test" }' -X POST https://test.rap.local:3000/api/v1/user/repos?token=6d836a020e19be4ce8952154969c8b6644f1e53a

It then created a new repository with no keys.

I am going of the documentation here:
https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys In the Create a public key section.

The documentation was last updated Dec 6, 2015, have there been any changes to the syntax?

Thanks for your time and help.

ListUserKeys doesn't format the url correctly

func (c *Client) ListMyPublicKeys(user string) ([]*PublicKey, error) {
    keys := make([]*PublicKey, 0, 10)
    return keys, c.getParsedResponse("GET", fmt.Sprintf("/user/keys", user), nil, nil, &keys)
}

Shouldn't drop usage of user parameter?

func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) {
    keys := make([]*PublicKey, 0, 10)
    return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys)
}

Collaborator with read write can delete repository

A collaborator that only have read access to a repository can delete it.

How?

  • Log in to Gogs with one account and add a user (another account) to a repository as a collaborator with read access
  • Log in to Gogs with the collaborator and create a token for this account, and query the API with the new token: DELETE {url}/api/v1/repos/*owner username*/*repo name*

Gogs Version: 0.11.29.0727

Gogs REST API

Hi there,

It's great that I'm able to make a POST HTTP request to the REST API that Gogs exposes to create a repository and all that, but I can't seem to find documentation on how to go about deleting a repository that was created via the same interface.

Is that just not documented? Or is it not supported via the currently exposed REST API?

Thanks a bunch!

richer api

I'm wanting to move away from gitlab (slow, slow, slow) but have an application that uses the api to manage lots of things. From what I can see, the api in gogs is a very poor relation - are there any plans on beefing up the api and making it much more functionally rich ?

Cannot create Webhook

Hi,

I'm using Gogs Version: 0.10.34.0330 / 0.11 RC.

I'm trying to create a hook through the api, and I get this response:
[{"fieldNames":["Config"],"classification":"RequiredError","message":"Required"}]

My code is:

import requests

organization = 'test'
repo_name = 'test'
token = 'ac16d61127466efc3d316db76e68b7358c8075b4'

data = {
    "type": "gogs",
    "config": {
        "url": "http://192.168.201.1:8080/hook",
        "content_type": "json"
    },
    "events": [
        "create",
        "delete",
        "fork",
        "push",
        "issues",
        "issue_comment",
        "pull_request",
        "release",
    ],
    "active": True
}

url = "http://192.168.201.100:3000/api/v1/repos/{o}/{r}/hooks?token={t}".format(o=organization, r=repo_name, t=token)

session = requests.Session()
response = session.post(url, data=data)
print response.text

Create issue for project

For use cases like bug reports from server it's good to have an API to create issues with setting labels and assignee and ...

getaddrinfo ENOTFOUND

Scenario:

The user is logged into door43 then loses wifi connection and tries to upload a project to git.door.43.

You guys may have a better way for the client to handle this error but since I don't know I'm assuming there's not. Thus, I think if as I a client of gogs it's better if I get the 443 error status/message.

Error: getaddrinfo ENOTFOUND git.door43.org git.door43.org:443
    at errnoException (dns.js:28)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76)

API to List organization repositories

Similar to GitHub:

List repositories for the specified org.

GET /orgs/:org/repos

This would make it easier to interact with repositories specific to a given organization.

Post Team and/or Post User

Use case is for migration purposes. Would like the ability to batch create teams.
It would be a nice feature to batch create users and batch assign to teams

Github API v3

REST Delete repo?

I'm having a problem trying to delete a repo via the rest api. I've tried a few variations of:

curl -X DELETE -u $user:$password "http://$host:3000/api/v1/repos/$user/abc-app-one"

But I'm getting a 204 -- No Content ("message":"deleteBeans: database table is locked"). What have I got wrong?

I'm using Gogs version 0.9.87.0826

CSRF Token Issues

Currently, I can't see a way of interacting with my gogs server when I keep getting:

Bad Request: no CSRF token represnet

Whenever I try to create a repository via the API.

Add default system wide hook

I need to create "build-in" CI service into my git server (like github pages generator). It should be undeletable. But I could not find any system wide hook configuration option in documentation. Is it missed or there is no such option?

Import data from GitLab

How can I import a full projeto do gogs? Is that possible?

I want to import Milestones, issues and commits.

Get Repo by Name

Would it be possible to add an endpoint for getting a single repository? I'm working on integrating Gogs with the latest version of Drone (0.4) and we have the need to retrieve a Repo by name.

If you have any docs for your API you can point me to I'm happy to submit a pull request and add this functionality to the client.

get closed issues

The GET /repos/:owner/:repo/issues gets all open issues for a repository, I'd like to get all of them.

Enable setting custom client, InsecureSkipVerify

For GitLab we see a lot of people self-hosting with customer SSL certs. We typically have to set InsecureSkipVerify to true. This is probably something we'll want to support with the Gogs client as well.

Something like this:

tr := &http.Transport{
  TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}

gogs.NewClient(url, token, client)

CSP violation

I started to play w/ API on REST level by issuing

fetch('https://try.gogs.io/api/v1/repos/a_test/another_test/issues/1', {
  method:'post',
  headers:{Authorization:'Basic '+btoa('user:pass')}
})

but I get back:

Refused to connect to 'https://try.gogs.io/api/v1/repos/a_test/another_test/issues/1' because it violates the following Content Security Policy directive: "connect-src 'self' https://suggestqueries.google.com https://ac.duckduckgo.com".

As far as I understood the code here, no special headers are added (though authorization is by token). Am I doing something wrong or is this a feature?

Public content for authorized user

The documentation states that querying:

  • repositories GET {url}/api/v1/users/{username}/{repos}
  • organizations GET {url}/api/v1/users/{username}/{orgs}
  • etc
    should only return public data of that user. That isn't the fact if the {username} is the same user that owns the api-token, instead everything is returned.

This is what one can expect when issuing the GET {url}/api/v1/user/repos and similar requests for the authorized user.

Either must the documentation be changed to cover the differences or the code should actually return the public data within the scopes for public data.

Second one makes the most sense.... It would be convenient to actually have an method to get only public data, even for the authorized user, as the data returned for some requests (such as organizations) doesnt tell if this data is a private or public.

Gogs Version: 0.11.29.0727

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.