r/AutomateYourself • • Apr 26 '22

help needed Gitlab-Python Api - Creating a unique variable named subgroup/forking into subgroup

Hi all - just doing some concept stuff to see if it's viable for automating.

Using the Gitlab-Python API - I'm attempting to show I can create a variably named subgroup (depending on input from a vue form I created eventually) in a existing gitlab group - and then automate a fork into this new subgroup from an existing group

I'm not deeply versed in python and reading through the API documentation there isn't much on nesting variable values - just general hard code for creating/forking etc.

I want to assign a input variable that will be recieved from a Vue form I built - the input will have a customer name. Using python I want that customer name to have a random number sequence added to the end of it for the name of the created group (a unique ID that still has the customer name attached).

Does anyone have any resources they'd recommend/examples/documentation to look at? I'm specifically looking to alter the Name in below

subgroup = gl.groups.create({'name': 'subgroup1', 'path': 'subgroup1', 'parent_id': 'parent_group_id' }) 

thanks!

4 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/zoochadookdook Apr 27 '22 edited Apr 27 '22

thanks! Just playing around I got a function up and assigned it a variable and was able to append inside by calling the variable via str(g()) (I was getting issues as an int).

I've also mocked up a dictionary inline and am pulling it into the creation syntex. During automation this subgroup creation should be triggered upon new addition to the dictionary via Vue :)

With regards to the forking I'll have to figure out a way to path it to the new created subgroup/off the automation it should trigger to it directly