From 98e415bf11f2d0033e8274cd2f077b29b9edc381 Mon Sep 17 00:00:00 2001 From: Mihaela Balutoiu Date: Mon, 10 Jul 2023 17:16:17 +0300 Subject: [PATCH 1/2] Add more swagger annotations to `apiserver` Signed-off-by: Mihaela Balutoiu --- apiserver/controllers/controllers.go | 43 +++++++ apiserver/controllers/instances.go | 28 +++++ apiserver/controllers/organizations.go | 167 +++++++++++++++++++++++++ apiserver/controllers/pools.go | 54 ++++++++ apiserver/swagger-models.yaml | 91 +++++++++++++- params/params.go | 9 ++ 6 files changed, 390 insertions(+), 2 deletions(-) diff --git a/apiserver/controllers/controllers.go b/apiserver/controllers/controllers.go index a7257340..37da8f1a 100644 --- a/apiserver/controllers/controllers.go +++ b/apiserver/controllers/controllers.go @@ -222,6 +222,21 @@ func (a *APIController) MetricsTokenHandler(w http.ResponseWriter, r *http.Reque } } +// swagger:route POST /auth/login login Login +// +// Logs in a user and returns a JWT token. +// +// Parameters: +// + name: Body +// description: Login information. +// type: PasswordLoginParams +// in: body +// required: true +// +// Responses: +// 200: JWTResponse +// 400: APIErrorResponse +// // LoginHandler returns a jwt token func (a *APIController) LoginHandler(w http.ResponseWriter, r *http.Request) { var loginInfo runnerParams.PasswordLoginParams @@ -253,6 +268,20 @@ func (a *APIController) LoginHandler(w http.ResponseWriter, r *http.Request) { } } +// swagger:route POST /first-run first-run FirstRun +// +// Initialize the first run of the controller. +// +// Parameters: +// + name: Body +// description: Create a new user. +// type: NewUserParams +// in: body +// required: true +// +// Responses: +// 200: User +// 400: APIErrorResponse func (a *APIController) FirstRunHandler(w http.ResponseWriter, r *http.Request) { if a.auth.IsInitialized() { err := gErrors.NewConflictError("already initialized") @@ -279,6 +308,13 @@ func (a *APIController) FirstRunHandler(w http.ResponseWriter, r *http.Request) } } +// swagger:route GET /credentials credentials ListCredentials +// +// List all credentials. +// +// Responses: +// 200: Credentials +// 400: APIErrorResponse func (a *APIController) ListCredentials(w http.ResponseWriter, r *http.Request) { ctx := r.Context() creds, err := a.r.ListCredentials(ctx) @@ -293,6 +329,13 @@ func (a *APIController) ListCredentials(w http.ResponseWriter, r *http.Request) } } +// swagger:route GET /providers providers ListProviders +// +// List all providers. +// +// Responses: +// 200: Providers +// 400: APIErrorResponse func (a *APIController) ListProviders(w http.ResponseWriter, r *http.Request) { ctx := r.Context() providers, err := a.r.ListProviders(ctx) diff --git a/apiserver/controllers/instances.go b/apiserver/controllers/instances.go index c867c523..a9ea528e 100644 --- a/apiserver/controllers/instances.go +++ b/apiserver/controllers/instances.go @@ -26,6 +26,20 @@ import ( "github.com/gorilla/mux" ) +// swagger:route GET /pools/{poolID}/instances instances ListPoolInstances +// +// List runner instances in a pool. +// +// Parameters: +// + name: poolID +// description: Runner pool ID. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Instances +// default: APIErrorResponse func (a *APIController) ListPoolInstancesHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() vars := mux.Vars(r) @@ -176,6 +190,20 @@ func (a *APIController) ListRepoInstancesHandler(w http.ResponseWriter, r *http. } } +// swagger:route GET /organizations/{orgID}/instances organizations instances ListOrgInstances +// +// List organization instances. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Instances +// default: APIErrorResponse func (a *APIController) ListOrgInstancesHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() vars := mux.Vars(r) diff --git a/apiserver/controllers/organizations.go b/apiserver/controllers/organizations.go index 7cdb072b..ab0abb81 100644 --- a/apiserver/controllers/organizations.go +++ b/apiserver/controllers/organizations.go @@ -26,6 +26,20 @@ import ( "github.com/gorilla/mux" ) +// swagger:route POST /organizations organizations CreateOrg +// +// Create organization with the parameters given. +// +// Parameters: +// + name: Body +// description: Parameters used when creating the organization. +// type: CreateOrgParams +// in: body +// required: true +// +// Responses: +// 200: Organization +// default: APIErrorResponse func (a *APIController) CreateOrgHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -48,6 +62,13 @@ func (a *APIController) CreateOrgHandler(w http.ResponseWriter, r *http.Request) } } +// swagger:route GET /organizations organizations ListOrgs +// +// List organizations. +// +// Responses: +// 200: Organizations +// default: APIErrorResponse func (a *APIController) ListOrgsHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -64,6 +85,20 @@ func (a *APIController) ListOrgsHandler(w http.ResponseWriter, r *http.Request) } } +// swagger:route GET /organizations/{orgID} organizations GetOrg +// +// Get organization by ID. +// +// Parameters: +// + name: orgID +// description: ID of the organization to fetch. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Organization +// default: APIErrorResponse func (a *APIController) GetOrgByIDHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -93,6 +128,19 @@ func (a *APIController) GetOrgByIDHandler(w http.ResponseWriter, r *http.Request } } +// swagger:route DELETE /organizations/{orgID} organizations DeleteOrg +// +// Delete organization by ID. +// +// Parameters: +// + name: orgID +// description: ID of the organization to delete. +// type: string +// in: path +// required: true +// +// Responses: +// default: APIErrorResponse func (a *APIController) DeleteOrgHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -120,6 +168,26 @@ func (a *APIController) DeleteOrgHandler(w http.ResponseWriter, r *http.Request) } +// swagger:route PUT /organizations/{orgID} organizations UpdateOrg +// +// Update organization with the parameters given. +// +// Parameters: +// + name: orgID +// description: ID of the organization to update. +// type: string +// in: path +// required: true +// +// + name: Body +// description: Parameters used when updating the organization. +// type: UpdateEntityParams +// in: body +// required: true +// +// Responses: +// 200: Organization +// default: APIErrorResponse func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -155,6 +223,26 @@ func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request) } } +// swagger:route POST /organizations/{orgID}/pools organizations pools CreateOrgPool +// +// Create organization pool with the parameters given. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// + name: Body +// description: Parameters used when creating the organization pool. +// type: CreatePoolParams +// in: body +// required: true +// +// Responses: +// 200: Pool +// default: APIErrorResponse func (a *APIController) CreateOrgPoolHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -191,6 +279,20 @@ func (a *APIController) CreateOrgPoolHandler(w http.ResponseWriter, r *http.Requ } } +// swagger:route GET /organizations/{orgID}/pools organizations pools ListOrgPools +// +// List organization pools. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Pools +// default: APIErrorResponse func (a *APIController) ListOrgPoolsHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() vars := mux.Vars(r) @@ -219,6 +321,26 @@ func (a *APIController) ListOrgPoolsHandler(w http.ResponseWriter, r *http.Reque } } +// swagger:route GET /organizations/{orgID}/pools/{poolID} organizations pools GetOrgPool +// +// Get organization pool by ID. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// + name: poolID +// description: Pool ID. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Pool +// default: APIErrorResponse func (a *APIController) GetOrgPoolHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() vars := mux.Vars(r) @@ -248,6 +370,25 @@ func (a *APIController) GetOrgPoolHandler(w http.ResponseWriter, r *http.Request } } +// swagger:route DELETE /organizations/{orgID}/pools/{poolID} organizations pools DeleteOrgPool +// +// Delete organization pool by ID. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// + name: poolID +// description: ID of the organization pool to delete. +// type: string +// in: path +// required: true +// +// Responses: +// default: APIErrorResponse func (a *APIController) DeleteOrgPoolHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -276,6 +417,32 @@ func (a *APIController) DeleteOrgPoolHandler(w http.ResponseWriter, r *http.Requ } +// swagger:route PUT /organizations/{orgID}/pools/{poolID} organizations pools UpdateOrgPool +// +// Update organization pool with the parameters given. +// +// Parameters: +// + name: orgID +// description: Organization ID. +// type: string +// in: path +// required: true +// +// + name: poolID +// description: ID of the organization pool to update. +// type: string +// in: path +// required: true +// +// + name: Body +// description: Parameters used when updating the organization pool. +// type: UpdatePoolParams +// in: body +// required: true +// +// Responses: +// 200: Pool +// default: APIErrorResponse func (a *APIController) UpdateOrgPoolHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() diff --git a/apiserver/controllers/pools.go b/apiserver/controllers/pools.go index b4e5ffa2..8393bc10 100644 --- a/apiserver/controllers/pools.go +++ b/apiserver/controllers/pools.go @@ -26,6 +26,13 @@ import ( "github.com/gorilla/mux" ) +// swagger:route GET /pools pools ListPools +// +// List all pools. +// +// Responses: +// 200: Pools +// default: APIErrorResponse func (a *APIController) ListAllPoolsHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -43,6 +50,20 @@ func (a *APIController) ListAllPoolsHandler(w http.ResponseWriter, r *http.Reque } } +// swagger:route GET /pools/{poolID} pools GetPool +// +// Get pool by ID. +// +// Parameters: +// + name: poolID +// description: ID of the pool to fetch. +// type: string +// in: path +// required: true +// +// Responses: +// 200: Pool +// default: APIErrorResponse func (a *APIController) GetPoolByIDHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -74,6 +95,19 @@ func (a *APIController) GetPoolByIDHandler(w http.ResponseWriter, r *http.Reques } } +// swagger:route DELETE /pools/{poolID} pools DeletePool +// +// Delete pool by ID. +// +// Parameters: +// + name: poolID +// description: ID of the pool to delete. +// type: string +// in: path +// required: true +// +// Responses: +// default: APIErrorResponse func (a *APIController) DeletePoolByIDHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -100,6 +134,26 @@ func (a *APIController) DeletePoolByIDHandler(w http.ResponseWriter, r *http.Req w.WriteHeader(http.StatusOK) } +// swagger:route PUT /pools/{poolID} pools UpdatePool +// +// Update pool by ID. +// +// Parameters: +// + name: poolID +// description: ID of the pool to update. +// type: string +// in: path +// required: true +// +// + name: Body +// description: Parameters to update the pool with. +// type: UpdatePoolParams +// in: body +// required: true +// +// Responses: +// 200: Pool +// default: APIErrorResponse func (a *APIController) UpdatePoolByIDHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() diff --git a/apiserver/swagger-models.yaml b/apiserver/swagger-models.yaml index 9565aff5..d64ce0c7 100644 --- a/apiserver/swagger-models.yaml +++ b/apiserver/swagger-models.yaml @@ -1,13 +1,75 @@ # NOTE: The purpose of these definitions is to reuse the existing golang # types from GARM packages. definitions: - Instances: + User: + type: object + x-go-type: + type: User + import: + package: github.com/cloudbase/garm/params + alias: garm_params + NewUserParams: + type: object + x-go-type: + type: NewUserParams + import: + package: github.com/cloudbase/garm/params + alias: garm_params + PasswordLoginParams: + type: object + x-go-type: + type: PasswordLoginParams + import: + package: github.com/cloudbase/garm/params + alias: garm_params + JWTResponse: + type: object + x-go-type: + type: JWTResponse + import: + package: github.com/cloudbase/garm/params + alias: garm_params + Credentials: + type: array + x-go-type: + type: Credentials + import: + package: github.com/cloudbase/garm/params + alias: garm_params + items: + $ref: '#/definitions/GithubCredentials' + GithubCredentials: + type: object + x-go-type: + type: GithubCredentials + import: + package: github.com/cloudbase/garm/params + alias: garm_params + Providers: + type: array + x-go-type: + type: Providers + import: + package: github.com/cloudbase/garm/params + alias: garm_params + items: + $ref: '#/definitions/Provider' + Provider: type: object + x-go-type: + type: Provider + import: + package: github.com/cloudbase/garm/params + alias: garm_params + Instances: + type: array x-go-type: type: Instances import: package: github.com/cloudbase/garm/params alias: garm_params + items: + $ref: '#/definitions/Instance' Instance: type: object x-go-type: @@ -16,12 +78,14 @@ definitions: package: github.com/cloudbase/garm/params alias: garm_params Pools: - type: object + type: array x-go-type: type: Pools import: package: github.com/cloudbase/garm/params alias: garm_params + items: + $ref: '#/definitions/Pool' Pool: type: object x-go-type: @@ -52,6 +116,29 @@ definitions: import: package: github.com/cloudbase/garm/params alias: garm_params + Organizations: + type: array + x-go-type: + type: Organizations + import: + package: github.com/cloudbase/garm/params + alias: garm_params + items: + $ref: '#/definitions/Organization' + Organization: + type: object + x-go-type: + type: Organization + import: + package: github.com/cloudbase/garm/params + alias: garm_params + CreateOrgParams: + type: object + x-go-type: + type: CreateOrgParams + import: + package: github.com/cloudbase/garm/params + alias: garm_params UpdateEntityParams: type: object x-go-type: diff --git a/params/params.go b/params/params.go index bb84b8d9..4749c0a2 100644 --- a/params/params.go +++ b/params/params.go @@ -350,6 +350,9 @@ func (o Organization) GetID() string { return o.ID } +// used by swagger client generated code +type Organizations []Organization + type Enterprise struct { ID string `json:"id"` Name string `json:"name"` @@ -401,12 +404,18 @@ type GithubCredentials struct { CABundle []byte `json:"ca_bundle,omitempty"` } +// used by swagger client generated code +type Credentials []GithubCredentials + type Provider struct { Name string `json:"name"` ProviderType ProviderType `json:"type"` Description string `json:"description"` } +// used by swagger client generated code +type Providers []Provider + type UpdatePoolStateParams struct { WebhookSecret string InternalConfig *Internal From db21fb6ea9f9e4eeafa65b2b6e1775c29343a254 Mon Sep 17 00:00:00 2001 From: Mihaela Balutoiu Date: Mon, 10 Jul 2023 17:30:59 +0300 Subject: [PATCH 2/2] Update generated swagger client code Signed-off-by: Mihaela Balutoiu --- apiserver/swagger.yaml | 529 +++++++++++++++++- client/credentials/credentials_client.go | 80 +++ .../list_credentials_parameters.go | 128 +++++ .../credentials/list_credentials_responses.go | 174 ++++++ client/first_run/first_run_client.go | 80 +++ client/first_run/first_run_parameters.go | 151 +++++ client/first_run/first_run_responses.go | 174 ++++++ client/garm_api_client.go | 30 + client/instances/instances_client.go | 40 ++ .../list_pool_instances_parameters.go | 151 +++++ .../list_pool_instances_responses.go | 179 ++++++ client/login/login_client.go | 80 +++ client/login/login_parameters.go | 151 +++++ client/login/login_responses.go | 174 ++++++ client/organizations/create_org_parameters.go | 151 +++++ .../create_org_pool_parameters.go | 173 ++++++ .../create_org_pool_responses.go | 179 ++++++ client/organizations/create_org_responses.go | 179 ++++++ client/organizations/delete_org_parameters.go | 151 +++++ .../delete_org_pool_parameters.go | 173 ++++++ .../delete_org_pool_responses.go | 103 ++++ client/organizations/delete_org_responses.go | 103 ++++ client/organizations/get_org_parameters.go | 151 +++++ .../organizations/get_org_pool_parameters.go | 173 ++++++ .../organizations/get_org_pool_responses.go | 179 ++++++ client/organizations/get_org_responses.go | 179 ++++++ .../list_org_instances_parameters.go | 151 +++++ .../list_org_instances_responses.go | 179 ++++++ .../list_org_pools_parameters.go | 151 +++++ .../organizations/list_org_pools_responses.go | 179 ++++++ client/organizations/list_orgs_parameters.go | 128 +++++ client/organizations/list_orgs_responses.go | 179 ++++++ client/organizations/organizations_client.go | 465 +++++++++++++++ client/organizations/update_org_parameters.go | 173 ++++++ .../update_org_pool_parameters.go | 195 +++++++ .../update_org_pool_responses.go | 179 ++++++ client/organizations/update_org_responses.go | 179 ++++++ client/pools/delete_pool_parameters.go | 151 +++++ client/pools/delete_pool_responses.go | 103 ++++ client/pools/get_pool_parameters.go | 151 +++++ client/pools/get_pool_responses.go | 179 ++++++ client/pools/list_pools_parameters.go | 128 +++++ client/pools/list_pools_responses.go | 179 ++++++ client/pools/pools_client.go | 191 +++++++ client/pools/update_pool_parameters.go | 173 ++++++ client/pools/update_pool_responses.go | 179 ++++++ client/providers/list_providers_parameters.go | 128 +++++ client/providers/list_providers_responses.go | 174 ++++++ client/providers/providers_client.go | 80 +++ 49 files changed, 7987 insertions(+), 2 deletions(-) create mode 100644 client/credentials/credentials_client.go create mode 100644 client/credentials/list_credentials_parameters.go create mode 100644 client/credentials/list_credentials_responses.go create mode 100644 client/first_run/first_run_client.go create mode 100644 client/first_run/first_run_parameters.go create mode 100644 client/first_run/first_run_responses.go create mode 100644 client/instances/list_pool_instances_parameters.go create mode 100644 client/instances/list_pool_instances_responses.go create mode 100644 client/login/login_client.go create mode 100644 client/login/login_parameters.go create mode 100644 client/login/login_responses.go create mode 100644 client/organizations/create_org_parameters.go create mode 100644 client/organizations/create_org_pool_parameters.go create mode 100644 client/organizations/create_org_pool_responses.go create mode 100644 client/organizations/create_org_responses.go create mode 100644 client/organizations/delete_org_parameters.go create mode 100644 client/organizations/delete_org_pool_parameters.go create mode 100644 client/organizations/delete_org_pool_responses.go create mode 100644 client/organizations/delete_org_responses.go create mode 100644 client/organizations/get_org_parameters.go create mode 100644 client/organizations/get_org_pool_parameters.go create mode 100644 client/organizations/get_org_pool_responses.go create mode 100644 client/organizations/get_org_responses.go create mode 100644 client/organizations/list_org_instances_parameters.go create mode 100644 client/organizations/list_org_instances_responses.go create mode 100644 client/organizations/list_org_pools_parameters.go create mode 100644 client/organizations/list_org_pools_responses.go create mode 100644 client/organizations/list_orgs_parameters.go create mode 100644 client/organizations/list_orgs_responses.go create mode 100644 client/organizations/organizations_client.go create mode 100644 client/organizations/update_org_parameters.go create mode 100644 client/organizations/update_org_pool_parameters.go create mode 100644 client/organizations/update_org_pool_responses.go create mode 100644 client/organizations/update_org_responses.go create mode 100644 client/pools/delete_pool_parameters.go create mode 100644 client/pools/delete_pool_responses.go create mode 100644 client/pools/get_pool_parameters.go create mode 100644 client/pools/get_pool_responses.go create mode 100644 client/pools/list_pools_parameters.go create mode 100644 client/pools/list_pools_responses.go create mode 100644 client/pools/pools_client.go create mode 100644 client/pools/update_pool_parameters.go create mode 100644 client/pools/update_pool_responses.go create mode 100644 client/providers/list_providers_parameters.go create mode 100644 client/providers/list_providers_responses.go create mode 100644 client/providers/providers_client.go diff --git a/apiserver/swagger.yaml b/apiserver/swagger.yaml index acf2a42b..dfb55a71 100644 --- a/apiserver/swagger.yaml +++ b/apiserver/swagger.yaml @@ -9,6 +9,13 @@ definitions: alias: apiserver_params package: github.com/cloudbase/garm/apiserver/params type: APIErrorResponse + CreateOrgParams: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: CreateOrgParams CreatePoolParams: type: object x-go-type: @@ -23,6 +30,22 @@ definitions: alias: garm_params package: github.com/cloudbase/garm/params type: CreateRepoParams + Credentials: + items: + $ref: '#/definitions/GithubCredentials' + type: array + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: Credentials + GithubCredentials: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: GithubCredentials Instance: type: object x-go-type: @@ -31,12 +54,51 @@ definitions: package: github.com/cloudbase/garm/params type: Instance Instances: - type: object + items: + $ref: '#/definitions/Instance' + type: array x-go-type: import: alias: garm_params package: github.com/cloudbase/garm/params type: Instances + JWTResponse: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: JWTResponse + NewUserParams: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: NewUserParams + Organization: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: Organization + Organizations: + items: + $ref: '#/definitions/Organization' + type: array + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: Organizations + PasswordLoginParams: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: PasswordLoginParams Pool: type: object x-go-type: @@ -45,12 +107,30 @@ definitions: package: github.com/cloudbase/garm/params type: Pool Pools: - type: object + items: + $ref: '#/definitions/Pool' + type: array x-go-type: import: alias: garm_params package: github.com/cloudbase/garm/params type: Pools + Provider: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: Provider + Providers: + items: + $ref: '#/definitions/Provider' + type: array + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: Providers Repositories: items: $ref: '#/definitions/Repository' @@ -81,6 +161,13 @@ definitions: alias: garm_params package: github.com/cloudbase/garm/params type: UpdatePoolParams + User: + type: object + x-go-type: + import: + alias: garm_params + package: github.com/cloudbase/garm/params + type: User info: description: The Garm API generated using go-swagger. license: @@ -89,6 +176,69 @@ info: title: Garm API. version: 1.0.0 paths: + /auth/login: + post: + operationId: Login + parameters: + - description: Login information. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/PasswordLoginParams' + description: Login information. + type: object + responses: + "200": + description: JWTResponse + schema: + $ref: '#/definitions/JWTResponse' + "400": + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Logs in a user and returns a JWT token. + tags: + - login + /credentials: + get: + operationId: ListCredentials + responses: + "200": + description: Credentials + schema: + $ref: '#/definitions/Credentials' + "400": + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List all credentials. + tags: + - credentials + /first-run: + post: + operationId: FirstRun + parameters: + - description: Create a new user. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/NewUserParams' + description: Create a new user. + type: object + responses: + "200": + description: User + schema: + $ref: '#/definitions/User' + "400": + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Initialize the first run of the controller. + tags: + - first-run /instances: get: operationId: ListInstances @@ -141,6 +291,381 @@ paths: summary: Get runner instance by name. tags: - instances + /organizations: + get: + operationId: ListOrgs + responses: + "200": + description: Organizations + schema: + $ref: '#/definitions/Organizations' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List organizations. + tags: + - organizations + post: + operationId: CreateOrg + parameters: + - description: Parameters used when creating the organization. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/CreateOrgParams' + description: Parameters used when creating the organization. + type: object + responses: + "200": + description: Organization + schema: + $ref: '#/definitions/Organization' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Create organization with the parameters given. + tags: + - organizations + /organizations/{orgID}: + delete: + operationId: DeleteOrg + parameters: + - description: ID of the organization to delete. + in: path + name: orgID + required: true + type: string + responses: + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Delete organization by ID. + tags: + - organizations + get: + operationId: GetOrg + parameters: + - description: ID of the organization to fetch. + in: path + name: orgID + required: true + type: string + responses: + "200": + description: Organization + schema: + $ref: '#/definitions/Organization' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Get organization by ID. + tags: + - organizations + put: + operationId: UpdateOrg + parameters: + - description: ID of the organization to update. + in: path + name: orgID + required: true + type: string + - description: Parameters used when updating the organization. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/UpdateEntityParams' + description: Parameters used when updating the organization. + type: object + responses: + "200": + description: Organization + schema: + $ref: '#/definitions/Organization' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Update organization with the parameters given. + tags: + - organizations + /organizations/{orgID}/instances: + get: + operationId: ListOrgInstances + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + responses: + "200": + description: Instances + schema: + $ref: '#/definitions/Instances' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List organization instances. + tags: + - organizations + - instances + /organizations/{orgID}/pools: + get: + operationId: ListOrgPools + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + responses: + "200": + description: Pools + schema: + $ref: '#/definitions/Pools' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List organization pools. + tags: + - organizations + - pools + post: + operationId: CreateOrgPool + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + - description: Parameters used when creating the organization pool. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/CreatePoolParams' + description: Parameters used when creating the organization pool. + type: object + responses: + "200": + description: Pool + schema: + $ref: '#/definitions/Pool' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Create organization pool with the parameters given. + tags: + - organizations + - pools + /organizations/{orgID}/pools/{poolID}: + delete: + operationId: DeleteOrgPool + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + - description: ID of the organization pool to delete. + in: path + name: poolID + required: true + type: string + responses: + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Delete organization pool by ID. + tags: + - organizations + - pools + get: + operationId: GetOrgPool + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + - description: Pool ID. + in: path + name: poolID + required: true + type: string + responses: + "200": + description: Pool + schema: + $ref: '#/definitions/Pool' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Get organization pool by ID. + tags: + - organizations + - pools + put: + operationId: UpdateOrgPool + parameters: + - description: Organization ID. + in: path + name: orgID + required: true + type: string + - description: ID of the organization pool to update. + in: path + name: poolID + required: true + type: string + - description: Parameters used when updating the organization pool. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/UpdatePoolParams' + description: Parameters used when updating the organization pool. + type: object + responses: + "200": + description: Pool + schema: + $ref: '#/definitions/Pool' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Update organization pool with the parameters given. + tags: + - organizations + - pools + /pools: + get: + operationId: ListPools + responses: + "200": + description: Pools + schema: + $ref: '#/definitions/Pools' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List all pools. + tags: + - pools + /pools/{poolID}: + delete: + operationId: DeletePool + parameters: + - description: ID of the pool to delete. + in: path + name: poolID + required: true + type: string + responses: + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Delete pool by ID. + tags: + - pools + get: + operationId: GetPool + parameters: + - description: ID of the pool to fetch. + in: path + name: poolID + required: true + type: string + responses: + "200": + description: Pool + schema: + $ref: '#/definitions/Pool' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Get pool by ID. + tags: + - pools + put: + operationId: UpdatePool + parameters: + - description: ID of the pool to update. + in: path + name: poolID + required: true + type: string + - description: Parameters to update the pool with. + in: body + name: Body + required: true + schema: + $ref: '#/definitions/UpdatePoolParams' + description: Parameters to update the pool with. + type: object + responses: + "200": + description: Pool + schema: + $ref: '#/definitions/Pool' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: Update pool by ID. + tags: + - pools + /pools/{poolID}/instances: + get: + operationId: ListPoolInstances + parameters: + - description: Runner pool ID. + in: path + name: poolID + required: true + type: string + responses: + "200": + description: Instances + schema: + $ref: '#/definitions/Instances' + default: + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List runner instances in a pool. + tags: + - instances + /providers: + get: + operationId: ListProviders + responses: + "200": + description: Providers + schema: + $ref: '#/definitions/Providers' + "400": + description: APIErrorResponse + schema: + $ref: '#/definitions/APIErrorResponse' + summary: List all providers. + tags: + - providers /repositories: get: operationId: ListRepos diff --git a/client/credentials/credentials_client.go b/client/credentials/credentials_client.go new file mode 100644 index 00000000..226b702d --- /dev/null +++ b/client/credentials/credentials_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package credentials + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new credentials API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for credentials API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListCredentialsOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +ListCredentials lists all credentials +*/ +func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListCredentialsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListCredentialsParams() + } + op := &runtime.ClientOperation{ + ID: "ListCredentials", + Method: "GET", + PathPattern: "/credentials", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListCredentialsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListCredentialsOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for ListCredentials: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/credentials/list_credentials_parameters.go b/client/credentials/list_credentials_parameters.go new file mode 100644 index 00000000..fdf839d7 --- /dev/null +++ b/client/credentials/list_credentials_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package credentials + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListCredentialsParams creates a new ListCredentialsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListCredentialsParams() *ListCredentialsParams { + return &ListCredentialsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListCredentialsParamsWithTimeout creates a new ListCredentialsParams object +// with the ability to set a timeout on a request. +func NewListCredentialsParamsWithTimeout(timeout time.Duration) *ListCredentialsParams { + return &ListCredentialsParams{ + timeout: timeout, + } +} + +// NewListCredentialsParamsWithContext creates a new ListCredentialsParams object +// with the ability to set a context for a request. +func NewListCredentialsParamsWithContext(ctx context.Context) *ListCredentialsParams { + return &ListCredentialsParams{ + Context: ctx, + } +} + +// NewListCredentialsParamsWithHTTPClient creates a new ListCredentialsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListCredentialsParamsWithHTTPClient(client *http.Client) *ListCredentialsParams { + return &ListCredentialsParams{ + HTTPClient: client, + } +} + +/* +ListCredentialsParams contains all the parameters to send to the API endpoint + + for the list credentials operation. + + Typically these are written to a http.Request. +*/ +type ListCredentialsParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list credentials params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListCredentialsParams) WithDefaults() *ListCredentialsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list credentials params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListCredentialsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list credentials params +func (o *ListCredentialsParams) WithTimeout(timeout time.Duration) *ListCredentialsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list credentials params +func (o *ListCredentialsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list credentials params +func (o *ListCredentialsParams) WithContext(ctx context.Context) *ListCredentialsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list credentials params +func (o *ListCredentialsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list credentials params +func (o *ListCredentialsParams) WithHTTPClient(client *http.Client) *ListCredentialsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list credentials params +func (o *ListCredentialsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/credentials/list_credentials_responses.go b/client/credentials/list_credentials_responses.go new file mode 100644 index 00000000..2d4c2f9a --- /dev/null +++ b/client/credentials/list_credentials_responses.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package credentials + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListCredentialsReader is a Reader for the ListCredentials structure. +type ListCredentialsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListCredentialsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListCredentialsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /credentials] ListCredentials", response, response.Code()) + } +} + +// NewListCredentialsOK creates a ListCredentialsOK with default headers values +func NewListCredentialsOK() *ListCredentialsOK { + return &ListCredentialsOK{} +} + +/* +ListCredentialsOK describes a response with status code 200, with default header values. + +Credentials +*/ +type ListCredentialsOK struct { + Payload garm_params.Credentials +} + +// IsSuccess returns true when this list credentials o k response has a 2xx status code +func (o *ListCredentialsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list credentials o k response has a 3xx status code +func (o *ListCredentialsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list credentials o k response has a 4xx status code +func (o *ListCredentialsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list credentials o k response has a 5xx status code +func (o *ListCredentialsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list credentials o k response a status code equal to that given +func (o *ListCredentialsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list credentials o k response +func (o *ListCredentialsOK) Code() int { + return 200 +} + +func (o *ListCredentialsOK) Error() string { + return fmt.Sprintf("[GET /credentials][%d] listCredentialsOK %+v", 200, o.Payload) +} + +func (o *ListCredentialsOK) String() string { + return fmt.Sprintf("[GET /credentials][%d] listCredentialsOK %+v", 200, o.Payload) +} + +func (o *ListCredentialsOK) GetPayload() garm_params.Credentials { + return o.Payload +} + +func (o *ListCredentialsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListCredentialsBadRequest creates a ListCredentialsBadRequest with default headers values +func NewListCredentialsBadRequest() *ListCredentialsBadRequest { + return &ListCredentialsBadRequest{} +} + +/* +ListCredentialsBadRequest describes a response with status code 400, with default header values. + +APIErrorResponse +*/ +type ListCredentialsBadRequest struct { + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list credentials bad request response has a 2xx status code +func (o *ListCredentialsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list credentials bad request response has a 3xx status code +func (o *ListCredentialsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list credentials bad request response has a 4xx status code +func (o *ListCredentialsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list credentials bad request response has a 5xx status code +func (o *ListCredentialsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list credentials bad request response a status code equal to that given +func (o *ListCredentialsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list credentials bad request response +func (o *ListCredentialsBadRequest) Code() int { + return 400 +} + +func (o *ListCredentialsBadRequest) Error() string { + return fmt.Sprintf("[GET /credentials][%d] listCredentialsBadRequest %+v", 400, o.Payload) +} + +func (o *ListCredentialsBadRequest) String() string { + return fmt.Sprintf("[GET /credentials][%d] listCredentialsBadRequest %+v", 400, o.Payload) +} + +func (o *ListCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListCredentialsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/first_run/first_run_client.go b/client/first_run/first_run_client.go new file mode 100644 index 00000000..9066a56e --- /dev/null +++ b/client/first_run/first_run_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package first_run + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new first run API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for first run API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + FirstRun(params *FirstRunParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*FirstRunOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +FirstRun initializes the first run of the controller +*/ +func (a *Client) FirstRun(params *FirstRunParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*FirstRunOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewFirstRunParams() + } + op := &runtime.ClientOperation{ + ID: "FirstRun", + Method: "POST", + PathPattern: "/first-run", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &FirstRunReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*FirstRunOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for FirstRun: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/first_run/first_run_parameters.go b/client/first_run/first_run_parameters.go new file mode 100644 index 00000000..5d3b91fd --- /dev/null +++ b/client/first_run/first_run_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package first_run + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewFirstRunParams creates a new FirstRunParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewFirstRunParams() *FirstRunParams { + return &FirstRunParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewFirstRunParamsWithTimeout creates a new FirstRunParams object +// with the ability to set a timeout on a request. +func NewFirstRunParamsWithTimeout(timeout time.Duration) *FirstRunParams { + return &FirstRunParams{ + timeout: timeout, + } +} + +// NewFirstRunParamsWithContext creates a new FirstRunParams object +// with the ability to set a context for a request. +func NewFirstRunParamsWithContext(ctx context.Context) *FirstRunParams { + return &FirstRunParams{ + Context: ctx, + } +} + +// NewFirstRunParamsWithHTTPClient creates a new FirstRunParams object +// with the ability to set a custom HTTPClient for a request. +func NewFirstRunParamsWithHTTPClient(client *http.Client) *FirstRunParams { + return &FirstRunParams{ + HTTPClient: client, + } +} + +/* +FirstRunParams contains all the parameters to send to the API endpoint + + for the first run operation. + + Typically these are written to a http.Request. +*/ +type FirstRunParams struct { + + /* Body. + + Create a new user. + */ + Body garm_params.NewUserParams + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the first run params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *FirstRunParams) WithDefaults() *FirstRunParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the first run params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *FirstRunParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the first run params +func (o *FirstRunParams) WithTimeout(timeout time.Duration) *FirstRunParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the first run params +func (o *FirstRunParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the first run params +func (o *FirstRunParams) WithContext(ctx context.Context) *FirstRunParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the first run params +func (o *FirstRunParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the first run params +func (o *FirstRunParams) WithHTTPClient(client *http.Client) *FirstRunParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the first run params +func (o *FirstRunParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the first run params +func (o *FirstRunParams) WithBody(body garm_params.NewUserParams) *FirstRunParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the first run params +func (o *FirstRunParams) SetBody(body garm_params.NewUserParams) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *FirstRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/first_run/first_run_responses.go b/client/first_run/first_run_responses.go new file mode 100644 index 00000000..9057d7ee --- /dev/null +++ b/client/first_run/first_run_responses.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package first_run + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// FirstRunReader is a Reader for the FirstRun structure. +type FirstRunReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *FirstRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewFirstRunOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewFirstRunBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /first-run] FirstRun", response, response.Code()) + } +} + +// NewFirstRunOK creates a FirstRunOK with default headers values +func NewFirstRunOK() *FirstRunOK { + return &FirstRunOK{} +} + +/* +FirstRunOK describes a response with status code 200, with default header values. + +User +*/ +type FirstRunOK struct { + Payload garm_params.User +} + +// IsSuccess returns true when this first run o k response has a 2xx status code +func (o *FirstRunOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this first run o k response has a 3xx status code +func (o *FirstRunOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this first run o k response has a 4xx status code +func (o *FirstRunOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this first run o k response has a 5xx status code +func (o *FirstRunOK) IsServerError() bool { + return false +} + +// IsCode returns true when this first run o k response a status code equal to that given +func (o *FirstRunOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the first run o k response +func (o *FirstRunOK) Code() int { + return 200 +} + +func (o *FirstRunOK) Error() string { + return fmt.Sprintf("[POST /first-run][%d] firstRunOK %+v", 200, o.Payload) +} + +func (o *FirstRunOK) String() string { + return fmt.Sprintf("[POST /first-run][%d] firstRunOK %+v", 200, o.Payload) +} + +func (o *FirstRunOK) GetPayload() garm_params.User { + return o.Payload +} + +func (o *FirstRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewFirstRunBadRequest creates a FirstRunBadRequest with default headers values +func NewFirstRunBadRequest() *FirstRunBadRequest { + return &FirstRunBadRequest{} +} + +/* +FirstRunBadRequest describes a response with status code 400, with default header values. + +APIErrorResponse +*/ +type FirstRunBadRequest struct { + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this first run bad request response has a 2xx status code +func (o *FirstRunBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this first run bad request response has a 3xx status code +func (o *FirstRunBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this first run bad request response has a 4xx status code +func (o *FirstRunBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this first run bad request response has a 5xx status code +func (o *FirstRunBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this first run bad request response a status code equal to that given +func (o *FirstRunBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the first run bad request response +func (o *FirstRunBadRequest) Code() int { + return 400 +} + +func (o *FirstRunBadRequest) Error() string { + return fmt.Sprintf("[POST /first-run][%d] firstRunBadRequest %+v", 400, o.Payload) +} + +func (o *FirstRunBadRequest) String() string { + return fmt.Sprintf("[POST /first-run][%d] firstRunBadRequest %+v", 400, o.Payload) +} + +func (o *FirstRunBadRequest) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *FirstRunBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/garm_api_client.go b/client/garm_api_client.go index eec535d5..d4780de0 100644 --- a/client/garm_api_client.go +++ b/client/garm_api_client.go @@ -10,7 +10,13 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/cloudbase/garm/client/credentials" + "github.com/cloudbase/garm/client/first_run" "github.com/cloudbase/garm/client/instances" + "github.com/cloudbase/garm/client/login" + "github.com/cloudbase/garm/client/organizations" + "github.com/cloudbase/garm/client/pools" + "github.com/cloudbase/garm/client/providers" "github.com/cloudbase/garm/client/repositories" ) @@ -56,7 +62,13 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *GarmAPI { cli := new(GarmAPI) cli.Transport = transport + cli.Credentials = credentials.New(transport, formats) + cli.FirstRun = first_run.New(transport, formats) cli.Instances = instances.New(transport, formats) + cli.Login = login.New(transport, formats) + cli.Organizations = organizations.New(transport, formats) + cli.Pools = pools.New(transport, formats) + cli.Providers = providers.New(transport, formats) cli.Repositories = repositories.New(transport, formats) return cli } @@ -102,8 +114,20 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { // GarmAPI is a client for garm API type GarmAPI struct { + Credentials credentials.ClientService + + FirstRun first_run.ClientService + Instances instances.ClientService + Login login.ClientService + + Organizations organizations.ClientService + + Pools pools.ClientService + + Providers providers.ClientService + Repositories repositories.ClientService Transport runtime.ClientTransport @@ -112,6 +136,12 @@ type GarmAPI struct { // SetTransport changes the transport on the client and all its subresources func (c *GarmAPI) SetTransport(transport runtime.ClientTransport) { c.Transport = transport + c.Credentials.SetTransport(transport) + c.FirstRun.SetTransport(transport) c.Instances.SetTransport(transport) + c.Login.SetTransport(transport) + c.Organizations.SetTransport(transport) + c.Pools.SetTransport(transport) + c.Providers.SetTransport(transport) c.Repositories.SetTransport(transport) } diff --git a/client/instances/instances_client.go b/client/instances/instances_client.go index 44fd4dd2..fae1d7da 100644 --- a/client/instances/instances_client.go +++ b/client/instances/instances_client.go @@ -34,6 +34,8 @@ type ClientService interface { ListInstances(params *ListInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListInstancesOK, error) + ListPoolInstances(params *ListPoolInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPoolInstancesOK, error) + SetTransport(transport runtime.ClientTransport) } @@ -145,6 +147,44 @@ func (a *Client) ListInstances(params *ListInstancesParams, authInfo runtime.Cli return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +ListPoolInstances lists runner instances in a pool +*/ +func (a *Client) ListPoolInstances(params *ListPoolInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPoolInstancesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListPoolInstancesParams() + } + op := &runtime.ClientOperation{ + ID: "ListPoolInstances", + Method: "GET", + PathPattern: "/pools/{poolID}/instances", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListPoolInstancesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListPoolInstancesOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListPoolInstancesDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/client/instances/list_pool_instances_parameters.go b/client/instances/list_pool_instances_parameters.go new file mode 100644 index 00000000..622010de --- /dev/null +++ b/client/instances/list_pool_instances_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListPoolInstancesParams creates a new ListPoolInstancesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListPoolInstancesParams() *ListPoolInstancesParams { + return &ListPoolInstancesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListPoolInstancesParamsWithTimeout creates a new ListPoolInstancesParams object +// with the ability to set a timeout on a request. +func NewListPoolInstancesParamsWithTimeout(timeout time.Duration) *ListPoolInstancesParams { + return &ListPoolInstancesParams{ + timeout: timeout, + } +} + +// NewListPoolInstancesParamsWithContext creates a new ListPoolInstancesParams object +// with the ability to set a context for a request. +func NewListPoolInstancesParamsWithContext(ctx context.Context) *ListPoolInstancesParams { + return &ListPoolInstancesParams{ + Context: ctx, + } +} + +// NewListPoolInstancesParamsWithHTTPClient creates a new ListPoolInstancesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListPoolInstancesParamsWithHTTPClient(client *http.Client) *ListPoolInstancesParams { + return &ListPoolInstancesParams{ + HTTPClient: client, + } +} + +/* +ListPoolInstancesParams contains all the parameters to send to the API endpoint + + for the list pool instances operation. + + Typically these are written to a http.Request. +*/ +type ListPoolInstancesParams struct { + + /* PoolID. + + Runner pool ID. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list pool instances params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPoolInstancesParams) WithDefaults() *ListPoolInstancesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list pool instances params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPoolInstancesParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list pool instances params +func (o *ListPoolInstancesParams) WithTimeout(timeout time.Duration) *ListPoolInstancesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list pool instances params +func (o *ListPoolInstancesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list pool instances params +func (o *ListPoolInstancesParams) WithContext(ctx context.Context) *ListPoolInstancesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list pool instances params +func (o *ListPoolInstancesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list pool instances params +func (o *ListPoolInstancesParams) WithHTTPClient(client *http.Client) *ListPoolInstancesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list pool instances params +func (o *ListPoolInstancesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithPoolID adds the poolID to the list pool instances params +func (o *ListPoolInstancesParams) WithPoolID(poolID string) *ListPoolInstancesParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the list pool instances params +func (o *ListPoolInstancesParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListPoolInstancesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/instances/list_pool_instances_responses.go b/client/instances/list_pool_instances_responses.go new file mode 100644 index 00000000..2a61ca06 --- /dev/null +++ b/client/instances/list_pool_instances_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListPoolInstancesReader is a Reader for the ListPoolInstances structure. +type ListPoolInstancesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListPoolInstancesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListPoolInstancesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListPoolInstancesDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListPoolInstancesOK creates a ListPoolInstancesOK with default headers values +func NewListPoolInstancesOK() *ListPoolInstancesOK { + return &ListPoolInstancesOK{} +} + +/* +ListPoolInstancesOK describes a response with status code 200, with default header values. + +Instances +*/ +type ListPoolInstancesOK struct { + Payload garm_params.Instances +} + +// IsSuccess returns true when this list pool instances o k response has a 2xx status code +func (o *ListPoolInstancesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list pool instances o k response has a 3xx status code +func (o *ListPoolInstancesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list pool instances o k response has a 4xx status code +func (o *ListPoolInstancesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list pool instances o k response has a 5xx status code +func (o *ListPoolInstancesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list pool instances o k response a status code equal to that given +func (o *ListPoolInstancesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list pool instances o k response +func (o *ListPoolInstancesOK) Code() int { + return 200 +} + +func (o *ListPoolInstancesOK) Error() string { + return fmt.Sprintf("[GET /pools/{poolID}/instances][%d] listPoolInstancesOK %+v", 200, o.Payload) +} + +func (o *ListPoolInstancesOK) String() string { + return fmt.Sprintf("[GET /pools/{poolID}/instances][%d] listPoolInstancesOK %+v", 200, o.Payload) +} + +func (o *ListPoolInstancesOK) GetPayload() garm_params.Instances { + return o.Payload +} + +func (o *ListPoolInstancesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListPoolInstancesDefault creates a ListPoolInstancesDefault with default headers values +func NewListPoolInstancesDefault(code int) *ListPoolInstancesDefault { + return &ListPoolInstancesDefault{ + _statusCode: code, + } +} + +/* +ListPoolInstancesDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type ListPoolInstancesDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list pool instances default response has a 2xx status code +func (o *ListPoolInstancesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list pool instances default response has a 3xx status code +func (o *ListPoolInstancesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list pool instances default response has a 4xx status code +func (o *ListPoolInstancesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list pool instances default response has a 5xx status code +func (o *ListPoolInstancesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list pool instances default response a status code equal to that given +func (o *ListPoolInstancesDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list pool instances default response +func (o *ListPoolInstancesDefault) Code() int { + return o._statusCode +} + +func (o *ListPoolInstancesDefault) Error() string { + return fmt.Sprintf("[GET /pools/{poolID}/instances][%d] ListPoolInstances default %+v", o._statusCode, o.Payload) +} + +func (o *ListPoolInstancesDefault) String() string { + return fmt.Sprintf("[GET /pools/{poolID}/instances][%d] ListPoolInstances default %+v", o._statusCode, o.Payload) +} + +func (o *ListPoolInstancesDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListPoolInstancesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/login/login_client.go b/client/login/login_client.go new file mode 100644 index 00000000..d976042d --- /dev/null +++ b/client/login/login_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package login + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new login API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for login API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + Login(params *LoginParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*LoginOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +Login logs in a user and returns a j w t token +*/ +func (a *Client) Login(params *LoginParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*LoginOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewLoginParams() + } + op := &runtime.ClientOperation{ + ID: "Login", + Method: "POST", + PathPattern: "/auth/login", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &LoginReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*LoginOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Login: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/login/login_parameters.go b/client/login/login_parameters.go new file mode 100644 index 00000000..02ea77bc --- /dev/null +++ b/client/login/login_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package login + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewLoginParams creates a new LoginParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewLoginParams() *LoginParams { + return &LoginParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewLoginParamsWithTimeout creates a new LoginParams object +// with the ability to set a timeout on a request. +func NewLoginParamsWithTimeout(timeout time.Duration) *LoginParams { + return &LoginParams{ + timeout: timeout, + } +} + +// NewLoginParamsWithContext creates a new LoginParams object +// with the ability to set a context for a request. +func NewLoginParamsWithContext(ctx context.Context) *LoginParams { + return &LoginParams{ + Context: ctx, + } +} + +// NewLoginParamsWithHTTPClient creates a new LoginParams object +// with the ability to set a custom HTTPClient for a request. +func NewLoginParamsWithHTTPClient(client *http.Client) *LoginParams { + return &LoginParams{ + HTTPClient: client, + } +} + +/* +LoginParams contains all the parameters to send to the API endpoint + + for the login operation. + + Typically these are written to a http.Request. +*/ +type LoginParams struct { + + /* Body. + + Login information. + */ + Body garm_params.PasswordLoginParams + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoginParams) WithDefaults() *LoginParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoginParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the login params +func (o *LoginParams) WithTimeout(timeout time.Duration) *LoginParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the login params +func (o *LoginParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the login params +func (o *LoginParams) WithContext(ctx context.Context) *LoginParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the login params +func (o *LoginParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the login params +func (o *LoginParams) WithHTTPClient(client *http.Client) *LoginParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the login params +func (o *LoginParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the login params +func (o *LoginParams) WithBody(body garm_params.PasswordLoginParams) *LoginParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the login params +func (o *LoginParams) SetBody(body garm_params.PasswordLoginParams) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *LoginParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/login/login_responses.go b/client/login/login_responses.go new file mode 100644 index 00000000..7506e909 --- /dev/null +++ b/client/login/login_responses.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package login + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// LoginReader is a Reader for the Login structure. +type LoginReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *LoginReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewLoginOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewLoginBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /auth/login] Login", response, response.Code()) + } +} + +// NewLoginOK creates a LoginOK with default headers values +func NewLoginOK() *LoginOK { + return &LoginOK{} +} + +/* +LoginOK describes a response with status code 200, with default header values. + +JWTResponse +*/ +type LoginOK struct { + Payload garm_params.JWTResponse +} + +// IsSuccess returns true when this login o k response has a 2xx status code +func (o *LoginOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this login o k response has a 3xx status code +func (o *LoginOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this login o k response has a 4xx status code +func (o *LoginOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this login o k response has a 5xx status code +func (o *LoginOK) IsServerError() bool { + return false +} + +// IsCode returns true when this login o k response a status code equal to that given +func (o *LoginOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the login o k response +func (o *LoginOK) Code() int { + return 200 +} + +func (o *LoginOK) Error() string { + return fmt.Sprintf("[POST /auth/login][%d] loginOK %+v", 200, o.Payload) +} + +func (o *LoginOK) String() string { + return fmt.Sprintf("[POST /auth/login][%d] loginOK %+v", 200, o.Payload) +} + +func (o *LoginOK) GetPayload() garm_params.JWTResponse { + return o.Payload +} + +func (o *LoginOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewLoginBadRequest creates a LoginBadRequest with default headers values +func NewLoginBadRequest() *LoginBadRequest { + return &LoginBadRequest{} +} + +/* +LoginBadRequest describes a response with status code 400, with default header values. + +APIErrorResponse +*/ +type LoginBadRequest struct { + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this login bad request response has a 2xx status code +func (o *LoginBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this login bad request response has a 3xx status code +func (o *LoginBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this login bad request response has a 4xx status code +func (o *LoginBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this login bad request response has a 5xx status code +func (o *LoginBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this login bad request response a status code equal to that given +func (o *LoginBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the login bad request response +func (o *LoginBadRequest) Code() int { + return 400 +} + +func (o *LoginBadRequest) Error() string { + return fmt.Sprintf("[POST /auth/login][%d] loginBadRequest %+v", 400, o.Payload) +} + +func (o *LoginBadRequest) String() string { + return fmt.Sprintf("[POST /auth/login][%d] loginBadRequest %+v", 400, o.Payload) +} + +func (o *LoginBadRequest) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *LoginBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/create_org_parameters.go b/client/organizations/create_org_parameters.go new file mode 100644 index 00000000..bf183834 --- /dev/null +++ b/client/organizations/create_org_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewCreateOrgParams creates a new CreateOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewCreateOrgParams() *CreateOrgParams { + return &CreateOrgParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCreateOrgParamsWithTimeout creates a new CreateOrgParams object +// with the ability to set a timeout on a request. +func NewCreateOrgParamsWithTimeout(timeout time.Duration) *CreateOrgParams { + return &CreateOrgParams{ + timeout: timeout, + } +} + +// NewCreateOrgParamsWithContext creates a new CreateOrgParams object +// with the ability to set a context for a request. +func NewCreateOrgParamsWithContext(ctx context.Context) *CreateOrgParams { + return &CreateOrgParams{ + Context: ctx, + } +} + +// NewCreateOrgParamsWithHTTPClient creates a new CreateOrgParams object +// with the ability to set a custom HTTPClient for a request. +func NewCreateOrgParamsWithHTTPClient(client *http.Client) *CreateOrgParams { + return &CreateOrgParams{ + HTTPClient: client, + } +} + +/* +CreateOrgParams contains all the parameters to send to the API endpoint + + for the create org operation. + + Typically these are written to a http.Request. +*/ +type CreateOrgParams struct { + + /* Body. + + Parameters used when creating the organization. + */ + Body garm_params.CreateOrgParams + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the create org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgParams) WithDefaults() *CreateOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the create org params +func (o *CreateOrgParams) WithTimeout(timeout time.Duration) *CreateOrgParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create org params +func (o *CreateOrgParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create org params +func (o *CreateOrgParams) WithContext(ctx context.Context) *CreateOrgParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create org params +func (o *CreateOrgParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create org params +func (o *CreateOrgParams) WithHTTPClient(client *http.Client) *CreateOrgParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create org params +func (o *CreateOrgParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the create org params +func (o *CreateOrgParams) WithBody(body garm_params.CreateOrgParams) *CreateOrgParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the create org params +func (o *CreateOrgParams) SetBody(body garm_params.CreateOrgParams) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/create_org_pool_parameters.go b/client/organizations/create_org_pool_parameters.go new file mode 100644 index 00000000..1fc46998 --- /dev/null +++ b/client/organizations/create_org_pool_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewCreateOrgPoolParams creates a new CreateOrgPoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewCreateOrgPoolParams() *CreateOrgPoolParams { + return &CreateOrgPoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCreateOrgPoolParamsWithTimeout creates a new CreateOrgPoolParams object +// with the ability to set a timeout on a request. +func NewCreateOrgPoolParamsWithTimeout(timeout time.Duration) *CreateOrgPoolParams { + return &CreateOrgPoolParams{ + timeout: timeout, + } +} + +// NewCreateOrgPoolParamsWithContext creates a new CreateOrgPoolParams object +// with the ability to set a context for a request. +func NewCreateOrgPoolParamsWithContext(ctx context.Context) *CreateOrgPoolParams { + return &CreateOrgPoolParams{ + Context: ctx, + } +} + +// NewCreateOrgPoolParamsWithHTTPClient creates a new CreateOrgPoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewCreateOrgPoolParamsWithHTTPClient(client *http.Client) *CreateOrgPoolParams { + return &CreateOrgPoolParams{ + HTTPClient: client, + } +} + +/* +CreateOrgPoolParams contains all the parameters to send to the API endpoint + + for the create org pool operation. + + Typically these are written to a http.Request. +*/ +type CreateOrgPoolParams struct { + + /* Body. + + Parameters used when creating the organization pool. + */ + Body garm_params.CreatePoolParams + + /* OrgID. + + Organization ID. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the create org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgPoolParams) WithDefaults() *CreateOrgPoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgPoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the create org pool params +func (o *CreateOrgPoolParams) WithTimeout(timeout time.Duration) *CreateOrgPoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create org pool params +func (o *CreateOrgPoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create org pool params +func (o *CreateOrgPoolParams) WithContext(ctx context.Context) *CreateOrgPoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create org pool params +func (o *CreateOrgPoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create org pool params +func (o *CreateOrgPoolParams) WithHTTPClient(client *http.Client) *CreateOrgPoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create org pool params +func (o *CreateOrgPoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the create org pool params +func (o *CreateOrgPoolParams) WithBody(body garm_params.CreatePoolParams) *CreateOrgPoolParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the create org pool params +func (o *CreateOrgPoolParams) SetBody(body garm_params.CreatePoolParams) { + o.Body = body +} + +// WithOrgID adds the orgID to the create org pool params +func (o *CreateOrgPoolParams) WithOrgID(orgID string) *CreateOrgPoolParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the create org pool params +func (o *CreateOrgPoolParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateOrgPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/create_org_pool_responses.go b/client/organizations/create_org_pool_responses.go new file mode 100644 index 00000000..d9d77022 --- /dev/null +++ b/client/organizations/create_org_pool_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// CreateOrgPoolReader is a Reader for the CreateOrgPool structure. +type CreateOrgPoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateOrgPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewCreateOrgPoolOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewCreateOrgPoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewCreateOrgPoolOK creates a CreateOrgPoolOK with default headers values +func NewCreateOrgPoolOK() *CreateOrgPoolOK { + return &CreateOrgPoolOK{} +} + +/* +CreateOrgPoolOK describes a response with status code 200, with default header values. + +Pool +*/ +type CreateOrgPoolOK struct { + Payload garm_params.Pool +} + +// IsSuccess returns true when this create org pool o k response has a 2xx status code +func (o *CreateOrgPoolOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create org pool o k response has a 3xx status code +func (o *CreateOrgPoolOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create org pool o k response has a 4xx status code +func (o *CreateOrgPoolOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create org pool o k response has a 5xx status code +func (o *CreateOrgPoolOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create org pool o k response a status code equal to that given +func (o *CreateOrgPoolOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create org pool o k response +func (o *CreateOrgPoolOK) Code() int { + return 200 +} + +func (o *CreateOrgPoolOK) Error() string { + return fmt.Sprintf("[POST /organizations/{orgID}/pools][%d] createOrgPoolOK %+v", 200, o.Payload) +} + +func (o *CreateOrgPoolOK) String() string { + return fmt.Sprintf("[POST /organizations/{orgID}/pools][%d] createOrgPoolOK %+v", 200, o.Payload) +} + +func (o *CreateOrgPoolOK) GetPayload() garm_params.Pool { + return o.Payload +} + +func (o *CreateOrgPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateOrgPoolDefault creates a CreateOrgPoolDefault with default headers values +func NewCreateOrgPoolDefault(code int) *CreateOrgPoolDefault { + return &CreateOrgPoolDefault{ + _statusCode: code, + } +} + +/* +CreateOrgPoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type CreateOrgPoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this create org pool default response has a 2xx status code +func (o *CreateOrgPoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create org pool default response has a 3xx status code +func (o *CreateOrgPoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create org pool default response has a 4xx status code +func (o *CreateOrgPoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create org pool default response has a 5xx status code +func (o *CreateOrgPoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create org pool default response a status code equal to that given +func (o *CreateOrgPoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the create org pool default response +func (o *CreateOrgPoolDefault) Code() int { + return o._statusCode +} + +func (o *CreateOrgPoolDefault) Error() string { + return fmt.Sprintf("[POST /organizations/{orgID}/pools][%d] CreateOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *CreateOrgPoolDefault) String() string { + return fmt.Sprintf("[POST /organizations/{orgID}/pools][%d] CreateOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *CreateOrgPoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *CreateOrgPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/create_org_responses.go b/client/organizations/create_org_responses.go new file mode 100644 index 00000000..f8858716 --- /dev/null +++ b/client/organizations/create_org_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// CreateOrgReader is a Reader for the CreateOrg structure. +type CreateOrgReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateOrgReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewCreateOrgOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewCreateOrgDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewCreateOrgOK creates a CreateOrgOK with default headers values +func NewCreateOrgOK() *CreateOrgOK { + return &CreateOrgOK{} +} + +/* +CreateOrgOK describes a response with status code 200, with default header values. + +Organization +*/ +type CreateOrgOK struct { + Payload garm_params.Organization +} + +// IsSuccess returns true when this create org o k response has a 2xx status code +func (o *CreateOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create org o k response has a 3xx status code +func (o *CreateOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create org o k response has a 4xx status code +func (o *CreateOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create org o k response has a 5xx status code +func (o *CreateOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create org o k response a status code equal to that given +func (o *CreateOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create org o k response +func (o *CreateOrgOK) Code() int { + return 200 +} + +func (o *CreateOrgOK) Error() string { + return fmt.Sprintf("[POST /organizations][%d] createOrgOK %+v", 200, o.Payload) +} + +func (o *CreateOrgOK) String() string { + return fmt.Sprintf("[POST /organizations][%d] createOrgOK %+v", 200, o.Payload) +} + +func (o *CreateOrgOK) GetPayload() garm_params.Organization { + return o.Payload +} + +func (o *CreateOrgOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateOrgDefault creates a CreateOrgDefault with default headers values +func NewCreateOrgDefault(code int) *CreateOrgDefault { + return &CreateOrgDefault{ + _statusCode: code, + } +} + +/* +CreateOrgDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type CreateOrgDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this create org default response has a 2xx status code +func (o *CreateOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create org default response has a 3xx status code +func (o *CreateOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create org default response has a 4xx status code +func (o *CreateOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create org default response has a 5xx status code +func (o *CreateOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create org default response a status code equal to that given +func (o *CreateOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the create org default response +func (o *CreateOrgDefault) Code() int { + return o._statusCode +} + +func (o *CreateOrgDefault) Error() string { + return fmt.Sprintf("[POST /organizations][%d] CreateOrg default %+v", o._statusCode, o.Payload) +} + +func (o *CreateOrgDefault) String() string { + return fmt.Sprintf("[POST /organizations][%d] CreateOrg default %+v", o._statusCode, o.Payload) +} + +func (o *CreateOrgDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *CreateOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/delete_org_parameters.go b/client/organizations/delete_org_parameters.go new file mode 100644 index 00000000..92e27495 --- /dev/null +++ b/client/organizations/delete_org_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteOrgParams creates a new DeleteOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteOrgParams() *DeleteOrgParams { + return &DeleteOrgParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteOrgParamsWithTimeout creates a new DeleteOrgParams object +// with the ability to set a timeout on a request. +func NewDeleteOrgParamsWithTimeout(timeout time.Duration) *DeleteOrgParams { + return &DeleteOrgParams{ + timeout: timeout, + } +} + +// NewDeleteOrgParamsWithContext creates a new DeleteOrgParams object +// with the ability to set a context for a request. +func NewDeleteOrgParamsWithContext(ctx context.Context) *DeleteOrgParams { + return &DeleteOrgParams{ + Context: ctx, + } +} + +// NewDeleteOrgParamsWithHTTPClient creates a new DeleteOrgParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteOrgParamsWithHTTPClient(client *http.Client) *DeleteOrgParams { + return &DeleteOrgParams{ + HTTPClient: client, + } +} + +/* +DeleteOrgParams contains all the parameters to send to the API endpoint + + for the delete org operation. + + Typically these are written to a http.Request. +*/ +type DeleteOrgParams struct { + + /* OrgID. + + ID of the organization to delete. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgParams) WithDefaults() *DeleteOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete org params +func (o *DeleteOrgParams) WithTimeout(timeout time.Duration) *DeleteOrgParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete org params +func (o *DeleteOrgParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete org params +func (o *DeleteOrgParams) WithContext(ctx context.Context) *DeleteOrgParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete org params +func (o *DeleteOrgParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete org params +func (o *DeleteOrgParams) WithHTTPClient(client *http.Client) *DeleteOrgParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete org params +func (o *DeleteOrgParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the delete org params +func (o *DeleteOrgParams) WithOrgID(orgID string) *DeleteOrgParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the delete org params +func (o *DeleteOrgParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/delete_org_pool_parameters.go b/client/organizations/delete_org_pool_parameters.go new file mode 100644 index 00000000..89500172 --- /dev/null +++ b/client/organizations/delete_org_pool_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteOrgPoolParams creates a new DeleteOrgPoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteOrgPoolParams() *DeleteOrgPoolParams { + return &DeleteOrgPoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteOrgPoolParamsWithTimeout creates a new DeleteOrgPoolParams object +// with the ability to set a timeout on a request. +func NewDeleteOrgPoolParamsWithTimeout(timeout time.Duration) *DeleteOrgPoolParams { + return &DeleteOrgPoolParams{ + timeout: timeout, + } +} + +// NewDeleteOrgPoolParamsWithContext creates a new DeleteOrgPoolParams object +// with the ability to set a context for a request. +func NewDeleteOrgPoolParamsWithContext(ctx context.Context) *DeleteOrgPoolParams { + return &DeleteOrgPoolParams{ + Context: ctx, + } +} + +// NewDeleteOrgPoolParamsWithHTTPClient creates a new DeleteOrgPoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteOrgPoolParamsWithHTTPClient(client *http.Client) *DeleteOrgPoolParams { + return &DeleteOrgPoolParams{ + HTTPClient: client, + } +} + +/* +DeleteOrgPoolParams contains all the parameters to send to the API endpoint + + for the delete org pool operation. + + Typically these are written to a http.Request. +*/ +type DeleteOrgPoolParams struct { + + /* OrgID. + + Organization ID. + */ + OrgID string + + /* PoolID. + + ID of the organization pool to delete. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgPoolParams) WithDefaults() *DeleteOrgPoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgPoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete org pool params +func (o *DeleteOrgPoolParams) WithTimeout(timeout time.Duration) *DeleteOrgPoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete org pool params +func (o *DeleteOrgPoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete org pool params +func (o *DeleteOrgPoolParams) WithContext(ctx context.Context) *DeleteOrgPoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete org pool params +func (o *DeleteOrgPoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete org pool params +func (o *DeleteOrgPoolParams) WithHTTPClient(client *http.Client) *DeleteOrgPoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete org pool params +func (o *DeleteOrgPoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the delete org pool params +func (o *DeleteOrgPoolParams) WithOrgID(orgID string) *DeleteOrgPoolParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the delete org pool params +func (o *DeleteOrgPoolParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WithPoolID adds the poolID to the delete org pool params +func (o *DeleteOrgPoolParams) WithPoolID(poolID string) *DeleteOrgPoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the delete org pool params +func (o *DeleteOrgPoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteOrgPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/delete_org_pool_responses.go b/client/organizations/delete_org_pool_responses.go new file mode 100644 index 00000000..82bde7bc --- /dev/null +++ b/client/organizations/delete_org_pool_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" +) + +// DeleteOrgPoolReader is a Reader for the DeleteOrgPool structure. +type DeleteOrgPoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteOrgPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + result := NewDeleteOrgPoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result +} + +// NewDeleteOrgPoolDefault creates a DeleteOrgPoolDefault with default headers values +func NewDeleteOrgPoolDefault(code int) *DeleteOrgPoolDefault { + return &DeleteOrgPoolDefault{ + _statusCode: code, + } +} + +/* +DeleteOrgPoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type DeleteOrgPoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this delete org pool default response has a 2xx status code +func (o *DeleteOrgPoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete org pool default response has a 3xx status code +func (o *DeleteOrgPoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete org pool default response has a 4xx status code +func (o *DeleteOrgPoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete org pool default response has a 5xx status code +func (o *DeleteOrgPoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete org pool default response a status code equal to that given +func (o *DeleteOrgPoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the delete org pool default response +func (o *DeleteOrgPoolDefault) Code() int { + return o._statusCode +} + +func (o *DeleteOrgPoolDefault) Error() string { + return fmt.Sprintf("[DELETE /organizations/{orgID}/pools/{poolID}][%d] DeleteOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *DeleteOrgPoolDefault) String() string { + return fmt.Sprintf("[DELETE /organizations/{orgID}/pools/{poolID}][%d] DeleteOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *DeleteOrgPoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *DeleteOrgPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/delete_org_responses.go b/client/organizations/delete_org_responses.go new file mode 100644 index 00000000..11e5ea2a --- /dev/null +++ b/client/organizations/delete_org_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" +) + +// DeleteOrgReader is a Reader for the DeleteOrg structure. +type DeleteOrgReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteOrgReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + result := NewDeleteOrgDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result +} + +// NewDeleteOrgDefault creates a DeleteOrgDefault with default headers values +func NewDeleteOrgDefault(code int) *DeleteOrgDefault { + return &DeleteOrgDefault{ + _statusCode: code, + } +} + +/* +DeleteOrgDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type DeleteOrgDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this delete org default response has a 2xx status code +func (o *DeleteOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete org default response has a 3xx status code +func (o *DeleteOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete org default response has a 4xx status code +func (o *DeleteOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete org default response has a 5xx status code +func (o *DeleteOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete org default response a status code equal to that given +func (o *DeleteOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the delete org default response +func (o *DeleteOrgDefault) Code() int { + return o._statusCode +} + +func (o *DeleteOrgDefault) Error() string { + return fmt.Sprintf("[DELETE /organizations/{orgID}][%d] DeleteOrg default %+v", o._statusCode, o.Payload) +} + +func (o *DeleteOrgDefault) String() string { + return fmt.Sprintf("[DELETE /organizations/{orgID}][%d] DeleteOrg default %+v", o._statusCode, o.Payload) +} + +func (o *DeleteOrgDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *DeleteOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/get_org_parameters.go b/client/organizations/get_org_parameters.go new file mode 100644 index 00000000..b5bab9c0 --- /dev/null +++ b/client/organizations/get_org_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetOrgParams creates a new GetOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetOrgParams() *GetOrgParams { + return &GetOrgParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetOrgParamsWithTimeout creates a new GetOrgParams object +// with the ability to set a timeout on a request. +func NewGetOrgParamsWithTimeout(timeout time.Duration) *GetOrgParams { + return &GetOrgParams{ + timeout: timeout, + } +} + +// NewGetOrgParamsWithContext creates a new GetOrgParams object +// with the ability to set a context for a request. +func NewGetOrgParamsWithContext(ctx context.Context) *GetOrgParams { + return &GetOrgParams{ + Context: ctx, + } +} + +// NewGetOrgParamsWithHTTPClient creates a new GetOrgParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetOrgParamsWithHTTPClient(client *http.Client) *GetOrgParams { + return &GetOrgParams{ + HTTPClient: client, + } +} + +/* +GetOrgParams contains all the parameters to send to the API endpoint + + for the get org operation. + + Typically these are written to a http.Request. +*/ +type GetOrgParams struct { + + /* OrgID. + + ID of the organization to fetch. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgParams) WithDefaults() *GetOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get org params +func (o *GetOrgParams) WithTimeout(timeout time.Duration) *GetOrgParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get org params +func (o *GetOrgParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get org params +func (o *GetOrgParams) WithContext(ctx context.Context) *GetOrgParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get org params +func (o *GetOrgParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get org params +func (o *GetOrgParams) WithHTTPClient(client *http.Client) *GetOrgParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get org params +func (o *GetOrgParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the get org params +func (o *GetOrgParams) WithOrgID(orgID string) *GetOrgParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the get org params +func (o *GetOrgParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/get_org_pool_parameters.go b/client/organizations/get_org_pool_parameters.go new file mode 100644 index 00000000..dd2dc817 --- /dev/null +++ b/client/organizations/get_org_pool_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetOrgPoolParams creates a new GetOrgPoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetOrgPoolParams() *GetOrgPoolParams { + return &GetOrgPoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetOrgPoolParamsWithTimeout creates a new GetOrgPoolParams object +// with the ability to set a timeout on a request. +func NewGetOrgPoolParamsWithTimeout(timeout time.Duration) *GetOrgPoolParams { + return &GetOrgPoolParams{ + timeout: timeout, + } +} + +// NewGetOrgPoolParamsWithContext creates a new GetOrgPoolParams object +// with the ability to set a context for a request. +func NewGetOrgPoolParamsWithContext(ctx context.Context) *GetOrgPoolParams { + return &GetOrgPoolParams{ + Context: ctx, + } +} + +// NewGetOrgPoolParamsWithHTTPClient creates a new GetOrgPoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetOrgPoolParamsWithHTTPClient(client *http.Client) *GetOrgPoolParams { + return &GetOrgPoolParams{ + HTTPClient: client, + } +} + +/* +GetOrgPoolParams contains all the parameters to send to the API endpoint + + for the get org pool operation. + + Typically these are written to a http.Request. +*/ +type GetOrgPoolParams struct { + + /* OrgID. + + Organization ID. + */ + OrgID string + + /* PoolID. + + Pool ID. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgPoolParams) WithDefaults() *GetOrgPoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgPoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get org pool params +func (o *GetOrgPoolParams) WithTimeout(timeout time.Duration) *GetOrgPoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get org pool params +func (o *GetOrgPoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get org pool params +func (o *GetOrgPoolParams) WithContext(ctx context.Context) *GetOrgPoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get org pool params +func (o *GetOrgPoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get org pool params +func (o *GetOrgPoolParams) WithHTTPClient(client *http.Client) *GetOrgPoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get org pool params +func (o *GetOrgPoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the get org pool params +func (o *GetOrgPoolParams) WithOrgID(orgID string) *GetOrgPoolParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the get org pool params +func (o *GetOrgPoolParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WithPoolID adds the poolID to the get org pool params +func (o *GetOrgPoolParams) WithPoolID(poolID string) *GetOrgPoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the get org pool params +func (o *GetOrgPoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetOrgPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/get_org_pool_responses.go b/client/organizations/get_org_pool_responses.go new file mode 100644 index 00000000..0036870f --- /dev/null +++ b/client/organizations/get_org_pool_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// GetOrgPoolReader is a Reader for the GetOrgPool structure. +type GetOrgPoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetOrgPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetOrgPoolOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetOrgPoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetOrgPoolOK creates a GetOrgPoolOK with default headers values +func NewGetOrgPoolOK() *GetOrgPoolOK { + return &GetOrgPoolOK{} +} + +/* +GetOrgPoolOK describes a response with status code 200, with default header values. + +Pool +*/ +type GetOrgPoolOK struct { + Payload garm_params.Pool +} + +// IsSuccess returns true when this get org pool o k response has a 2xx status code +func (o *GetOrgPoolOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get org pool o k response has a 3xx status code +func (o *GetOrgPoolOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org pool o k response has a 4xx status code +func (o *GetOrgPoolOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get org pool o k response has a 5xx status code +func (o *GetOrgPoolOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get org pool o k response a status code equal to that given +func (o *GetOrgPoolOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get org pool o k response +func (o *GetOrgPoolOK) Code() int { + return 200 +} + +func (o *GetOrgPoolOK) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools/{poolID}][%d] getOrgPoolOK %+v", 200, o.Payload) +} + +func (o *GetOrgPoolOK) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools/{poolID}][%d] getOrgPoolOK %+v", 200, o.Payload) +} + +func (o *GetOrgPoolOK) GetPayload() garm_params.Pool { + return o.Payload +} + +func (o *GetOrgPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetOrgPoolDefault creates a GetOrgPoolDefault with default headers values +func NewGetOrgPoolDefault(code int) *GetOrgPoolDefault { + return &GetOrgPoolDefault{ + _statusCode: code, + } +} + +/* +GetOrgPoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type GetOrgPoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this get org pool default response has a 2xx status code +func (o *GetOrgPoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get org pool default response has a 3xx status code +func (o *GetOrgPoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get org pool default response has a 4xx status code +func (o *GetOrgPoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get org pool default response has a 5xx status code +func (o *GetOrgPoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get org pool default response a status code equal to that given +func (o *GetOrgPoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the get org pool default response +func (o *GetOrgPoolDefault) Code() int { + return o._statusCode +} + +func (o *GetOrgPoolDefault) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools/{poolID}][%d] GetOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *GetOrgPoolDefault) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools/{poolID}][%d] GetOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *GetOrgPoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *GetOrgPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/get_org_responses.go b/client/organizations/get_org_responses.go new file mode 100644 index 00000000..926a088d --- /dev/null +++ b/client/organizations/get_org_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// GetOrgReader is a Reader for the GetOrg structure. +type GetOrgReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetOrgReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetOrgOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetOrgDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetOrgOK creates a GetOrgOK with default headers values +func NewGetOrgOK() *GetOrgOK { + return &GetOrgOK{} +} + +/* +GetOrgOK describes a response with status code 200, with default header values. + +Organization +*/ +type GetOrgOK struct { + Payload garm_params.Organization +} + +// IsSuccess returns true when this get org o k response has a 2xx status code +func (o *GetOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get org o k response has a 3xx status code +func (o *GetOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org o k response has a 4xx status code +func (o *GetOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get org o k response has a 5xx status code +func (o *GetOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get org o k response a status code equal to that given +func (o *GetOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get org o k response +func (o *GetOrgOK) Code() int { + return 200 +} + +func (o *GetOrgOK) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}][%d] getOrgOK %+v", 200, o.Payload) +} + +func (o *GetOrgOK) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}][%d] getOrgOK %+v", 200, o.Payload) +} + +func (o *GetOrgOK) GetPayload() garm_params.Organization { + return o.Payload +} + +func (o *GetOrgOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetOrgDefault creates a GetOrgDefault with default headers values +func NewGetOrgDefault(code int) *GetOrgDefault { + return &GetOrgDefault{ + _statusCode: code, + } +} + +/* +GetOrgDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type GetOrgDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this get org default response has a 2xx status code +func (o *GetOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get org default response has a 3xx status code +func (o *GetOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get org default response has a 4xx status code +func (o *GetOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get org default response has a 5xx status code +func (o *GetOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get org default response a status code equal to that given +func (o *GetOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the get org default response +func (o *GetOrgDefault) Code() int { + return o._statusCode +} + +func (o *GetOrgDefault) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}][%d] GetOrg default %+v", o._statusCode, o.Payload) +} + +func (o *GetOrgDefault) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}][%d] GetOrg default %+v", o._statusCode, o.Payload) +} + +func (o *GetOrgDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *GetOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/list_org_instances_parameters.go b/client/organizations/list_org_instances_parameters.go new file mode 100644 index 00000000..e7167a7e --- /dev/null +++ b/client/organizations/list_org_instances_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListOrgInstancesParams creates a new ListOrgInstancesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListOrgInstancesParams() *ListOrgInstancesParams { + return &ListOrgInstancesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListOrgInstancesParamsWithTimeout creates a new ListOrgInstancesParams object +// with the ability to set a timeout on a request. +func NewListOrgInstancesParamsWithTimeout(timeout time.Duration) *ListOrgInstancesParams { + return &ListOrgInstancesParams{ + timeout: timeout, + } +} + +// NewListOrgInstancesParamsWithContext creates a new ListOrgInstancesParams object +// with the ability to set a context for a request. +func NewListOrgInstancesParamsWithContext(ctx context.Context) *ListOrgInstancesParams { + return &ListOrgInstancesParams{ + Context: ctx, + } +} + +// NewListOrgInstancesParamsWithHTTPClient creates a new ListOrgInstancesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListOrgInstancesParamsWithHTTPClient(client *http.Client) *ListOrgInstancesParams { + return &ListOrgInstancesParams{ + HTTPClient: client, + } +} + +/* +ListOrgInstancesParams contains all the parameters to send to the API endpoint + + for the list org instances operation. + + Typically these are written to a http.Request. +*/ +type ListOrgInstancesParams struct { + + /* OrgID. + + Organization ID. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list org instances params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgInstancesParams) WithDefaults() *ListOrgInstancesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list org instances params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgInstancesParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list org instances params +func (o *ListOrgInstancesParams) WithTimeout(timeout time.Duration) *ListOrgInstancesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list org instances params +func (o *ListOrgInstancesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list org instances params +func (o *ListOrgInstancesParams) WithContext(ctx context.Context) *ListOrgInstancesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list org instances params +func (o *ListOrgInstancesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list org instances params +func (o *ListOrgInstancesParams) WithHTTPClient(client *http.Client) *ListOrgInstancesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list org instances params +func (o *ListOrgInstancesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the list org instances params +func (o *ListOrgInstancesParams) WithOrgID(orgID string) *ListOrgInstancesParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the list org instances params +func (o *ListOrgInstancesParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListOrgInstancesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/list_org_instances_responses.go b/client/organizations/list_org_instances_responses.go new file mode 100644 index 00000000..1c0f48e0 --- /dev/null +++ b/client/organizations/list_org_instances_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListOrgInstancesReader is a Reader for the ListOrgInstances structure. +type ListOrgInstancesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListOrgInstancesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListOrgInstancesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListOrgInstancesDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListOrgInstancesOK creates a ListOrgInstancesOK with default headers values +func NewListOrgInstancesOK() *ListOrgInstancesOK { + return &ListOrgInstancesOK{} +} + +/* +ListOrgInstancesOK describes a response with status code 200, with default header values. + +Instances +*/ +type ListOrgInstancesOK struct { + Payload garm_params.Instances +} + +// IsSuccess returns true when this list org instances o k response has a 2xx status code +func (o *ListOrgInstancesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list org instances o k response has a 3xx status code +func (o *ListOrgInstancesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list org instances o k response has a 4xx status code +func (o *ListOrgInstancesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list org instances o k response has a 5xx status code +func (o *ListOrgInstancesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list org instances o k response a status code equal to that given +func (o *ListOrgInstancesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list org instances o k response +func (o *ListOrgInstancesOK) Code() int { + return 200 +} + +func (o *ListOrgInstancesOK) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/instances][%d] listOrgInstancesOK %+v", 200, o.Payload) +} + +func (o *ListOrgInstancesOK) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/instances][%d] listOrgInstancesOK %+v", 200, o.Payload) +} + +func (o *ListOrgInstancesOK) GetPayload() garm_params.Instances { + return o.Payload +} + +func (o *ListOrgInstancesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListOrgInstancesDefault creates a ListOrgInstancesDefault with default headers values +func NewListOrgInstancesDefault(code int) *ListOrgInstancesDefault { + return &ListOrgInstancesDefault{ + _statusCode: code, + } +} + +/* +ListOrgInstancesDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type ListOrgInstancesDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list org instances default response has a 2xx status code +func (o *ListOrgInstancesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list org instances default response has a 3xx status code +func (o *ListOrgInstancesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list org instances default response has a 4xx status code +func (o *ListOrgInstancesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list org instances default response has a 5xx status code +func (o *ListOrgInstancesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list org instances default response a status code equal to that given +func (o *ListOrgInstancesDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list org instances default response +func (o *ListOrgInstancesDefault) Code() int { + return o._statusCode +} + +func (o *ListOrgInstancesDefault) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/instances][%d] ListOrgInstances default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgInstancesDefault) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/instances][%d] ListOrgInstances default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgInstancesDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListOrgInstancesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/list_org_pools_parameters.go b/client/organizations/list_org_pools_parameters.go new file mode 100644 index 00000000..15a4284e --- /dev/null +++ b/client/organizations/list_org_pools_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListOrgPoolsParams creates a new ListOrgPoolsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListOrgPoolsParams() *ListOrgPoolsParams { + return &ListOrgPoolsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListOrgPoolsParamsWithTimeout creates a new ListOrgPoolsParams object +// with the ability to set a timeout on a request. +func NewListOrgPoolsParamsWithTimeout(timeout time.Duration) *ListOrgPoolsParams { + return &ListOrgPoolsParams{ + timeout: timeout, + } +} + +// NewListOrgPoolsParamsWithContext creates a new ListOrgPoolsParams object +// with the ability to set a context for a request. +func NewListOrgPoolsParamsWithContext(ctx context.Context) *ListOrgPoolsParams { + return &ListOrgPoolsParams{ + Context: ctx, + } +} + +// NewListOrgPoolsParamsWithHTTPClient creates a new ListOrgPoolsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListOrgPoolsParamsWithHTTPClient(client *http.Client) *ListOrgPoolsParams { + return &ListOrgPoolsParams{ + HTTPClient: client, + } +} + +/* +ListOrgPoolsParams contains all the parameters to send to the API endpoint + + for the list org pools operation. + + Typically these are written to a http.Request. +*/ +type ListOrgPoolsParams struct { + + /* OrgID. + + Organization ID. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list org pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgPoolsParams) WithDefaults() *ListOrgPoolsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list org pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgPoolsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list org pools params +func (o *ListOrgPoolsParams) WithTimeout(timeout time.Duration) *ListOrgPoolsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list org pools params +func (o *ListOrgPoolsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list org pools params +func (o *ListOrgPoolsParams) WithContext(ctx context.Context) *ListOrgPoolsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list org pools params +func (o *ListOrgPoolsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list org pools params +func (o *ListOrgPoolsParams) WithHTTPClient(client *http.Client) *ListOrgPoolsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list org pools params +func (o *ListOrgPoolsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOrgID adds the orgID to the list org pools params +func (o *ListOrgPoolsParams) WithOrgID(orgID string) *ListOrgPoolsParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the list org pools params +func (o *ListOrgPoolsParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListOrgPoolsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/list_org_pools_responses.go b/client/organizations/list_org_pools_responses.go new file mode 100644 index 00000000..b39944fd --- /dev/null +++ b/client/organizations/list_org_pools_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListOrgPoolsReader is a Reader for the ListOrgPools structure. +type ListOrgPoolsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListOrgPoolsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListOrgPoolsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListOrgPoolsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListOrgPoolsOK creates a ListOrgPoolsOK with default headers values +func NewListOrgPoolsOK() *ListOrgPoolsOK { + return &ListOrgPoolsOK{} +} + +/* +ListOrgPoolsOK describes a response with status code 200, with default header values. + +Pools +*/ +type ListOrgPoolsOK struct { + Payload garm_params.Pools +} + +// IsSuccess returns true when this list org pools o k response has a 2xx status code +func (o *ListOrgPoolsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list org pools o k response has a 3xx status code +func (o *ListOrgPoolsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list org pools o k response has a 4xx status code +func (o *ListOrgPoolsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list org pools o k response has a 5xx status code +func (o *ListOrgPoolsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list org pools o k response a status code equal to that given +func (o *ListOrgPoolsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list org pools o k response +func (o *ListOrgPoolsOK) Code() int { + return 200 +} + +func (o *ListOrgPoolsOK) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools][%d] listOrgPoolsOK %+v", 200, o.Payload) +} + +func (o *ListOrgPoolsOK) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools][%d] listOrgPoolsOK %+v", 200, o.Payload) +} + +func (o *ListOrgPoolsOK) GetPayload() garm_params.Pools { + return o.Payload +} + +func (o *ListOrgPoolsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListOrgPoolsDefault creates a ListOrgPoolsDefault with default headers values +func NewListOrgPoolsDefault(code int) *ListOrgPoolsDefault { + return &ListOrgPoolsDefault{ + _statusCode: code, + } +} + +/* +ListOrgPoolsDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type ListOrgPoolsDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list org pools default response has a 2xx status code +func (o *ListOrgPoolsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list org pools default response has a 3xx status code +func (o *ListOrgPoolsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list org pools default response has a 4xx status code +func (o *ListOrgPoolsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list org pools default response has a 5xx status code +func (o *ListOrgPoolsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list org pools default response a status code equal to that given +func (o *ListOrgPoolsDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list org pools default response +func (o *ListOrgPoolsDefault) Code() int { + return o._statusCode +} + +func (o *ListOrgPoolsDefault) Error() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools][%d] ListOrgPools default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgPoolsDefault) String() string { + return fmt.Sprintf("[GET /organizations/{orgID}/pools][%d] ListOrgPools default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgPoolsDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListOrgPoolsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/list_orgs_parameters.go b/client/organizations/list_orgs_parameters.go new file mode 100644 index 00000000..1441722f --- /dev/null +++ b/client/organizations/list_orgs_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListOrgsParams creates a new ListOrgsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListOrgsParams() *ListOrgsParams { + return &ListOrgsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListOrgsParamsWithTimeout creates a new ListOrgsParams object +// with the ability to set a timeout on a request. +func NewListOrgsParamsWithTimeout(timeout time.Duration) *ListOrgsParams { + return &ListOrgsParams{ + timeout: timeout, + } +} + +// NewListOrgsParamsWithContext creates a new ListOrgsParams object +// with the ability to set a context for a request. +func NewListOrgsParamsWithContext(ctx context.Context) *ListOrgsParams { + return &ListOrgsParams{ + Context: ctx, + } +} + +// NewListOrgsParamsWithHTTPClient creates a new ListOrgsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListOrgsParamsWithHTTPClient(client *http.Client) *ListOrgsParams { + return &ListOrgsParams{ + HTTPClient: client, + } +} + +/* +ListOrgsParams contains all the parameters to send to the API endpoint + + for the list orgs operation. + + Typically these are written to a http.Request. +*/ +type ListOrgsParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list orgs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgsParams) WithDefaults() *ListOrgsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list orgs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListOrgsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list orgs params +func (o *ListOrgsParams) WithTimeout(timeout time.Duration) *ListOrgsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list orgs params +func (o *ListOrgsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list orgs params +func (o *ListOrgsParams) WithContext(ctx context.Context) *ListOrgsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list orgs params +func (o *ListOrgsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list orgs params +func (o *ListOrgsParams) WithHTTPClient(client *http.Client) *ListOrgsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list orgs params +func (o *ListOrgsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListOrgsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/list_orgs_responses.go b/client/organizations/list_orgs_responses.go new file mode 100644 index 00000000..b29343e3 --- /dev/null +++ b/client/organizations/list_orgs_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListOrgsReader is a Reader for the ListOrgs structure. +type ListOrgsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListOrgsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListOrgsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListOrgsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListOrgsOK creates a ListOrgsOK with default headers values +func NewListOrgsOK() *ListOrgsOK { + return &ListOrgsOK{} +} + +/* +ListOrgsOK describes a response with status code 200, with default header values. + +Organizations +*/ +type ListOrgsOK struct { + Payload garm_params.Organizations +} + +// IsSuccess returns true when this list orgs o k response has a 2xx status code +func (o *ListOrgsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list orgs o k response has a 3xx status code +func (o *ListOrgsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list orgs o k response has a 4xx status code +func (o *ListOrgsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list orgs o k response has a 5xx status code +func (o *ListOrgsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list orgs o k response a status code equal to that given +func (o *ListOrgsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list orgs o k response +func (o *ListOrgsOK) Code() int { + return 200 +} + +func (o *ListOrgsOK) Error() string { + return fmt.Sprintf("[GET /organizations][%d] listOrgsOK %+v", 200, o.Payload) +} + +func (o *ListOrgsOK) String() string { + return fmt.Sprintf("[GET /organizations][%d] listOrgsOK %+v", 200, o.Payload) +} + +func (o *ListOrgsOK) GetPayload() garm_params.Organizations { + return o.Payload +} + +func (o *ListOrgsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListOrgsDefault creates a ListOrgsDefault with default headers values +func NewListOrgsDefault(code int) *ListOrgsDefault { + return &ListOrgsDefault{ + _statusCode: code, + } +} + +/* +ListOrgsDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type ListOrgsDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list orgs default response has a 2xx status code +func (o *ListOrgsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list orgs default response has a 3xx status code +func (o *ListOrgsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list orgs default response has a 4xx status code +func (o *ListOrgsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list orgs default response has a 5xx status code +func (o *ListOrgsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list orgs default response a status code equal to that given +func (o *ListOrgsDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list orgs default response +func (o *ListOrgsDefault) Code() int { + return o._statusCode +} + +func (o *ListOrgsDefault) Error() string { + return fmt.Sprintf("[GET /organizations][%d] ListOrgs default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgsDefault) String() string { + return fmt.Sprintf("[GET /organizations][%d] ListOrgs default %+v", o._statusCode, o.Payload) +} + +func (o *ListOrgsDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListOrgsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/organizations_client.go b/client/organizations/organizations_client.go new file mode 100644 index 00000000..3d75cd86 --- /dev/null +++ b/client/organizations/organizations_client.go @@ -0,0 +1,465 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new organizations API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for organizations API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgOK, error) + + CreateOrgPool(params *CreateOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgPoolOK, error) + + DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error + + DeleteOrgPool(params *DeleteOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error + + GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgOK, error) + + GetOrgPool(params *GetOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgPoolOK, error) + + ListOrgInstances(params *ListOrgInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgInstancesOK, error) + + ListOrgPools(params *ListOrgPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgPoolsOK, error) + + ListOrgs(params *ListOrgsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgsOK, error) + + UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgOK, error) + + UpdateOrgPool(params *UpdateOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgPoolOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +CreateOrg creates organization with the parameters given +*/ +func (a *Client) CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateOrgParams() + } + op := &runtime.ClientOperation{ + ID: "CreateOrg", + Method: "POST", + PathPattern: "/organizations", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &CreateOrgReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*CreateOrgOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*CreateOrgDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +CreateOrgPool creates organization pool with the parameters given +*/ +func (a *Client) CreateOrgPool(params *CreateOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgPoolOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateOrgPoolParams() + } + op := &runtime.ClientOperation{ + ID: "CreateOrgPool", + Method: "POST", + PathPattern: "/organizations/{orgID}/pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &CreateOrgPoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*CreateOrgPoolOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*CreateOrgPoolDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +DeleteOrg deletes organization by ID +*/ +func (a *Client) DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteOrgParams() + } + op := &runtime.ClientOperation{ + ID: "DeleteOrg", + Method: "DELETE", + PathPattern: "/organizations/{orgID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeleteOrgReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + _, err := a.transport.Submit(op) + if err != nil { + return err + } + return nil +} + +/* +DeleteOrgPool deletes organization pool by ID +*/ +func (a *Client) DeleteOrgPool(params *DeleteOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteOrgPoolParams() + } + op := &runtime.ClientOperation{ + ID: "DeleteOrgPool", + Method: "DELETE", + PathPattern: "/organizations/{orgID}/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeleteOrgPoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + _, err := a.transport.Submit(op) + if err != nil { + return err + } + return nil +} + +/* +GetOrg gets organization by ID +*/ +func (a *Client) GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetOrgParams() + } + op := &runtime.ClientOperation{ + ID: "GetOrg", + Method: "GET", + PathPattern: "/organizations/{orgID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetOrgReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*GetOrgOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetOrgDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +GetOrgPool gets organization pool by ID +*/ +func (a *Client) GetOrgPool(params *GetOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgPoolOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetOrgPoolParams() + } + op := &runtime.ClientOperation{ + ID: "GetOrgPool", + Method: "GET", + PathPattern: "/organizations/{orgID}/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetOrgPoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*GetOrgPoolOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetOrgPoolDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +ListOrgInstances lists organization instances +*/ +func (a *Client) ListOrgInstances(params *ListOrgInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgInstancesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListOrgInstancesParams() + } + op := &runtime.ClientOperation{ + ID: "ListOrgInstances", + Method: "GET", + PathPattern: "/organizations/{orgID}/instances", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListOrgInstancesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListOrgInstancesOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListOrgInstancesDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +ListOrgPools lists organization pools +*/ +func (a *Client) ListOrgPools(params *ListOrgPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgPoolsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListOrgPoolsParams() + } + op := &runtime.ClientOperation{ + ID: "ListOrgPools", + Method: "GET", + PathPattern: "/organizations/{orgID}/pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListOrgPoolsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListOrgPoolsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListOrgPoolsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +ListOrgs lists organizations +*/ +func (a *Client) ListOrgs(params *ListOrgsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListOrgsParams() + } + op := &runtime.ClientOperation{ + ID: "ListOrgs", + Method: "GET", + PathPattern: "/organizations", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListOrgsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListOrgsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListOrgsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +UpdateOrg updates organization with the parameters given +*/ +func (a *Client) UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateOrgParams() + } + op := &runtime.ClientOperation{ + ID: "UpdateOrg", + Method: "PUT", + PathPattern: "/organizations/{orgID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &UpdateOrgReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*UpdateOrgOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*UpdateOrgDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +UpdateOrgPool updates organization pool with the parameters given +*/ +func (a *Client) UpdateOrgPool(params *UpdateOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgPoolOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateOrgPoolParams() + } + op := &runtime.ClientOperation{ + ID: "UpdateOrgPool", + Method: "PUT", + PathPattern: "/organizations/{orgID}/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &UpdateOrgPoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*UpdateOrgPoolOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*UpdateOrgPoolDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/organizations/update_org_parameters.go b/client/organizations/update_org_parameters.go new file mode 100644 index 00000000..e2e32517 --- /dev/null +++ b/client/organizations/update_org_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewUpdateOrgParams creates a new UpdateOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUpdateOrgParams() *UpdateOrgParams { + return &UpdateOrgParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateOrgParamsWithTimeout creates a new UpdateOrgParams object +// with the ability to set a timeout on a request. +func NewUpdateOrgParamsWithTimeout(timeout time.Duration) *UpdateOrgParams { + return &UpdateOrgParams{ + timeout: timeout, + } +} + +// NewUpdateOrgParamsWithContext creates a new UpdateOrgParams object +// with the ability to set a context for a request. +func NewUpdateOrgParamsWithContext(ctx context.Context) *UpdateOrgParams { + return &UpdateOrgParams{ + Context: ctx, + } +} + +// NewUpdateOrgParamsWithHTTPClient creates a new UpdateOrgParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateOrgParamsWithHTTPClient(client *http.Client) *UpdateOrgParams { + return &UpdateOrgParams{ + HTTPClient: client, + } +} + +/* +UpdateOrgParams contains all the parameters to send to the API endpoint + + for the update org operation. + + Typically these are written to a http.Request. +*/ +type UpdateOrgParams struct { + + /* Body. + + Parameters used when updating the organization. + */ + Body garm_params.UpdateEntityParams + + /* OrgID. + + ID of the organization to update. + */ + OrgID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgParams) WithDefaults() *UpdateOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update org params +func (o *UpdateOrgParams) WithTimeout(timeout time.Duration) *UpdateOrgParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update org params +func (o *UpdateOrgParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update org params +func (o *UpdateOrgParams) WithContext(ctx context.Context) *UpdateOrgParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update org params +func (o *UpdateOrgParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update org params +func (o *UpdateOrgParams) WithHTTPClient(client *http.Client) *UpdateOrgParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update org params +func (o *UpdateOrgParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the update org params +func (o *UpdateOrgParams) WithBody(body garm_params.UpdateEntityParams) *UpdateOrgParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the update org params +func (o *UpdateOrgParams) SetBody(body garm_params.UpdateEntityParams) { + o.Body = body +} + +// WithOrgID adds the orgID to the update org params +func (o *UpdateOrgParams) WithOrgID(orgID string) *UpdateOrgParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the update org params +func (o *UpdateOrgParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/update_org_pool_parameters.go b/client/organizations/update_org_pool_parameters.go new file mode 100644 index 00000000..089441e4 --- /dev/null +++ b/client/organizations/update_org_pool_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewUpdateOrgPoolParams creates a new UpdateOrgPoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUpdateOrgPoolParams() *UpdateOrgPoolParams { + return &UpdateOrgPoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateOrgPoolParamsWithTimeout creates a new UpdateOrgPoolParams object +// with the ability to set a timeout on a request. +func NewUpdateOrgPoolParamsWithTimeout(timeout time.Duration) *UpdateOrgPoolParams { + return &UpdateOrgPoolParams{ + timeout: timeout, + } +} + +// NewUpdateOrgPoolParamsWithContext creates a new UpdateOrgPoolParams object +// with the ability to set a context for a request. +func NewUpdateOrgPoolParamsWithContext(ctx context.Context) *UpdateOrgPoolParams { + return &UpdateOrgPoolParams{ + Context: ctx, + } +} + +// NewUpdateOrgPoolParamsWithHTTPClient creates a new UpdateOrgPoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateOrgPoolParamsWithHTTPClient(client *http.Client) *UpdateOrgPoolParams { + return &UpdateOrgPoolParams{ + HTTPClient: client, + } +} + +/* +UpdateOrgPoolParams contains all the parameters to send to the API endpoint + + for the update org pool operation. + + Typically these are written to a http.Request. +*/ +type UpdateOrgPoolParams struct { + + /* Body. + + Parameters used when updating the organization pool. + */ + Body garm_params.UpdatePoolParams + + /* OrgID. + + Organization ID. + */ + OrgID string + + /* PoolID. + + ID of the organization pool to update. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgPoolParams) WithDefaults() *UpdateOrgPoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update org pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgPoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update org pool params +func (o *UpdateOrgPoolParams) WithTimeout(timeout time.Duration) *UpdateOrgPoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update org pool params +func (o *UpdateOrgPoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update org pool params +func (o *UpdateOrgPoolParams) WithContext(ctx context.Context) *UpdateOrgPoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update org pool params +func (o *UpdateOrgPoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update org pool params +func (o *UpdateOrgPoolParams) WithHTTPClient(client *http.Client) *UpdateOrgPoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update org pool params +func (o *UpdateOrgPoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the update org pool params +func (o *UpdateOrgPoolParams) WithBody(body garm_params.UpdatePoolParams) *UpdateOrgPoolParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the update org pool params +func (o *UpdateOrgPoolParams) SetBody(body garm_params.UpdatePoolParams) { + o.Body = body +} + +// WithOrgID adds the orgID to the update org pool params +func (o *UpdateOrgPoolParams) WithOrgID(orgID string) *UpdateOrgPoolParams { + o.SetOrgID(orgID) + return o +} + +// SetOrgID adds the orgId to the update org pool params +func (o *UpdateOrgPoolParams) SetOrgID(orgID string) { + o.OrgID = orgID +} + +// WithPoolID adds the poolID to the update org pool params +func (o *UpdateOrgPoolParams) WithPoolID(poolID string) *UpdateOrgPoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the update org pool params +func (o *UpdateOrgPoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateOrgPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param orgID + if err := r.SetPathParam("orgID", o.OrgID); err != nil { + return err + } + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/organizations/update_org_pool_responses.go b/client/organizations/update_org_pool_responses.go new file mode 100644 index 00000000..761195aa --- /dev/null +++ b/client/organizations/update_org_pool_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// UpdateOrgPoolReader is a Reader for the UpdateOrgPool structure. +type UpdateOrgPoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateOrgPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateOrgPoolOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewUpdateOrgPoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewUpdateOrgPoolOK creates a UpdateOrgPoolOK with default headers values +func NewUpdateOrgPoolOK() *UpdateOrgPoolOK { + return &UpdateOrgPoolOK{} +} + +/* +UpdateOrgPoolOK describes a response with status code 200, with default header values. + +Pool +*/ +type UpdateOrgPoolOK struct { + Payload garm_params.Pool +} + +// IsSuccess returns true when this update org pool o k response has a 2xx status code +func (o *UpdateOrgPoolOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update org pool o k response has a 3xx status code +func (o *UpdateOrgPoolOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org pool o k response has a 4xx status code +func (o *UpdateOrgPoolOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update org pool o k response has a 5xx status code +func (o *UpdateOrgPoolOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update org pool o k response a status code equal to that given +func (o *UpdateOrgPoolOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update org pool o k response +func (o *UpdateOrgPoolOK) Code() int { + return 200 +} + +func (o *UpdateOrgPoolOK) Error() string { + return fmt.Sprintf("[PUT /organizations/{orgID}/pools/{poolID}][%d] updateOrgPoolOK %+v", 200, o.Payload) +} + +func (o *UpdateOrgPoolOK) String() string { + return fmt.Sprintf("[PUT /organizations/{orgID}/pools/{poolID}][%d] updateOrgPoolOK %+v", 200, o.Payload) +} + +func (o *UpdateOrgPoolOK) GetPayload() garm_params.Pool { + return o.Payload +} + +func (o *UpdateOrgPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateOrgPoolDefault creates a UpdateOrgPoolDefault with default headers values +func NewUpdateOrgPoolDefault(code int) *UpdateOrgPoolDefault { + return &UpdateOrgPoolDefault{ + _statusCode: code, + } +} + +/* +UpdateOrgPoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type UpdateOrgPoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this update org pool default response has a 2xx status code +func (o *UpdateOrgPoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update org pool default response has a 3xx status code +func (o *UpdateOrgPoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update org pool default response has a 4xx status code +func (o *UpdateOrgPoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update org pool default response has a 5xx status code +func (o *UpdateOrgPoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update org pool default response a status code equal to that given +func (o *UpdateOrgPoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the update org pool default response +func (o *UpdateOrgPoolDefault) Code() int { + return o._statusCode +} + +func (o *UpdateOrgPoolDefault) Error() string { + return fmt.Sprintf("[PUT /organizations/{orgID}/pools/{poolID}][%d] UpdateOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *UpdateOrgPoolDefault) String() string { + return fmt.Sprintf("[PUT /organizations/{orgID}/pools/{poolID}][%d] UpdateOrgPool default %+v", o._statusCode, o.Payload) +} + +func (o *UpdateOrgPoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *UpdateOrgPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/organizations/update_org_responses.go b/client/organizations/update_org_responses.go new file mode 100644 index 00000000..2275a545 --- /dev/null +++ b/client/organizations/update_org_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organizations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// UpdateOrgReader is a Reader for the UpdateOrg structure. +type UpdateOrgReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateOrgReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateOrgOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewUpdateOrgDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewUpdateOrgOK creates a UpdateOrgOK with default headers values +func NewUpdateOrgOK() *UpdateOrgOK { + return &UpdateOrgOK{} +} + +/* +UpdateOrgOK describes a response with status code 200, with default header values. + +Organization +*/ +type UpdateOrgOK struct { + Payload garm_params.Organization +} + +// IsSuccess returns true when this update org o k response has a 2xx status code +func (o *UpdateOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update org o k response has a 3xx status code +func (o *UpdateOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org o k response has a 4xx status code +func (o *UpdateOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update org o k response has a 5xx status code +func (o *UpdateOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update org o k response a status code equal to that given +func (o *UpdateOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update org o k response +func (o *UpdateOrgOK) Code() int { + return 200 +} + +func (o *UpdateOrgOK) Error() string { + return fmt.Sprintf("[PUT /organizations/{orgID}][%d] updateOrgOK %+v", 200, o.Payload) +} + +func (o *UpdateOrgOK) String() string { + return fmt.Sprintf("[PUT /organizations/{orgID}][%d] updateOrgOK %+v", 200, o.Payload) +} + +func (o *UpdateOrgOK) GetPayload() garm_params.Organization { + return o.Payload +} + +func (o *UpdateOrgOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateOrgDefault creates a UpdateOrgDefault with default headers values +func NewUpdateOrgDefault(code int) *UpdateOrgDefault { + return &UpdateOrgDefault{ + _statusCode: code, + } +} + +/* +UpdateOrgDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type UpdateOrgDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this update org default response has a 2xx status code +func (o *UpdateOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update org default response has a 3xx status code +func (o *UpdateOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update org default response has a 4xx status code +func (o *UpdateOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update org default response has a 5xx status code +func (o *UpdateOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update org default response a status code equal to that given +func (o *UpdateOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the update org default response +func (o *UpdateOrgDefault) Code() int { + return o._statusCode +} + +func (o *UpdateOrgDefault) Error() string { + return fmt.Sprintf("[PUT /organizations/{orgID}][%d] UpdateOrg default %+v", o._statusCode, o.Payload) +} + +func (o *UpdateOrgDefault) String() string { + return fmt.Sprintf("[PUT /organizations/{orgID}][%d] UpdateOrg default %+v", o._statusCode, o.Payload) +} + +func (o *UpdateOrgDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *UpdateOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/pools/delete_pool_parameters.go b/client/pools/delete_pool_parameters.go new file mode 100644 index 00000000..4524703d --- /dev/null +++ b/client/pools/delete_pool_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeletePoolParams creates a new DeletePoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeletePoolParams() *DeletePoolParams { + return &DeletePoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeletePoolParamsWithTimeout creates a new DeletePoolParams object +// with the ability to set a timeout on a request. +func NewDeletePoolParamsWithTimeout(timeout time.Duration) *DeletePoolParams { + return &DeletePoolParams{ + timeout: timeout, + } +} + +// NewDeletePoolParamsWithContext creates a new DeletePoolParams object +// with the ability to set a context for a request. +func NewDeletePoolParamsWithContext(ctx context.Context) *DeletePoolParams { + return &DeletePoolParams{ + Context: ctx, + } +} + +// NewDeletePoolParamsWithHTTPClient creates a new DeletePoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeletePoolParamsWithHTTPClient(client *http.Client) *DeletePoolParams { + return &DeletePoolParams{ + HTTPClient: client, + } +} + +/* +DeletePoolParams contains all the parameters to send to the API endpoint + + for the delete pool operation. + + Typically these are written to a http.Request. +*/ +type DeletePoolParams struct { + + /* PoolID. + + ID of the pool to delete. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeletePoolParams) WithDefaults() *DeletePoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeletePoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete pool params +func (o *DeletePoolParams) WithTimeout(timeout time.Duration) *DeletePoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete pool params +func (o *DeletePoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete pool params +func (o *DeletePoolParams) WithContext(ctx context.Context) *DeletePoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete pool params +func (o *DeletePoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete pool params +func (o *DeletePoolParams) WithHTTPClient(client *http.Client) *DeletePoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete pool params +func (o *DeletePoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithPoolID adds the poolID to the delete pool params +func (o *DeletePoolParams) WithPoolID(poolID string) *DeletePoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the delete pool params +func (o *DeletePoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *DeletePoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/pools/delete_pool_responses.go b/client/pools/delete_pool_responses.go new file mode 100644 index 00000000..a556eaef --- /dev/null +++ b/client/pools/delete_pool_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" +) + +// DeletePoolReader is a Reader for the DeletePool structure. +type DeletePoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeletePoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + result := NewDeletePoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result +} + +// NewDeletePoolDefault creates a DeletePoolDefault with default headers values +func NewDeletePoolDefault(code int) *DeletePoolDefault { + return &DeletePoolDefault{ + _statusCode: code, + } +} + +/* +DeletePoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type DeletePoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this delete pool default response has a 2xx status code +func (o *DeletePoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete pool default response has a 3xx status code +func (o *DeletePoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete pool default response has a 4xx status code +func (o *DeletePoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete pool default response has a 5xx status code +func (o *DeletePoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete pool default response a status code equal to that given +func (o *DeletePoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the delete pool default response +func (o *DeletePoolDefault) Code() int { + return o._statusCode +} + +func (o *DeletePoolDefault) Error() string { + return fmt.Sprintf("[DELETE /pools/{poolID}][%d] DeletePool default %+v", o._statusCode, o.Payload) +} + +func (o *DeletePoolDefault) String() string { + return fmt.Sprintf("[DELETE /pools/{poolID}][%d] DeletePool default %+v", o._statusCode, o.Payload) +} + +func (o *DeletePoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *DeletePoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/pools/get_pool_parameters.go b/client/pools/get_pool_parameters.go new file mode 100644 index 00000000..c4871e02 --- /dev/null +++ b/client/pools/get_pool_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetPoolParams creates a new GetPoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPoolParams() *GetPoolParams { + return &GetPoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPoolParamsWithTimeout creates a new GetPoolParams object +// with the ability to set a timeout on a request. +func NewGetPoolParamsWithTimeout(timeout time.Duration) *GetPoolParams { + return &GetPoolParams{ + timeout: timeout, + } +} + +// NewGetPoolParamsWithContext creates a new GetPoolParams object +// with the ability to set a context for a request. +func NewGetPoolParamsWithContext(ctx context.Context) *GetPoolParams { + return &GetPoolParams{ + Context: ctx, + } +} + +// NewGetPoolParamsWithHTTPClient creates a new GetPoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPoolParamsWithHTTPClient(client *http.Client) *GetPoolParams { + return &GetPoolParams{ + HTTPClient: client, + } +} + +/* +GetPoolParams contains all the parameters to send to the API endpoint + + for the get pool operation. + + Typically these are written to a http.Request. +*/ +type GetPoolParams struct { + + /* PoolID. + + ID of the pool to fetch. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPoolParams) WithDefaults() *GetPoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get pool params +func (o *GetPoolParams) WithTimeout(timeout time.Duration) *GetPoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get pool params +func (o *GetPoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get pool params +func (o *GetPoolParams) WithContext(ctx context.Context) *GetPoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get pool params +func (o *GetPoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get pool params +func (o *GetPoolParams) WithHTTPClient(client *http.Client) *GetPoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get pool params +func (o *GetPoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithPoolID adds the poolID to the get pool params +func (o *GetPoolParams) WithPoolID(poolID string) *GetPoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the get pool params +func (o *GetPoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/pools/get_pool_responses.go b/client/pools/get_pool_responses.go new file mode 100644 index 00000000..22ee22d5 --- /dev/null +++ b/client/pools/get_pool_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// GetPoolReader is a Reader for the GetPool structure. +type GetPoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPoolOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetPoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetPoolOK creates a GetPoolOK with default headers values +func NewGetPoolOK() *GetPoolOK { + return &GetPoolOK{} +} + +/* +GetPoolOK describes a response with status code 200, with default header values. + +Pool +*/ +type GetPoolOK struct { + Payload garm_params.Pool +} + +// IsSuccess returns true when this get pool o k response has a 2xx status code +func (o *GetPoolOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pool o k response has a 3xx status code +func (o *GetPoolOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pool o k response has a 4xx status code +func (o *GetPoolOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pool o k response has a 5xx status code +func (o *GetPoolOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pool o k response a status code equal to that given +func (o *GetPoolOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pool o k response +func (o *GetPoolOK) Code() int { + return 200 +} + +func (o *GetPoolOK) Error() string { + return fmt.Sprintf("[GET /pools/{poolID}][%d] getPoolOK %+v", 200, o.Payload) +} + +func (o *GetPoolOK) String() string { + return fmt.Sprintf("[GET /pools/{poolID}][%d] getPoolOK %+v", 200, o.Payload) +} + +func (o *GetPoolOK) GetPayload() garm_params.Pool { + return o.Payload +} + +func (o *GetPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPoolDefault creates a GetPoolDefault with default headers values +func NewGetPoolDefault(code int) *GetPoolDefault { + return &GetPoolDefault{ + _statusCode: code, + } +} + +/* +GetPoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type GetPoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this get pool default response has a 2xx status code +func (o *GetPoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pool default response has a 3xx status code +func (o *GetPoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pool default response has a 4xx status code +func (o *GetPoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pool default response has a 5xx status code +func (o *GetPoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pool default response a status code equal to that given +func (o *GetPoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the get pool default response +func (o *GetPoolDefault) Code() int { + return o._statusCode +} + +func (o *GetPoolDefault) Error() string { + return fmt.Sprintf("[GET /pools/{poolID}][%d] GetPool default %+v", o._statusCode, o.Payload) +} + +func (o *GetPoolDefault) String() string { + return fmt.Sprintf("[GET /pools/{poolID}][%d] GetPool default %+v", o._statusCode, o.Payload) +} + +func (o *GetPoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *GetPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/pools/list_pools_parameters.go b/client/pools/list_pools_parameters.go new file mode 100644 index 00000000..361dec69 --- /dev/null +++ b/client/pools/list_pools_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListPoolsParams creates a new ListPoolsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListPoolsParams() *ListPoolsParams { + return &ListPoolsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListPoolsParamsWithTimeout creates a new ListPoolsParams object +// with the ability to set a timeout on a request. +func NewListPoolsParamsWithTimeout(timeout time.Duration) *ListPoolsParams { + return &ListPoolsParams{ + timeout: timeout, + } +} + +// NewListPoolsParamsWithContext creates a new ListPoolsParams object +// with the ability to set a context for a request. +func NewListPoolsParamsWithContext(ctx context.Context) *ListPoolsParams { + return &ListPoolsParams{ + Context: ctx, + } +} + +// NewListPoolsParamsWithHTTPClient creates a new ListPoolsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListPoolsParamsWithHTTPClient(client *http.Client) *ListPoolsParams { + return &ListPoolsParams{ + HTTPClient: client, + } +} + +/* +ListPoolsParams contains all the parameters to send to the API endpoint + + for the list pools operation. + + Typically these are written to a http.Request. +*/ +type ListPoolsParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPoolsParams) WithDefaults() *ListPoolsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPoolsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list pools params +func (o *ListPoolsParams) WithTimeout(timeout time.Duration) *ListPoolsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list pools params +func (o *ListPoolsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list pools params +func (o *ListPoolsParams) WithContext(ctx context.Context) *ListPoolsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list pools params +func (o *ListPoolsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list pools params +func (o *ListPoolsParams) WithHTTPClient(client *http.Client) *ListPoolsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list pools params +func (o *ListPoolsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListPoolsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/pools/list_pools_responses.go b/client/pools/list_pools_responses.go new file mode 100644 index 00000000..fa2701d6 --- /dev/null +++ b/client/pools/list_pools_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListPoolsReader is a Reader for the ListPools structure. +type ListPoolsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListPoolsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListPoolsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListPoolsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListPoolsOK creates a ListPoolsOK with default headers values +func NewListPoolsOK() *ListPoolsOK { + return &ListPoolsOK{} +} + +/* +ListPoolsOK describes a response with status code 200, with default header values. + +Pools +*/ +type ListPoolsOK struct { + Payload garm_params.Pools +} + +// IsSuccess returns true when this list pools o k response has a 2xx status code +func (o *ListPoolsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list pools o k response has a 3xx status code +func (o *ListPoolsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list pools o k response has a 4xx status code +func (o *ListPoolsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list pools o k response has a 5xx status code +func (o *ListPoolsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list pools o k response a status code equal to that given +func (o *ListPoolsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list pools o k response +func (o *ListPoolsOK) Code() int { + return 200 +} + +func (o *ListPoolsOK) Error() string { + return fmt.Sprintf("[GET /pools][%d] listPoolsOK %+v", 200, o.Payload) +} + +func (o *ListPoolsOK) String() string { + return fmt.Sprintf("[GET /pools][%d] listPoolsOK %+v", 200, o.Payload) +} + +func (o *ListPoolsOK) GetPayload() garm_params.Pools { + return o.Payload +} + +func (o *ListPoolsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListPoolsDefault creates a ListPoolsDefault with default headers values +func NewListPoolsDefault(code int) *ListPoolsDefault { + return &ListPoolsDefault{ + _statusCode: code, + } +} + +/* +ListPoolsDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type ListPoolsDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list pools default response has a 2xx status code +func (o *ListPoolsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list pools default response has a 3xx status code +func (o *ListPoolsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list pools default response has a 4xx status code +func (o *ListPoolsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list pools default response has a 5xx status code +func (o *ListPoolsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list pools default response a status code equal to that given +func (o *ListPoolsDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list pools default response +func (o *ListPoolsDefault) Code() int { + return o._statusCode +} + +func (o *ListPoolsDefault) Error() string { + return fmt.Sprintf("[GET /pools][%d] ListPools default %+v", o._statusCode, o.Payload) +} + +func (o *ListPoolsDefault) String() string { + return fmt.Sprintf("[GET /pools][%d] ListPools default %+v", o._statusCode, o.Payload) +} + +func (o *ListPoolsDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListPoolsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/pools/pools_client.go b/client/pools/pools_client.go new file mode 100644 index 00000000..f8b18359 --- /dev/null +++ b/client/pools/pools_client.go @@ -0,0 +1,191 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new pools API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for pools API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + DeletePool(params *DeletePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error + + GetPool(params *GetPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPoolOK, error) + + ListPools(params *ListPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPoolsOK, error) + + UpdatePool(params *UpdatePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdatePoolOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +DeletePool deletes pool by ID +*/ +func (a *Client) DeletePool(params *DeletePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error { + // TODO: Validate the params before sending + if params == nil { + params = NewDeletePoolParams() + } + op := &runtime.ClientOperation{ + ID: "DeletePool", + Method: "DELETE", + PathPattern: "/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeletePoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + _, err := a.transport.Submit(op) + if err != nil { + return err + } + return nil +} + +/* +GetPool gets pool by ID +*/ +func (a *Client) GetPool(params *GetPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPoolOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetPoolParams() + } + op := &runtime.ClientOperation{ + ID: "GetPool", + Method: "GET", + PathPattern: "/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetPoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*GetPoolOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetPoolDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +ListPools lists all pools +*/ +func (a *Client) ListPools(params *ListPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPoolsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListPoolsParams() + } + op := &runtime.ClientOperation{ + ID: "ListPools", + Method: "GET", + PathPattern: "/pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListPoolsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListPoolsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListPoolsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +UpdatePool updates pool by ID +*/ +func (a *Client) UpdatePool(params *UpdatePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdatePoolOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdatePoolParams() + } + op := &runtime.ClientOperation{ + ID: "UpdatePool", + Method: "PUT", + PathPattern: "/pools/{poolID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &UpdatePoolReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*UpdatePoolOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*UpdatePoolDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/pools/update_pool_parameters.go b/client/pools/update_pool_parameters.go new file mode 100644 index 00000000..75bf5c96 --- /dev/null +++ b/client/pools/update_pool_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + garm_params "github.com/cloudbase/garm/params" +) + +// NewUpdatePoolParams creates a new UpdatePoolParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUpdatePoolParams() *UpdatePoolParams { + return &UpdatePoolParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdatePoolParamsWithTimeout creates a new UpdatePoolParams object +// with the ability to set a timeout on a request. +func NewUpdatePoolParamsWithTimeout(timeout time.Duration) *UpdatePoolParams { + return &UpdatePoolParams{ + timeout: timeout, + } +} + +// NewUpdatePoolParamsWithContext creates a new UpdatePoolParams object +// with the ability to set a context for a request. +func NewUpdatePoolParamsWithContext(ctx context.Context) *UpdatePoolParams { + return &UpdatePoolParams{ + Context: ctx, + } +} + +// NewUpdatePoolParamsWithHTTPClient creates a new UpdatePoolParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdatePoolParamsWithHTTPClient(client *http.Client) *UpdatePoolParams { + return &UpdatePoolParams{ + HTTPClient: client, + } +} + +/* +UpdatePoolParams contains all the parameters to send to the API endpoint + + for the update pool operation. + + Typically these are written to a http.Request. +*/ +type UpdatePoolParams struct { + + /* Body. + + Parameters to update the pool with. + */ + Body garm_params.UpdatePoolParams + + /* PoolID. + + ID of the pool to update. + */ + PoolID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePoolParams) WithDefaults() *UpdatePoolParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update pool params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePoolParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update pool params +func (o *UpdatePoolParams) WithTimeout(timeout time.Duration) *UpdatePoolParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update pool params +func (o *UpdatePoolParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update pool params +func (o *UpdatePoolParams) WithContext(ctx context.Context) *UpdatePoolParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update pool params +func (o *UpdatePoolParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update pool params +func (o *UpdatePoolParams) WithHTTPClient(client *http.Client) *UpdatePoolParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update pool params +func (o *UpdatePoolParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the update pool params +func (o *UpdatePoolParams) WithBody(body garm_params.UpdatePoolParams) *UpdatePoolParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the update pool params +func (o *UpdatePoolParams) SetBody(body garm_params.UpdatePoolParams) { + o.Body = body +} + +// WithPoolID adds the poolID to the update pool params +func (o *UpdatePoolParams) WithPoolID(poolID string) *UpdatePoolParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the update pool params +func (o *UpdatePoolParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdatePoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param poolID + if err := r.SetPathParam("poolID", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/pools/update_pool_responses.go b/client/pools/update_pool_responses.go new file mode 100644 index 00000000..62e83a95 --- /dev/null +++ b/client/pools/update_pool_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// UpdatePoolReader is a Reader for the UpdatePool structure. +type UpdatePoolReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdatePoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdatePoolOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewUpdatePoolDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewUpdatePoolOK creates a UpdatePoolOK with default headers values +func NewUpdatePoolOK() *UpdatePoolOK { + return &UpdatePoolOK{} +} + +/* +UpdatePoolOK describes a response with status code 200, with default header values. + +Pool +*/ +type UpdatePoolOK struct { + Payload garm_params.Pool +} + +// IsSuccess returns true when this update pool o k response has a 2xx status code +func (o *UpdatePoolOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update pool o k response has a 3xx status code +func (o *UpdatePoolOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pool o k response has a 4xx status code +func (o *UpdatePoolOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update pool o k response has a 5xx status code +func (o *UpdatePoolOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update pool o k response a status code equal to that given +func (o *UpdatePoolOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update pool o k response +func (o *UpdatePoolOK) Code() int { + return 200 +} + +func (o *UpdatePoolOK) Error() string { + return fmt.Sprintf("[PUT /pools/{poolID}][%d] updatePoolOK %+v", 200, o.Payload) +} + +func (o *UpdatePoolOK) String() string { + return fmt.Sprintf("[PUT /pools/{poolID}][%d] updatePoolOK %+v", 200, o.Payload) +} + +func (o *UpdatePoolOK) GetPayload() garm_params.Pool { + return o.Payload +} + +func (o *UpdatePoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdatePoolDefault creates a UpdatePoolDefault with default headers values +func NewUpdatePoolDefault(code int) *UpdatePoolDefault { + return &UpdatePoolDefault{ + _statusCode: code, + } +} + +/* +UpdatePoolDefault describes a response with status code -1, with default header values. + +APIErrorResponse +*/ +type UpdatePoolDefault struct { + _statusCode int + + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this update pool default response has a 2xx status code +func (o *UpdatePoolDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update pool default response has a 3xx status code +func (o *UpdatePoolDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update pool default response has a 4xx status code +func (o *UpdatePoolDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update pool default response has a 5xx status code +func (o *UpdatePoolDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update pool default response a status code equal to that given +func (o *UpdatePoolDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the update pool default response +func (o *UpdatePoolDefault) Code() int { + return o._statusCode +} + +func (o *UpdatePoolDefault) Error() string { + return fmt.Sprintf("[PUT /pools/{poolID}][%d] UpdatePool default %+v", o._statusCode, o.Payload) +} + +func (o *UpdatePoolDefault) String() string { + return fmt.Sprintf("[PUT /pools/{poolID}][%d] UpdatePool default %+v", o._statusCode, o.Payload) +} + +func (o *UpdatePoolDefault) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *UpdatePoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/providers/list_providers_parameters.go b/client/providers/list_providers_parameters.go new file mode 100644 index 00000000..e411b1aa --- /dev/null +++ b/client/providers/list_providers_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package providers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListProvidersParams creates a new ListProvidersParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListProvidersParams() *ListProvidersParams { + return &ListProvidersParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListProvidersParamsWithTimeout creates a new ListProvidersParams object +// with the ability to set a timeout on a request. +func NewListProvidersParamsWithTimeout(timeout time.Duration) *ListProvidersParams { + return &ListProvidersParams{ + timeout: timeout, + } +} + +// NewListProvidersParamsWithContext creates a new ListProvidersParams object +// with the ability to set a context for a request. +func NewListProvidersParamsWithContext(ctx context.Context) *ListProvidersParams { + return &ListProvidersParams{ + Context: ctx, + } +} + +// NewListProvidersParamsWithHTTPClient creates a new ListProvidersParams object +// with the ability to set a custom HTTPClient for a request. +func NewListProvidersParamsWithHTTPClient(client *http.Client) *ListProvidersParams { + return &ListProvidersParams{ + HTTPClient: client, + } +} + +/* +ListProvidersParams contains all the parameters to send to the API endpoint + + for the list providers operation. + + Typically these are written to a http.Request. +*/ +type ListProvidersParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list providers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListProvidersParams) WithDefaults() *ListProvidersParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list providers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListProvidersParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list providers params +func (o *ListProvidersParams) WithTimeout(timeout time.Duration) *ListProvidersParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list providers params +func (o *ListProvidersParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list providers params +func (o *ListProvidersParams) WithContext(ctx context.Context) *ListProvidersParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list providers params +func (o *ListProvidersParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list providers params +func (o *ListProvidersParams) WithHTTPClient(client *http.Client) *ListProvidersParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list providers params +func (o *ListProvidersParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListProvidersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/providers/list_providers_responses.go b/client/providers/list_providers_responses.go new file mode 100644 index 00000000..e80551d1 --- /dev/null +++ b/client/providers/list_providers_responses.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package providers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// ListProvidersReader is a Reader for the ListProviders structure. +type ListProvidersReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListProvidersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListProvidersOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListProvidersBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /providers] ListProviders", response, response.Code()) + } +} + +// NewListProvidersOK creates a ListProvidersOK with default headers values +func NewListProvidersOK() *ListProvidersOK { + return &ListProvidersOK{} +} + +/* +ListProvidersOK describes a response with status code 200, with default header values. + +Providers +*/ +type ListProvidersOK struct { + Payload garm_params.Providers +} + +// IsSuccess returns true when this list providers o k response has a 2xx status code +func (o *ListProvidersOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list providers o k response has a 3xx status code +func (o *ListProvidersOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list providers o k response has a 4xx status code +func (o *ListProvidersOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list providers o k response has a 5xx status code +func (o *ListProvidersOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list providers o k response a status code equal to that given +func (o *ListProvidersOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list providers o k response +func (o *ListProvidersOK) Code() int { + return 200 +} + +func (o *ListProvidersOK) Error() string { + return fmt.Sprintf("[GET /providers][%d] listProvidersOK %+v", 200, o.Payload) +} + +func (o *ListProvidersOK) String() string { + return fmt.Sprintf("[GET /providers][%d] listProvidersOK %+v", 200, o.Payload) +} + +func (o *ListProvidersOK) GetPayload() garm_params.Providers { + return o.Payload +} + +func (o *ListProvidersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListProvidersBadRequest creates a ListProvidersBadRequest with default headers values +func NewListProvidersBadRequest() *ListProvidersBadRequest { + return &ListProvidersBadRequest{} +} + +/* +ListProvidersBadRequest describes a response with status code 400, with default header values. + +APIErrorResponse +*/ +type ListProvidersBadRequest struct { + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this list providers bad request response has a 2xx status code +func (o *ListProvidersBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list providers bad request response has a 3xx status code +func (o *ListProvidersBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list providers bad request response has a 4xx status code +func (o *ListProvidersBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list providers bad request response has a 5xx status code +func (o *ListProvidersBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list providers bad request response a status code equal to that given +func (o *ListProvidersBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list providers bad request response +func (o *ListProvidersBadRequest) Code() int { + return 400 +} + +func (o *ListProvidersBadRequest) Error() string { + return fmt.Sprintf("[GET /providers][%d] listProvidersBadRequest %+v", 400, o.Payload) +} + +func (o *ListProvidersBadRequest) String() string { + return fmt.Sprintf("[GET /providers][%d] listProvidersBadRequest %+v", 400, o.Payload) +} + +func (o *ListProvidersBadRequest) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *ListProvidersBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/providers/providers_client.go b/client/providers/providers_client.go new file mode 100644 index 00000000..3ddfead8 --- /dev/null +++ b/client/providers/providers_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package providers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new providers API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for providers API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ListProviders(params *ListProvidersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListProvidersOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +ListProviders lists all providers +*/ +func (a *Client) ListProviders(params *ListProvidersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListProvidersOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListProvidersParams() + } + op := &runtime.ClientOperation{ + ID: "ListProviders", + Method: "GET", + PathPattern: "/providers", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListProvidersReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListProvidersOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for ListProviders: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +}