66 "github.com/cloudbase/garm/client"
77 clientControllerInfo "github.com/cloudbase/garm/client/controller_info"
88 clientCredentials "github.com/cloudbase/garm/client/credentials"
9+ clientEndpoints "github.com/cloudbase/garm/client/endpoints"
910 clientFirstRun "github.com/cloudbase/garm/client/first_run"
1011 clientInstances "github.com/cloudbase/garm/client/instances"
1112 clientJobs "github.com/cloudbase/garm/client/jobs"
@@ -18,9 +19,7 @@ import (
1819 "github.com/cloudbase/garm/params"
1920)
2021
21- // ///////////
22- // Garm Init /
23- // ///////////
22+ // firstRun will initialize a new garm installation.
2423func firstRun (apiCli * client.GarmAPI , newUser params.NewUserParams ) (params.User , error ) {
2524 firstRunResponse , err := apiCli .FirstRun .FirstRun (
2625 clientFirstRun .NewFirstRunParams ().WithBody (newUser ),
@@ -41,9 +40,7 @@ func login(apiCli *client.GarmAPI, params params.PasswordLoginParams) (string, e
4140 return loginResponse .Payload .Token , nil
4241}
4342
44- // ////////////////////////////
45- // Credentials and Providers //
46- // ////////////////////////////
43+ // listCredentials lists all the credentials configured in GARM.
4744func listCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Credentials , error ) {
4845 listCredentialsResponse , err := apiCli .Credentials .ListCredentials (
4946 clientCredentials .NewListCredentialsParams (),
@@ -54,6 +51,69 @@ func listCredentials(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfo
5451 return listCredentialsResponse .Payload , nil
5552}
5653
54+ func createGithubCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsParams params.CreateGithubCredentialsParams ) (* params.GithubCredentials , error ) {
55+ createCredentialsResponse , err := apiCli .Credentials .CreateCredentials (
56+ clientCredentials .NewCreateCredentialsParams ().WithBody (credentialsParams ),
57+ apiAuthToken )
58+ if err != nil {
59+ return nil , err
60+ }
61+ return & createCredentialsResponse .Payload , nil
62+ }
63+
64+ func deleteGithubCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsID int64 ) error {
65+ return apiCli .Credentials .DeleteCredentials (
66+ clientCredentials .NewDeleteCredentialsParams ().WithID (credentialsID ),
67+ apiAuthToken )
68+ }
69+
70+ func getGithubCredential (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsID int64 ) (* params.GithubCredentials , error ) {
71+ getCredentialsResponse , err := apiCli .Credentials .GetCredentials (
72+ clientCredentials .NewGetCredentialsParams ().WithID (credentialsID ),
73+ apiAuthToken )
74+ if err != nil {
75+ return nil , err
76+ }
77+ return & getCredentialsResponse .Payload , nil
78+ }
79+
80+ func createGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointParams params.CreateGithubEndpointParams ) (* params.GithubEndpoint , error ) {
81+ createEndpointResponse , err := apiCli .Endpoints .CreateGithubEndpoint (
82+ clientEndpoints .NewCreateGithubEndpointParams ().WithBody (endpointParams ),
83+ apiAuthToken )
84+ if err != nil {
85+ return nil , err
86+ }
87+ return & createEndpointResponse .Payload , nil
88+ }
89+
90+ func listGithubEndpoints (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.GithubEndpoints , error ) {
91+ listEndpointsResponse , err := apiCli .Endpoints .ListGithubEndpoints (
92+ clientEndpoints .NewListGithubEndpointsParams (),
93+ apiAuthToken )
94+ if err != nil {
95+ return nil , err
96+ }
97+ return listEndpointsResponse .Payload , nil
98+ }
99+
100+ func getGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointName string ) (* params.GithubEndpoint , error ) {
101+ getEndpointResponse , err := apiCli .Endpoints .GetGithubEndpoint (
102+ clientEndpoints .NewGetGithubEndpointParams ().WithName (endpointName ),
103+ apiAuthToken )
104+ if err != nil {
105+ return nil , err
106+ }
107+ return & getEndpointResponse .Payload , nil
108+ }
109+
110+ func deleteGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointName string ) error {
111+ return apiCli .Endpoints .DeleteGithubEndpoint (
112+ clientEndpoints .NewDeleteGithubEndpointParams ().WithName (endpointName ),
113+ apiAuthToken )
114+ }
115+
116+ // listProviders lists all the providers configured in GARM.
57117func listProviders (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Providers , error ) {
58118 listProvidersResponse , err := apiCli .Providers .ListProviders (
59119 clientProviders .NewListProvidersParams (),
@@ -64,9 +124,7 @@ func listProviders(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWr
64124 return listProvidersResponse .Payload , nil
65125}
66126
67- // ////////////////////////
68- // // Controller info ////
69- // ////////////////////////
127+ // getControllerInfo returns information about the GARM controller.
70128func getControllerInfo (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.ControllerInfo , error ) {
71129 controllerInfoResponse , err := apiCli .ControllerInfo .ControllerInfo (
72130 clientControllerInfo .NewControllerInfoParams (),
@@ -77,9 +135,7 @@ func getControllerInfo(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthIn
77135 return controllerInfoResponse .Payload , nil
78136}
79137
80- // ////////
81- // Jobs //
82- // ////////
138+ // listJobs lists all the jobs configured in GARM.
83139func listJobs (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Jobs , error ) {
84140 listJobsResponse , err := apiCli .Jobs .ListJobs (
85141 clientJobs .NewListJobsParams (),
@@ -90,9 +146,7 @@ func listJobs(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter)
90146 return listJobsResponse .Payload , nil
91147}
92148
93- // //////////////////
94- // / Metrics Token //
95- // //////////////////
149+ // getMetricsToken returns the metrics token.
96150func getMetricsToken (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (string , error ) {
97151 getMetricsTokenResponse , err := apiCli .MetricsToken .GetMetricsToken (
98152 clientMetricsToken .NewGetMetricsTokenParams (),
0 commit comments