@@ -1408,3 +1408,50 @@ 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
+ // UserRunner represents a GitLab runner linked to the current user.
1413
+ //
1414
+ // GitLab API docs:
1415
+ // https://docs.gitlab.com/ee/api/users.html#create-a-runner
1416
+ type UserRunner struct {
1417
+ ID int `json:"id"`
1418
+ Token string `json:"token"`
1419
+ TokenExpiresAt * time.Time `json:"token_expires_at"`
1420
+ }
1421
+
1422
+ // CreateUserRunnerOptions represents the available CreateUserRunner() options.
1423
+ //
1424
+ // GitLab API docs:
1425
+ // https://docs.gitlab.com/ee/api/users.html#create-a-runner
1426
+ type CreateUserRunnerOptions struct {
1427
+ RunnerType * string `url:"runner_type,omitempty" json:"runner_type,omitempty"`
1428
+ GroupID * int `url:"group_id,omitempty" json:"group_id,omitempty"`
1429
+ ProjectID * int `url:"project_id,omitempty" json:"project_id,omitempty"`
1430
+ Description * string `url:"description,omitempty" json:"description,omitempty"`
1431
+ Paused * bool `url:"paused,omitempty" json:"paused,omitempty"`
1432
+ Locked * bool `url:"locked,omitempty" json:"locked,omitempty"`
1433
+ RunUntagged * bool `url:"run_untagged,omitempty" json:"run_untagged,omitempty"`
1434
+ TagList * []string `url:"tag_list,omitempty" json:"tag_list,omitempty"`
1435
+ AccessLevel * string `url:"access_level,omitempty" json:"access_level,omitempty"`
1436
+ MaximumTimeout * int `url:"maximum_timeout,omitempty" json:"maximum_timeout,omitempty"`
1437
+ MaintenanceNote * string `url:"maintenance_note,omitempty" json:"maintenance_note,omitempty"`
1438
+ }
1439
+
1440
+ // CreateUserRunner creates a runner linked to the current user.
1441
+ //
1442
+ // GitLab API docs:
1443
+ // https://docs.gitlab.com/ee/api/users.html#create-a-runner
1444
+ func (s * UsersService ) CreateUserRunner (opts * CreateUserRunnerOptions , options ... RequestOptionFunc ) (* UserRunner , * Response , error ) {
1445
+ req , err := s .client .NewRequest (http .MethodPost , "user/runners" , opts , options )
1446
+ if err != nil {
1447
+ return nil , nil , err
1448
+ }
1449
+
1450
+ r := new (UserRunner )
1451
+ resp , err := s .client .Do (req , r )
1452
+ if err != nil {
1453
+ return nil , resp , err
1454
+ }
1455
+
1456
+ return r , resp , nil
1457
+ }
0 commit comments