Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

tonic-PLAN.Rmd 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. ---
  2. title: "Adding tonic to gin: the plan"
  3. author: "colomb_julien"
  4. date: "8/6/2020"
  5. output:
  6. bookdown::html_document2:
  7. keep_md: yes
  8. toc: true
  9. ---
  10. ```{r, echo=FALSE}
  11. botname = "tonic-bot"
  12. RAT = "read-access-team"
  13. WAT = "write-access-team"
  14. ```
  15. # Overview
  16. TONIC: Templates for organizing nifty information containers
  17. GIN users will use their GIN credential to login to the tonic application. In this application, they will be able to perform some function that are either complex (requiring many steps) and/or functions they do not have the access rights to perform. In the backend, the application will login to GIN using the `r botname`.
  18. `r botname` will create organisation, teams and repositories on behalf of the loged-in user. In order to use the application on existing repositories or organisations, one needs to add `r botname` as a collaborator on a repository, or as an owner of an organisation (this step is automatized when `r botname` is creating them).
  19. Instead of creating simple repositories, `r botname` creates research repositories (RR): these repositories are created from a template and include submodules (themselves created from templates). Submodules allow for a differentiation of access rights and easy publication of part of a repository.
  20. # Information available from login
  21. After login, the application will know the user's credential, and can therefore access the metadata associated and find:
  22. - organisations where he is a member, and `r botname` is an owner.
  23. - organisation that are lab-organisation (i.e have the 2 default teams)
  24. - repositories were he and `r botname` has write access to
  25. # Administration functions
  26. ## Create new lab-organisation ()
  27. The principle is to create an organisation, where `r botname` and the logged-user will become owners. The organisation also get two teams per default: the `r RAT` and the `r WAT`, with read and write access rights respectively.
  28. - Problem: the bot would need admin access, or the API must change to create the organisation.
  29. - createteam seems not to work here.
  30. - putative problem: what if there is already an organisation with that name ?
  31. Create the organisation:
  32. (code not working: no admin access)
  33. ```{bash, results='hide'}
  34. . setgin.sh
  35. ## create an organisation, with bot
  36. botname="jcolomb"
  37. loginuser="bruce-wayne"
  38. #Inputs
  39. thisorga="testorga"
  40. createorga(){
  41. organame=$1
  42. data="{\"username\":\"${organame}\",\"Description\":\"${organame}\"}"
  43. echo post ${data} ${ginhost}/api/v1/admin/users/${botname}/orgs
  44. }
  45. createorga ${thisorga}
  46. #POST /admin/users/:username/orgs
  47. # username string Required Organization user name
  48. # full_name string Full name of organization
  49. # description string Description to the organization
  50. # website string Official website
  51. # location string Organization location
  52. ```
  53. Add login user as organisation owner:
  54. (code not working, probably because put does not work ?)
  55. ```{bash}
  56. . setgin.sh
  57. botname="jcolomb"
  58. loginuser="bruce-wayne"
  59. thisorga="testorga"
  60. addusertoorga(){
  61. organame=$1
  62. user=$2
  63. data="{\"role\":admin}"
  64. echo put ${data} ${ginhost}/api/v1/orgs/${organame}/memberships/${user}
  65. }
  66. addusertoorga ${thisorga} ${loginuser}
  67. ```
  68. Create the teams:
  69. ```{bash}
  70. . setgin.sh
  71. botname="jcolomb"
  72. loginuser="jcolomb"
  73. thisorga="testorga"
  74. createteam() {
  75. teamname=$1
  76. organisation=$2
  77. permission=$3
  78. data="{\"name\":\"${teamname}\",\"description\":\"default team\",\"permission\":\"${permission}\"}"
  79. #post ${data} ${ginhost}/api/v1/orgs/${organisation}/teams
  80. echo post ${data} ${ginhost}/api/v1/orgs/${organisation}/teams
  81. }
  82. createteam readaccess ${thisorga} read
  83. createteam writeaccess ${thisorga} admin
  84. ```
  85. ## Add members to a lab-organisation ()
  86. Here, we will add the member to an organisation, with member permission and add him to the default teams.
  87. - choose an organisation from the list
  88. - add username of user to add (could use the same search GIN has)
  89. ```{bash}
  90. ## add someone to organisation + teams
  91. . setgin.sh
  92. botname="jcolomb"
  93. loginuser="bruce-wayne"
  94. #Inputs:
  95. thisorga="testorga"
  96. newuser="bruce-wayne"
  97. # PUT /orgs/:orgname/memberships/:username
  98. # role="member"
  99. addusertoorga_m(){
  100. organame=$1
  101. user=$2
  102. data="{\"role\":member}"
  103. echo put ${data} ${ginhost}/api/v1/orgs/${organame}/memberships/${user}
  104. }
  105. addusertoorga_m ${thisorga} ${newuser}
  106. ## for each team:
  107. #PUT /admin/teams/:teamid/members/:username
  108. addusertoteam(){
  109. organame=$1
  110. teamname=$2
  111. user=$3
  112. teamlist="GET /orgs/${organame}/teams"
  113. teamid="id from teamlist with name==teamname"
  114. data="{\"role\":member}"
  115. echo put ${data} ${ginhost}/api/v1//admin/teams/${teamid}/members/${user}
  116. }
  117. addusertoteam ${thisorga} readaccess ${newuser}
  118. addusertoteam ${thisorga} writeaccess ${newuser}
  119. # PS there is no way to get all members of an organisation ?
  120. ```
  121. # Repository functions
  122. ## Overview of research repositories
  123. We call the research repository, a GIN repository created from a template folder structure developed for (neuro-)research, and that hosts submodules. The user may be able to select submodules and templates, during or after the creation of the research repository.
  124. Because users must get access to all repository at once, each research repository comes with its team, which get admin access to the parent repository and all submodules.
  125. ## Create research repository ()
  126. ### user inputs
  127. - RR name
  128. - main template for parent repository (may include some submodules)
  129. - (optional) existing team to add the new RR
  130. message: additional submodules (for data for instance) may be added later
  131. ### create repository
  132. - check that name is available
  133. - if no exisiting team has been indicated: create a new team (add _1 if name unavailable)
  134. - create repository
  135. - add repository to team (indicated or newly created)
  136. - downlaod repository on /temp
  137. - clone template into it
  138. - sync to gin (change remote URL to project repo, git annex init)
  139. - add default submodules (see below)
  140. - set git annex
  141. - sync to gin (change remote URL to project repo, git annex init)
  142. ## Add existing (lab) submodule to a research repository ()
  143. input:
  144. - submodule address
  145. - folder name in parent repository
  146. logic:
  147. - if needed: download repository on /temp
  148. - add submodule with git submodule add
  149. - sync to gin
  150. ## Add specific submodule to a research repository ()
  151. - input: submodule template + folder name in parent repository + parent repository
  152. - automatic extra: teamid of team with write access to parent repository
  153. logic:
  154. - create submodule repository
  155. - disable issue-tracker
  156. - add repository to team (indicated or newly created)
  157. - downlaod repository on /temp
  158. - clone template into it (including git-annex behavior)
  159. - sync to gin (change remote URL to project repo, git annex init)
  160. - add submodule to parent repository (see above)
  161. ## Clone research repositories ()
  162. - clone parent repository
  163. - update submodules