Skip to content

Commit

Permalink
Merge pull request #136 from mihaelabalutoiu/add-more-swagger-client-api
Browse files Browse the repository at this point in the history
Add more functionality to swagger client library
  • Loading branch information
gabriel-samfira authored Jul 18, 2023
2 parents 8089244 + 520f468 commit 91dd082
Show file tree
Hide file tree
Showing 11 changed files with 853 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apiserver/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ func (a *APIController) NotFoundHandler(w http.ResponseWriter, r *http.Request)
}
}

// swagger:route GET /metrics-token metrics-token MetricsToken
//
// Returns a JWT token that can be used to access the metrics endpoint.
//
// Responses:
// 200: JWTResponse
// 401: APIErrorResponse
func (a *APIController) MetricsTokenHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down Expand Up @@ -350,6 +357,13 @@ func (a *APIController) ListProviders(w http.ResponseWriter, r *http.Request) {
}
}

// swagger:route GET /jobs jobs ListJobs
//
// List all jobs.
//
// Responses:
// 200: Jobs
// 400: APIErrorResponse
func (a *APIController) ListAllJobs(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
jobs, err := a.r.ListAllJobs(ctx)
Expand Down
16 changes: 16 additions & 0 deletions apiserver/swagger-models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Jobs:
type: array
x-go-type:
type: Jobs
import:
package: github.com/cloudbase/garm/params
alias: garm_params
items:
$ref: '#/definitions/Job'
Job:
type: object
x-go-type:
type: Job
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Credentials:
type: array
x-go-type:
Expand Down
46 changes: 46 additions & 0 deletions apiserver/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: JWTResponse
Job:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Job
Jobs:
items:
$ref: '#/definitions/Job'
type: array
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Jobs
NewUserParams:
type: object
x-go-type:
Expand Down Expand Up @@ -291,6 +307,36 @@ paths:
summary: Get runner instance by name.
tags:
- instances
/jobs:
get:
operationId: ListJobs
responses:
"200":
description: Jobs
schema:
$ref: '#/definitions/Jobs'
"400":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List all jobs.
tags:
- jobs
/metrics-token:
get:
operationId: MetricsToken
responses:
"200":
description: JWTResponse
schema:
$ref: '#/definitions/JWTResponse'
"401":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Returns a JWT token that can be used to access the metrics endpoint.
tags:
- metrics-token
/organizations:
get:
operationId: ListOrgs
Expand Down
10 changes: 10 additions & 0 deletions client/garm_api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions client/jobs/jobs_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions client/jobs/list_jobs_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 91dd082

Please sign in to comment.