@@ -1408,3 +1408,63 @@ func (s *UsersService) DisableTwoFactor(user int, options ...RequestOptionFunc)
1408
1408
return fmt .Errorf ("Received unexpected result code: %d" , resp .StatusCode )
1409
1409
}
1410
1410
}
1411
+
1412
+ // CreateUserRunnerOptions represents the options available when creating a GitLab Runner
1413
+ // using the new user-based flow.
1414
+ //
1415
+ // GitLab API docs:
1416
+ // https://docs.gitlab.com/ee/api/users.html#create-a-runner
1417
+ type CreateUserRunnerOptions struct {
1418
+ RunnerType string `json:"runner_type"`
1419
+ GroupID int `json:"group_id"`
1420
+ ProjectID int `json:"project_id"`
1421
+ Description string `json:"description"`
1422
+ Paused bool `json:"paused"`
1423
+ Locked bool `json:"locked"`
1424
+ RunUntagged bool `json:"run_untagged"`
1425
+ TagList []string `json:"tag_list"`
1426
+ AccessLevel string `json:"access_level"`
1427
+ MaximumTimeout int `json:"maximum_timeout"`
1428
+ }
1429
+
1430
+ // UserRunner represents the a GitLab runner instance created using the user-based flow
1431
+ //
1432
+ // GitLab API docs:
1433
+ // https://docs.gitlab.com/ee/api/users.html#create-a-runner
1434
+ type UserRunner struct {
1435
+ ID int `json:"id"`
1436
+ Token string `json:"token"`
1437
+ TokenExpiresAt string `json:"token_expires_at"`
1438
+ RunnerType string `json:"runner_type"`
1439
+ GroupID int `json:"group_id"`
1440
+ ProjectID int `json:"project_id"`
1441
+ Description string `json:"description"`
1442
+ Paused bool `json:"paused"`
1443
+ Locked bool `json:"locked"`
1444
+ RunUntagged bool `json:"run_untagged"`
1445
+ TagList []string `json:"tag_list"`
1446
+ AccessLevel string `json:"access_level"`
1447
+ MaximumTimeout int `json:"maximum_timeout"`
1448
+ }
1449
+
1450
+ // GetUserMemberships retrieves a list of the user's memberships.
1451
+ //
1452
+ // GitLab API docs:
1453
+ // https://docs.gitlab.com/ee/api/users.html#user-memberships
1454
+ func (s * UsersService ) CreateUserRunner (runnerOpts * CreateUserRunnerOptions , options ... RequestOptionFunc ) (* UserRunner , * Response , error ) {
1455
+ // The user who owns the runner comes from the access token used to authorize the request.
1456
+ u := "user/runners"
1457
+
1458
+ req , err := s .client .NewRequest (http .MethodPost , u , runnerOpts , options )
1459
+ if err != nil {
1460
+ return nil , nil , err
1461
+ }
1462
+
1463
+ var r * UserRunner
1464
+ resp , err := s .client .Do (req , & r )
1465
+ if err != nil {
1466
+ return nil , resp , err
1467
+ }
1468
+
1469
+ return r , resp , nil
1470
+ }
0 commit comments