setgin.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Token can be created in GIN user settings, under Applications.
  2. # An organisation admin account is required to create teams.
  3. token="f5058edf6a8e7e6ea2c52af474039902b2aa923b"
  4. # Change this to the local installation addresses to test locally.
  5. # Include the protocol scheme http:// or https:// and the port if it's not
  6. # standard for the protocol.
  7. ginhost="https://gin.g-node.org"
  8. # Same as above, change to local address to test locally and include port
  9. # number if it's not 22.
  10. ginssh="gin.g-node.org"
  11. organisation="gin4rri"
  12. post() {
  13. data=$1
  14. url=$2
  15. curl -X -H "Content-Type: application/jsonAuthorization" -H "Authorization: token ${token}" -d "${data}" ${url}
  16. }
  17. put() {
  18. data=$1
  19. url=$2
  20. curl -H "Content-Type: application/jsonAuthorization" -H "Authorization: token ${token}" -d "${data}" -X PUT "${url}"
  21. }
  22. patch() {
  23. data=$1
  24. url=$2
  25. curl -H "Content-Type: application/jsonAuthorization" -H "Authorization: token ${token}" -d "${data}" -X PATCH "${url}"
  26. }
  27. createrepo() {
  28. reponame=$1
  29. data="{\"Name\":\"${reponame}\",\"Description\":\"deleteme\",\"Private\":true}"
  30. post ${data} ${ginhost}/api/v1/org/${organisation}/repos
  31. }
  32. createrepot() {
  33. reponame=$1
  34. data="{\"Name\":\"${reponame}\",\"Description\":\"deleteme\",\"Private\":true,\"Readme\":\"Default\",\"auto_init\":true}"
  35. post ${data} ${ginhost}/api/v1/org/${organisation}/repos
  36. }
  37. issuetrackeroption (){
  38. reponame=$1
  39. enable_issuesopt=$2
  40. # todo https://github.com/gogs/docs-api/tree/master/Repositories
  41. # PATCH /repos/:owner/:repo/issue-tracker
  42. # enable_issues = false
  43. ## maybe link to parent issue tracker instead ?
  44. data="{\"enable_issues\":${enable_issuesopt}}"
  45. patch $data ${ginhost}/api/v1/repos/${organisation}/${reponame}/issue-tracker
  46. }