From 9c77529698d5fdb9b8c24ba29934ba9efe8e1a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Mon, 29 Apr 2024 09:57:23 +0000 Subject: [PATCH] wip: creating system and associate operator --- api/api.yml | 107 ++++-- internal/api/adapters/db/db.go | 2 + internal/api/adapters/db/systems.go | 50 +++ internal/api/controllers/systems.go | 51 ++- internal/api/models/operator.go | 3 + internal/api/models/system.go | 12 +- internal/api/ports/systems.go | 20 +- internal/api/services/api.go | 76 +++++ internal/utils/utils.go | 5 + pkg/apis/api.go | 20 ++ pkg/apis/client.gen.go | 492 +++++++++++++++++++++++++++- pkg/apis/models.gen.go | 129 +++++--- pkg/apis/server.gen.go | 330 ++++++++++++++++++- 13 files changed, 1177 insertions(+), 120 deletions(-) create mode 100644 internal/api/adapters/db/systems.go diff --git a/api/api.yml b/api/api.yml index 4ac2f933..06256d87 100644 --- a/api/api.yml +++ b/api/api.yml @@ -809,10 +809,7 @@ paths: produces: - "application/json" requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/System" + $ref: "#/components/requestBodies/CreateSystem" responses: "201": description: Created @@ -828,32 +825,22 @@ paths: /systems/{systemId}: get: - summary: List all managed systems. + summary: Gets a system by ID operationId: getSystem - tags: - - Systems - description: |- - Returns a list of managed systems. parameters: - - name: systemId - in: path - required: true - description: The id of the system to retrieve - schema: - type: string + - $ref: "#/components/parameters/systemId" responses: "200": - description: A paginated response of all systems + description: Successful + content: + application/json: + schema: + $ref: "#/components/schemas/System" put: summary: Updates a system by ID operationId: updateSystem parameters: - - name: systemId - in: path - required: true - description: The id of the system to update - schema: - type: string + - $ref: "#/components/parameters/systemId" requestBody: content: application/json: @@ -867,16 +854,47 @@ paths: schema: $ref: "#/components/schemas/System" - deleted: + delete: summary: Deletes a system by ID operationId: deleteSystem parameters: - - name: systemId - in: path - required: true - description: The id of the system to delete - schema: - type: string + - $ref: "#/components/parameters/systemId" + responses: + "204": + description: Successful + + /systems/{systemId}/operator: + get: + summary: Gets the operator for a system + operationId: getSystemOperator + parameters: + - $ref: "#/components/parameters/systemId" + responses: + "200": + description: Successful + content: + application/json: + schema: + $ref: "#/components/schemas/Operator" + put: + summary: Updates the operator for a system + operationId: updateSystemOperator + parameters: + - $ref: "#/components/parameters/systemId" + requestBody: + $ref: "#/components/requestBodies/UpdateSystemOperator" + responses: + "200": + description: Successful + content: + application/json: + schema: + $ref: "#/components/schemas/Operator" + delete: + summary: Deletes the operator for a system + operationId: deleteSystemOperator + parameters: + - $ref: "#/components/parameters/systemId" responses: "204": description: Successful @@ -893,6 +911,14 @@ definitions: components: parameters: + systemId: + in: path + name: systemId + required: true + schema: + type: string + format: uuid + description: The id of the system to retrieve. teamId: in: path name: teamId @@ -954,6 +980,29 @@ components: description: The id of the operator to retrieve. requestBodies: + CreateSystem: + content: + application/json: + schema: + type: object + required: + - name + properties: + name: + type: string + description: + type: string + UpdateSystemOperator: + content: + application/json: + schema: + type: object + required: + - operatorId + properties: + operatorId: + type: string + format: uuid CreateTeam: content: application/json: diff --git a/internal/api/adapters/db/db.go b/internal/api/adapters/db/db.go index 7dab0008..eeef267a 100644 --- a/internal/api/adapters/db/db.go +++ b/internal/api/adapters/db/db.go @@ -11,6 +11,7 @@ var ( _ ports.Users = (*DB)(nil) _ ports.Accounts = (*DB)(nil) _ ports.Operators = (*DB)(nil) + _ ports.Systems = (*DB)(nil) ) // DB ... @@ -29,5 +30,6 @@ func (db *DB) RunMigrations() error { &models.User{}, &models.Account{}, &models.Operator{}, + &models.System{}, ) } diff --git a/internal/api/adapters/db/systems.go b/internal/api/adapters/db/systems.go new file mode 100644 index 00000000..4279362c --- /dev/null +++ b/internal/api/adapters/db/systems.go @@ -0,0 +1,50 @@ +package db + +import ( + "context" + + "github.com/google/uuid" + "github.com/zeiss/typhoon/internal/api/models" +) + +// GetSystem ... +func (db *DB) GetSystem(ctx context.Context, id uuid.UUID) (*models.System, error) { + system := &models.System{} + if err := db.conn.Where("id = ?", id).Preload("Operator").First(system).Error; err != nil { + return nil, err + } + + return system, nil +} + +// CreateSystem ... +func (db *DB) CreateSystem(ctx context.Context, system *models.System) error { + return db.conn.WithContext(ctx).Create(system).Error +} + +// ListSystems ... +func (db *DB) ListSystems(ctx context.Context, pagination models.Pagination[models.System]) (models.Pagination[models.System], error) { + systems := []models.System{} + + err := db.conn.WithContext(ctx).Scopes(models.Paginate(&systems, &pagination, db.conn)).Limit(pagination.Limit).Offset(pagination.Offset).Find(&systems).Error + if err != nil { + return pagination, err + } + pagination.Rows = systems + + return pagination, nil +} + +// DeleteSystem ... +func (db *DB) DeleteSystem(ctx context.Context, id uuid.UUID) error { + return db.conn.WithContext(ctx).Delete(&models.System{}, id).Error +} + +// UpdateSystem ... +func (db *DB) UpdateSystem(ctx context.Context, system *models.System) (*models.System, error) { + if err := db.conn.WithContext(ctx).Save(system).Error; err != nil { + return nil, err + } + + return system, nil +} diff --git a/internal/api/controllers/systems.go b/internal/api/controllers/systems.go index 9a1e09b9..b20cdfe8 100644 --- a/internal/api/controllers/systems.go +++ b/internal/api/controllers/systems.go @@ -1,6 +1,12 @@ package controllers -import "github.com/zeiss/typhoon/internal/api/ports" +import ( + "context" + + "github.com/google/uuid" + "github.com/zeiss/typhoon/internal/api/models" + "github.com/zeiss/typhoon/internal/api/ports" +) // SystemsController ... type SystemsController struct { @@ -8,6 +14,47 @@ type SystemsController struct { } // NewSystemsController ... -func NewSystemsController(db ports.Teams) *SystemsController { +func NewSystemsController(db ports.Systems) *SystemsController { return &SystemsController{db} } + +// CreateSystem ... +func (c *SystemsController) CreateSystem(ctx context.Context, name, description string) (*models.System, error) { + system := &models.System{ + Name: name, + Description: description, + } + + if err := c.db.CreateSystem(ctx, system); err != nil { + return nil, err + } + + return system, nil +} + +// DeleteSystem ... +func (c *SystemsController) DeleteSystem(ctx context.Context, id uuid.UUID) error { + return c.db.DeleteSystem(ctx, id) +} + +// GetSystem ... +func (c *SystemsController) GetSystem(ctx context.Context, id uuid.UUID) (*models.System, error) { + return c.db.GetSystem(ctx, id) +} + +// ListSystems ... +func (c *SystemsController) ListSystems(ctx context.Context, pagination models.Pagination[models.System]) (models.Pagination[models.System], error) { + return c.db.ListSystems(ctx, pagination) +} + +// UpdateSystemOperator ... +func (c *SystemsController) UpdateSystemOperator(ctx context.Context, systemId, operatorID uuid.UUID) (*models.System, error) { + system, err := c.db.GetSystem(ctx, systemId) + if err != nil { + return nil, err + } + + system.OperatorID = &operatorID + + return c.db.UpdateSystem(ctx, system) +} diff --git a/internal/api/models/operator.go b/internal/api/models/operator.go index fd29e6db..ce59c0c4 100644 --- a/internal/api/models/operator.go +++ b/internal/api/models/operator.go @@ -20,6 +20,9 @@ type Operator struct { Token Token `json:"token" gorm:"foreignKey:TokenID"` TokenID string `json:"token_id"` + // Systems is the list of systems that the operator has. + Systems []System `json:"systems" gorm:"many2many:operator_systems;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:SystemID"` + // Accounts is the list of accounts that the operator has. SigningKeys []NKey `json:"signing_keys" gorm:"many2many:operator_signing_keys;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:SigningKeyID"` diff --git a/internal/api/models/system.go b/internal/api/models/system.go index ad3f0a35..2146d122 100644 --- a/internal/api/models/system.go +++ b/internal/api/models/system.go @@ -13,15 +13,9 @@ type System struct { Name string `json:"name" gorm:"unique"` Description string `json:"description"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} - -// Cluster ... -type Cluster struct { - ID uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()"` - URL string `json:"url"` + // Operator is the operator that the system belongs to. + Operator Operator `json:"operator" gorm:"foreignKey:OperatorID"` + OperatorID *uuid.UUID `json:"operator_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` diff --git a/internal/api/ports/systems.go b/internal/api/ports/systems.go index b86079d1..f5bfeee5 100644 --- a/internal/api/ports/systems.go +++ b/internal/api/ports/systems.go @@ -1,4 +1,22 @@ package ports +import ( + "context" + + "github.com/google/uuid" + "github.com/zeiss/typhoon/internal/api/models" +) + // Systems is the interface that wraps the methods to access data. -type Systems interface{} +type Systems interface { + // CreateSystem creates a new system. + CreateSystem(ctx context.Context, system *models.System) error + // UpdateSystem updates a system. + UpdateSystem(ctx context.Context, system *models.System) (*models.System, error) + // GetSystem retrieves a system by its ID. + GetSystem(ctx context.Context, id uuid.UUID) (*models.System, error) + // ListSystems retrieves all systems. + ListSystems(ctx context.Context, pagination models.Pagination[models.System]) (models.Pagination[models.System], error) + // DeleteSystem deletes a system by its ID. + DeleteSystem(ctx context.Context, id uuid.UUID) error +} diff --git a/internal/api/services/api.go b/internal/api/services/api.go index d8a15f91..7252b1d9 100644 --- a/internal/api/services/api.go +++ b/internal/api/services/api.go @@ -5,6 +5,8 @@ import ( "context" "github.com/zeiss/typhoon/internal/api/controllers" + "github.com/zeiss/typhoon/internal/api/models" + "github.com/zeiss/typhoon/internal/utils" openapi "github.com/zeiss/typhoon/pkg/apis" ) @@ -27,6 +29,80 @@ func NewApiHandlers(systems *controllers.SystemsController, teams *controllers.T return &ApiHandlers{systems: systems, teams: teams, version: version, operators: operators, accounts: accounts, users: users} } +// CreateSystem ... +func (a *ApiHandlers) CreateSystem(ctx context.Context, req openapi.CreateSystemRequestObject) (openapi.CreateSystemResponseObject, error) { + system, err := a.systems.CreateSystem(ctx, req.Body.Name, *req.Body.Description) + if err != nil { + return nil, err + } + + return openapi.CreateSystem201JSONResponse(openapi.System{Id: &system.ID, Name: system.Name, Description: utils.StrPtr(system.Description)}), nil +} + +// GetSystem ... +func (a *ApiHandlers) GetSystem(ctx context.Context, req openapi.GetSystemRequestObject) (openapi.GetSystemResponseObject, error) { + system, err := a.systems.GetSystem(ctx, req.SystemId) + if err != nil { + return nil, err + } + + return openapi.GetSystem200JSONResponse(openapi.System{Id: &system.ID, Name: system.Name, Description: utils.StrPtr(system.Description), Operator: &openapi.Operator{Id: system.OperatorID}}), nil +} + +// GetSystemOperator ... +func (a *ApiHandlers) GetSystemOperator(ctx context.Context, req openapi.GetSystemOperatorRequestObject) (openapi.GetSystemOperatorResponseObject, error) { + system, err := a.systems.GetSystem(ctx, req.SystemId) + if err != nil { + return nil, err + } + + return openapi.GetSystemOperator200JSONResponse(openapi.Operator{Id: utils.PtrUUID(system.Operator.ID), Name: system.Operator.Name}), nil +} + +// DeleteSystem ... +func (a *ApiHandlers) DeleteSystem(ctx context.Context, req openapi.DeleteSystemRequestObject) (openapi.DeleteSystemResponseObject, error) { + err := a.systems.DeleteSystem(ctx, req.SystemId) + if err != nil { + return nil, err + } + + return openapi.DeleteSystem204Response(openapi.DeleteSystem204Response{}), nil +} + +// ListSystems ... +func (a *ApiHandlers) ListSystems(ctx context.Context, req openapi.ListSystemsRequestObject) (openapi.ListSystemsResponseObject, error) { + pagination := models.Pagination[models.System]{} + + result, err := a.systems.ListSystems(ctx, pagination) + if err != nil { + return nil, err + } + + systems := make([]openapi.System, 0, len(result.Rows)) + for _, system := range result.Rows { + systems = append(systems, openapi.System{ + Id: &system.ID, + Name: system.Name, + Description: utils.StrPtr(system.Description), + CreatedAt: &system.CreatedAt, + UpdatedAt: &system.UpdatedAt, + DeletedAt: &system.DeletedAt.Time, + }) + } + + return openapi.ListSystems200JSONResponse(openapi.ListSystems200JSONResponse{Results: &systems}), nil +} + +// UpdateSystemOperator ... +func (a *ApiHandlers) UpdateSystemOperator(ctx context.Context, req openapi.UpdateSystemOperatorRequestObject) (openapi.UpdateSystemOperatorResponseObject, error) { + system, err := a.systems.UpdateSystemOperator(ctx, req.SystemId, *&req.Body.OperatorId) + if err != nil { + return nil, err + } + + return openapi.UpdateSystemOperator200JSONResponse(openapi.UpdateSystemOperator200JSONResponse{Id: utils.PtrUUID(system.ID)}), nil +} + // CreateOperator ... func (a *ApiHandlers) CreateOperator(ctx context.Context, req openapi.CreateOperatorRequestObject) (openapi.CreateOperatorResponseObject, error) { operator, err := a.operators.CreateOperator(ctx, req.Body.Name) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 39498baf..8d5f34ed 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -11,3 +11,8 @@ func PtrInt(i int) *int { func PtrUUID(u uuid.UUID) *uuid.UUID { return &u } + +// StrPtr returns a pointer to a string. +func StrPtr(s string) *string { + return &s +} diff --git a/pkg/apis/api.go b/pkg/apis/api.go index 0add436c..4b7b337c 100644 --- a/pkg/apis/api.go +++ b/pkg/apis/api.go @@ -140,6 +140,26 @@ func (u *Unimplemented) UpdateSystem(ctx context.Context, request UpdateSystemRe return nil, errors.New("not implemented") } +// DeleteSystem ... +func (u *Unimplemented) DeleteSystem(ctx context.Context, request DeleteSystemRequestObject) (DeleteSystemResponseObject, error) { + return nil, errors.New("not implemented") +} + +// DeleteSystemOperator ... +func (u *Unimplemented) DeleteSystemOperator(ctx context.Context, request DeleteSystemOperatorRequestObject) (DeleteSystemOperatorResponseObject, error) { + return nil, errors.New("not implemented") +} + +// GetSystemOperator ... +func (u *Unimplemented) GetSystemOperator(ctx context.Context, request GetSystemOperatorRequestObject) (GetSystemOperatorResponseObject, error) { + return nil, errors.New("not implemented") +} + +// UpdateSystemOperator ... +func (u *Unimplemented) UpdateSystemOperator(ctx context.Context, request UpdateSystemOperatorRequestObject) (UpdateSystemOperatorResponseObject, error) { + return nil, errors.New("not implemented") +} + // ListTeams ... func (u *Unimplemented) ListTeams(ctx context.Context, request ListTeamsRequestObject) (ListTeamsResponseObject, error) { return nil, errors.New("not implemented") diff --git a/pkg/apis/client.gen.go b/pkg/apis/client.gen.go index c42eff26..1bb968c7 100644 --- a/pkg/apis/client.gen.go +++ b/pkg/apis/client.gen.go @@ -169,13 +169,27 @@ type ClientInterface interface { CreateSystem(ctx context.Context, body CreateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // DeleteSystem request + DeleteSystem(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetSystem request - GetSystem(ctx context.Context, systemId string, reqEditors ...RequestEditorFn) (*http.Response, error) + GetSystem(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) // UpdateSystemWithBody request with any body - UpdateSystemWithBody(ctx context.Context, systemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateSystemWithBody(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateSystem(ctx context.Context, systemId SystemId, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSystemOperator request + DeleteSystemOperator(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateSystem(ctx context.Context, systemId string, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetSystemOperator request + GetSystemOperator(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSystemOperatorWithBody request with any body + UpdateSystemOperatorWithBody(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateSystemOperator(ctx context.Context, systemId SystemId, body UpdateSystemOperatorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // ListTeams request ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -566,7 +580,19 @@ func (c *Client) CreateSystem(ctx context.Context, body CreateSystemJSONRequestB return c.Client.Do(req) } -func (c *Client) GetSystem(ctx context.Context, systemId string, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) DeleteSystem(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSystemRequest(c.Server, systemId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetSystem(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetSystemRequest(c.Server, systemId) if err != nil { return nil, err @@ -578,7 +604,7 @@ func (c *Client) GetSystem(ctx context.Context, systemId string, reqEditors ...R return c.Client.Do(req) } -func (c *Client) UpdateSystemWithBody(ctx context.Context, systemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateSystemWithBody(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateSystemRequestWithBody(c.Server, systemId, contentType, body) if err != nil { return nil, err @@ -590,7 +616,7 @@ func (c *Client) UpdateSystemWithBody(ctx context.Context, systemId string, cont return c.Client.Do(req) } -func (c *Client) UpdateSystem(ctx context.Context, systemId string, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateSystem(ctx context.Context, systemId SystemId, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateSystemRequest(c.Server, systemId, body) if err != nil { return nil, err @@ -602,6 +628,54 @@ func (c *Client) UpdateSystem(ctx context.Context, systemId string, body UpdateS return c.Client.Do(req) } +func (c *Client) DeleteSystemOperator(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSystemOperatorRequest(c.Server, systemId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetSystemOperator(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSystemOperatorRequest(c.Server, systemId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateSystemOperatorWithBody(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSystemOperatorRequestWithBody(c.Server, systemId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateSystemOperator(ctx context.Context, systemId SystemId, body UpdateSystemOperatorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSystemOperatorRequest(c.Server, systemId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListTeamsRequest(c.Server, params) if err != nil { @@ -1930,8 +2004,42 @@ func NewCreateSystemRequestWithBody(server string, contentType string, body io.R return req, nil } +// NewDeleteSystemRequest generates requests for DeleteSystem +func NewDeleteSystemRequest(server string, systemId SystemId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "systemId", runtime.ParamLocationPath, systemId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/systems/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewGetSystemRequest generates requests for GetSystem -func NewGetSystemRequest(server string, systemId string) (*http.Request, error) { +func NewGetSystemRequest(server string, systemId SystemId) (*http.Request, error) { var err error var pathParam0 string @@ -1965,7 +2073,7 @@ func NewGetSystemRequest(server string, systemId string) (*http.Request, error) } // NewUpdateSystemRequest calls the generic UpdateSystem builder with application/json body -func NewUpdateSystemRequest(server string, systemId string, body UpdateSystemJSONRequestBody) (*http.Request, error) { +func NewUpdateSystemRequest(server string, systemId SystemId, body UpdateSystemJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -1976,7 +2084,7 @@ func NewUpdateSystemRequest(server string, systemId string, body UpdateSystemJSO } // NewUpdateSystemRequestWithBody generates requests for UpdateSystem with any type of body -func NewUpdateSystemRequestWithBody(server string, systemId string, contentType string, body io.Reader) (*http.Request, error) { +func NewUpdateSystemRequestWithBody(server string, systemId SystemId, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -2011,6 +2119,121 @@ func NewUpdateSystemRequestWithBody(server string, systemId string, contentType return req, nil } +// NewDeleteSystemOperatorRequest generates requests for DeleteSystemOperator +func NewDeleteSystemOperatorRequest(server string, systemId SystemId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "systemId", runtime.ParamLocationPath, systemId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/systems/%s/operator", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSystemOperatorRequest generates requests for GetSystemOperator +func NewGetSystemOperatorRequest(server string, systemId SystemId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "systemId", runtime.ParamLocationPath, systemId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/systems/%s/operator", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateSystemOperatorRequest calls the generic UpdateSystemOperator builder with application/json body +func NewUpdateSystemOperatorRequest(server string, systemId SystemId, body UpdateSystemOperatorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateSystemOperatorRequestWithBody(server, systemId, "application/json", bodyReader) +} + +// NewUpdateSystemOperatorRequestWithBody generates requests for UpdateSystemOperator with any type of body +func NewUpdateSystemOperatorRequestWithBody(server string, systemId SystemId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "systemId", runtime.ParamLocationPath, systemId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/systems/%s/operator", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewListTeamsRequest generates requests for ListTeams func NewListTeamsRequest(server string, params *ListTeamsParams) (*http.Request, error) { var err error @@ -2896,13 +3119,27 @@ type ClientWithResponsesInterface interface { CreateSystemWithResponse(ctx context.Context, body CreateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSystemResponse, error) + // DeleteSystemWithResponse request + DeleteSystemWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*DeleteSystemResponse, error) + // GetSystemWithResponse request - GetSystemWithResponse(ctx context.Context, systemId string, reqEditors ...RequestEditorFn) (*GetSystemResponse, error) + GetSystemWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*GetSystemResponse, error) // UpdateSystemWithBodyWithResponse request with any body - UpdateSystemWithBodyWithResponse(ctx context.Context, systemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) + UpdateSystemWithBodyWithResponse(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) + + UpdateSystemWithResponse(ctx context.Context, systemId SystemId, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) + + // DeleteSystemOperatorWithResponse request + DeleteSystemOperatorWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*DeleteSystemOperatorResponse, error) + + // GetSystemOperatorWithResponse request + GetSystemOperatorWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*GetSystemOperatorResponse, error) + + // UpdateSystemOperatorWithBodyWithResponse request with any body + UpdateSystemOperatorWithBodyWithResponse(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemOperatorResponse, error) - UpdateSystemWithResponse(ctx context.Context, systemId string, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) + UpdateSystemOperatorWithResponse(ctx context.Context, systemId SystemId, body UpdateSystemOperatorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemOperatorResponse, error) // ListTeamsWithResponse request ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) @@ -3488,9 +3725,31 @@ func (r CreateSystemResponse) StatusCode() int { return 0 } +type DeleteSystemResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r DeleteSystemResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSystemResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetSystemResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *System } // Status returns HTTPResponse.Status @@ -3531,6 +3790,71 @@ func (r UpdateSystemResponse) StatusCode() int { return 0 } +type DeleteSystemOperatorResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r DeleteSystemOperatorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSystemOperatorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetSystemOperatorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Operator +} + +// Status returns HTTPResponse.Status +func (r GetSystemOperatorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSystemOperatorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateSystemOperatorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Operator +} + +// Status returns HTTPResponse.Status +func (r UpdateSystemOperatorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSystemOperatorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListTeamsResponse struct { Body []byte HTTPResponse *http.Response @@ -4106,8 +4430,17 @@ func (c *ClientWithResponses) CreateSystemWithResponse(ctx context.Context, body return ParseCreateSystemResponse(rsp) } +// DeleteSystemWithResponse request returning *DeleteSystemResponse +func (c *ClientWithResponses) DeleteSystemWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*DeleteSystemResponse, error) { + rsp, err := c.DeleteSystem(ctx, systemId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSystemResponse(rsp) +} + // GetSystemWithResponse request returning *GetSystemResponse -func (c *ClientWithResponses) GetSystemWithResponse(ctx context.Context, systemId string, reqEditors ...RequestEditorFn) (*GetSystemResponse, error) { +func (c *ClientWithResponses) GetSystemWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*GetSystemResponse, error) { rsp, err := c.GetSystem(ctx, systemId, reqEditors...) if err != nil { return nil, err @@ -4116,7 +4449,7 @@ func (c *ClientWithResponses) GetSystemWithResponse(ctx context.Context, systemI } // UpdateSystemWithBodyWithResponse request with arbitrary body returning *UpdateSystemResponse -func (c *ClientWithResponses) UpdateSystemWithBodyWithResponse(ctx context.Context, systemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) { +func (c *ClientWithResponses) UpdateSystemWithBodyWithResponse(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) { rsp, err := c.UpdateSystemWithBody(ctx, systemId, contentType, body, reqEditors...) if err != nil { return nil, err @@ -4124,7 +4457,7 @@ func (c *ClientWithResponses) UpdateSystemWithBodyWithResponse(ctx context.Conte return ParseUpdateSystemResponse(rsp) } -func (c *ClientWithResponses) UpdateSystemWithResponse(ctx context.Context, systemId string, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) { +func (c *ClientWithResponses) UpdateSystemWithResponse(ctx context.Context, systemId SystemId, body UpdateSystemJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemResponse, error) { rsp, err := c.UpdateSystem(ctx, systemId, body, reqEditors...) if err != nil { return nil, err @@ -4132,6 +4465,41 @@ func (c *ClientWithResponses) UpdateSystemWithResponse(ctx context.Context, syst return ParseUpdateSystemResponse(rsp) } +// DeleteSystemOperatorWithResponse request returning *DeleteSystemOperatorResponse +func (c *ClientWithResponses) DeleteSystemOperatorWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*DeleteSystemOperatorResponse, error) { + rsp, err := c.DeleteSystemOperator(ctx, systemId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSystemOperatorResponse(rsp) +} + +// GetSystemOperatorWithResponse request returning *GetSystemOperatorResponse +func (c *ClientWithResponses) GetSystemOperatorWithResponse(ctx context.Context, systemId SystemId, reqEditors ...RequestEditorFn) (*GetSystemOperatorResponse, error) { + rsp, err := c.GetSystemOperator(ctx, systemId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSystemOperatorResponse(rsp) +} + +// UpdateSystemOperatorWithBodyWithResponse request with arbitrary body returning *UpdateSystemOperatorResponse +func (c *ClientWithResponses) UpdateSystemOperatorWithBodyWithResponse(ctx context.Context, systemId SystemId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSystemOperatorResponse, error) { + rsp, err := c.UpdateSystemOperatorWithBody(ctx, systemId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSystemOperatorResponse(rsp) +} + +func (c *ClientWithResponses) UpdateSystemOperatorWithResponse(ctx context.Context, systemId SystemId, body UpdateSystemOperatorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSystemOperatorResponse, error) { + rsp, err := c.UpdateSystemOperator(ctx, systemId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSystemOperatorResponse(rsp) +} + // ListTeamsWithResponse request returning *ListTeamsResponse func (c *ClientWithResponses) ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) { rsp, err := c.ListTeams(ctx, params, reqEditors...) @@ -4876,6 +5244,22 @@ func ParseCreateSystemResponse(rsp *http.Response) (*CreateSystemResponse, error return response, nil } +// ParseDeleteSystemResponse parses an HTTP response from a DeleteSystemWithResponse call +func ParseDeleteSystemResponse(rsp *http.Response) (*DeleteSystemResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSystemResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseGetSystemResponse parses an HTTP response from a GetSystemWithResponse call func ParseGetSystemResponse(rsp *http.Response) (*GetSystemResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -4889,6 +5273,16 @@ func ParseGetSystemResponse(rsp *http.Response) (*GetSystemResponse, error) { HTTPResponse: rsp, } + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest System + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + return response, nil } @@ -4918,6 +5312,74 @@ func ParseUpdateSystemResponse(rsp *http.Response) (*UpdateSystemResponse, error return response, nil } +// ParseDeleteSystemOperatorResponse parses an HTTP response from a DeleteSystemOperatorWithResponse call +func ParseDeleteSystemOperatorResponse(rsp *http.Response) (*DeleteSystemOperatorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSystemOperatorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetSystemOperatorResponse parses an HTTP response from a GetSystemOperatorWithResponse call +func ParseGetSystemOperatorResponse(rsp *http.Response) (*GetSystemOperatorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSystemOperatorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Operator + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseUpdateSystemOperatorResponse parses an HTTP response from a UpdateSystemOperatorWithResponse call +func ParseUpdateSystemOperatorResponse(rsp *http.Response) (*UpdateSystemOperatorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSystemOperatorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Operator + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseListTeamsResponse parses an HTTP response from a ListTeamsWithResponse call func ParseListTeamsResponse(rsp *http.Response) (*ListTeamsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/apis/models.gen.go b/pkg/apis/models.gen.go index 66b82e76..a8e768c7 100644 --- a/pkg/apis/models.gen.go +++ b/pkg/apis/models.gen.go @@ -209,6 +209,9 @@ type OffsetParam = int // OperatorId defines model for operatorId. type OperatorId = openapi_types.UUID +// SystemId defines model for systemId. +type SystemId = openapi_types.UUID + // TeamId defines model for teamId. type TeamId = openapi_types.UUID @@ -234,9 +237,20 @@ type CreateOperatorAccountUser struct { Name string `json:"name"` } +// CreateSystem defines model for CreateSystem. +type CreateSystem struct { + Description *string `json:"description,omitempty"` + Name string `json:"name"` +} + // CreateTeam defines model for CreateTeam. type CreateTeam = Team +// UpdateSystemOperator defines model for UpdateSystemOperator. +type UpdateSystemOperator struct { + OperatorId openapi_types.UUID `json:"operatorId"` +} + // ListOperatorParams defines parameters for ListOperator. type ListOperatorParams struct { // Offset The number of items to skip before starting to collect the result set. @@ -301,6 +315,17 @@ type ListOperatorSigningKeysParams struct { Limit *LimitParam `form:"limit,omitempty" json:"limit,omitempty"` } +// CreateSystemJSONBody defines parameters for CreateSystem. +type CreateSystemJSONBody struct { + Description *string `json:"description,omitempty"` + Name string `json:"name"` +} + +// UpdateSystemOperatorJSONBody defines parameters for UpdateSystemOperator. +type UpdateSystemOperatorJSONBody struct { + OperatorId openapi_types.UUID `json:"operatorId"` +} + // ListTeamsParams defines parameters for ListTeams. type ListTeamsParams struct { // Offset The number of items to skip before starting to collect the result set. @@ -350,11 +375,14 @@ type CreateOperatorAccountJSONRequestBody CreateOperatorAccountJSONBody type CreateOperatorAccountUserJSONRequestBody CreateOperatorAccountUserJSONBody // CreateSystemJSONRequestBody defines body for CreateSystem for application/json ContentType. -type CreateSystemJSONRequestBody = System +type CreateSystemJSONRequestBody CreateSystemJSONBody // UpdateSystemJSONRequestBody defines body for UpdateSystem for application/json ContentType. type UpdateSystemJSONRequestBody = System +// UpdateSystemOperatorJSONRequestBody defines body for UpdateSystemOperator for application/json ContentType. +type UpdateSystemOperatorJSONRequestBody UpdateSystemOperatorJSONBody + // CreateTeamJSONRequestBody defines body for CreateTeam for application/json ContentType. type CreateTeamJSONRequestBody = Team @@ -373,55 +401,56 @@ type UpdateUserJSONRequestBody = User // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+wda2/bOPKvCNr7qFhKegcs/C277QVpF2lQp1vg0mBBS2ObjSxqSSpZw/B/P/ClhyVZ", - "D1tOUvhbLJHDec9wOGLWtk+WMYkg4swer+0YUbQEDlT+Qr5PkohfB+JHAMynOOaYRPbYvluAhQOLzCy+", - "AEsPtDixKHCK4QlGtmNjMTJGfGE7doSWYI9zIB2bwt8JphDYY04TcGzmL2CJxFozQpeI22M7SbAYyVex", - "mMw4xdHc3mwce05JEjcjJoe1QMuA2w+pEC8xvxUsrMYrSpZToEwghzksmUYsoVGK1t8J0FWGl4Ro57EI", - "YIaSkNvjC8+xl+gfvEyW9vg/4geO1I/zFDcccZgDlciR2YxBM3YF5Ngjjq0pzAgFi3FEOY7m4rlPwhB8", - "LllMgSUhtxjwOiLUytVU5PH2qvGOgSJOaLOwzcgW8s4B3U/kHNCyGTMxqgVWGth+GCUMWvBKjGqBkQa2", - "D0YbNRkY/40EGKRj+Z0C4nCpfIF44JOIg/oTxXGIfSSwdn8wgfo6t1pMhei4hlOgcL29tKFiXcGljJ57", - "NeohxZxMf4DPBeYbR2P6WavLHqiKacjnH5YIh5W4HpsWzf2vDPYhC2rpORS+d6AcVmsE/0VhZo/tX9ws", - "tLnqLXMlsI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a5nOjKrvHjSA/xK/V/W", + "krxf91d2ZhXcTByYQqJuHy9f10fxpCk9H8Gzm0E6bbYzaMPsejOGD7bRTZbot9VNe/xL0tGsyF4n7G1x", + "hlcpoGaXkwpwb5FEXQLTeBI3AMLOAaTbFDWK5G8JFvvhwP6bZDLiN8fF4iwE5blcbTO2/mFMG+Pp3bi0", + "byPK3fMkN2s09Wjb7WkQGo6hC20rTxqNbF9s6RiNKlE42r6zLSzmFsYALbefSN2JEadO7Z0TRnkB0YF3", + "y1K+ddtkpmSbJCwCxbpkkr+sTSXFzGIimVzl1imNTCANk0QmQhgshUyumeqTQDJJekEaqZnaa8nQrWcf", + "FYJotlYlqEGjRB1jGnfsgHI5QZ4V7Tpl+dq9u2QT5pyqhG+3Q7a16dU2Y9bZY21P4kC3Va6Hu7v2FXU7", + "thCaLW7O3e43ruSQ4TzGqfdmxyJc4TqiQ7sZpUMtjiHkhc5bmnK25l6CutrkS9LetwcnvZC6Kk2z6pO4", + "RMvrErkqrAayne6tNvupdhS1r6q4cj7kcr3KlEWl7B33lAu110qFtIpmhaLKFwfUiubBiervr05a5G1z", + "yfS1MMQ5pB43FmTr+bylbHTErH4h53QcQtVKwHVybeuRmjus+7VUn1K6Uzt1r8xtayv1Tr3TTYlZz57p", + "Xt2yrylrS3pdX0nHdMeUrNwl3ZCQHU7eB+yM7pe96d3M9Qnbm2TYcbWSb83i3gr/D+nZXlC8WXJX/FhA", + "u/Ss0tb+TO86G4yaZInkX22kWCc9baI3PiYEAmYofJMrPS9vr3OtWECeQHSSbprjGk2uZruXd6Q9FFIU", + "/cK0+weuiLmkRTxJ73S7l3mLWF8aQ140H+EJ/DBachrkqNxFYWPb9kMX+YuQsvF7571jowjbT+ciQCvq", + "Kv71EQUDEdD/RVTSpzZdGeoSsVFmNWn31nZQIsQZbIGYeBRTvhsoQ1PHeA2wCJ7PeeamgQNP/HcwCDx5", + "85r4Z2EV8NVUnmb+PwAA///ycDGWam4AAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/apis/server.gen.go b/pkg/apis/server.gen.go index 15b25741..17bfc170 100644 --- a/pkg/apis/server.gen.go +++ b/pkg/apis/server.gen.go @@ -85,12 +85,24 @@ type ServerInterface interface { // Creates a new system // (POST /systems) CreateSystem(c *fiber.Ctx) error - // List all managed systems. + // Deletes a system by ID + // (DELETE /systems/{systemId}) + DeleteSystem(c *fiber.Ctx, systemId SystemId) error + // Gets a system by ID // (GET /systems/{systemId}) - GetSystem(c *fiber.Ctx, systemId string) error + GetSystem(c *fiber.Ctx, systemId SystemId) error // Updates a system by ID // (PUT /systems/{systemId}) - UpdateSystem(c *fiber.Ctx, systemId string) error + UpdateSystem(c *fiber.Ctx, systemId SystemId) error + // Deletes the operator for a system + // (DELETE /systems/{systemId}/operator) + DeleteSystemOperator(c *fiber.Ctx, systemId SystemId) error + // Gets the operator for a system + // (GET /systems/{systemId}/operator) + GetSystemOperator(c *fiber.Ctx, systemId SystemId) error + // Updates the operator for a system + // (PUT /systems/{systemId}/operator) + UpdateSystemOperator(c *fiber.Ctx, systemId SystemId) error // List all teams // (GET /teams) ListTeams(c *fiber.Ctx, params ListTeamsParams) error @@ -809,13 +821,35 @@ func (siw *ServerInterfaceWrapper) CreateSystem(c *fiber.Ctx) error { return siw.Handler.CreateSystem(c) } +// DeleteSystem operation middleware +func (siw *ServerInterfaceWrapper) DeleteSystem(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "systemId" ------------- + var systemId SystemId + + err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter systemId: %w", err).Error()) + } + + c.Context().SetUserValue(CookieAuthScopes, []string{}) + + c.Context().SetUserValue(BearerAuthScopes, []string{}) + + c.Context().SetUserValue(Api_keyScopes, []string{}) + + return siw.Handler.DeleteSystem(c, systemId) +} + // GetSystem operation middleware func (siw *ServerInterfaceWrapper) GetSystem(c *fiber.Ctx) error { var err error // ------------- Path parameter "systemId" ------------- - var systemId string + var systemId SystemId err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { @@ -837,7 +871,7 @@ func (siw *ServerInterfaceWrapper) UpdateSystem(c *fiber.Ctx) error { var err error // ------------- Path parameter "systemId" ------------- - var systemId string + var systemId SystemId err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { @@ -853,6 +887,72 @@ func (siw *ServerInterfaceWrapper) UpdateSystem(c *fiber.Ctx) error { return siw.Handler.UpdateSystem(c, systemId) } +// DeleteSystemOperator operation middleware +func (siw *ServerInterfaceWrapper) DeleteSystemOperator(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "systemId" ------------- + var systemId SystemId + + err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter systemId: %w", err).Error()) + } + + c.Context().SetUserValue(CookieAuthScopes, []string{}) + + c.Context().SetUserValue(BearerAuthScopes, []string{}) + + c.Context().SetUserValue(Api_keyScopes, []string{}) + + return siw.Handler.DeleteSystemOperator(c, systemId) +} + +// GetSystemOperator operation middleware +func (siw *ServerInterfaceWrapper) GetSystemOperator(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "systemId" ------------- + var systemId SystemId + + err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter systemId: %w", err).Error()) + } + + c.Context().SetUserValue(CookieAuthScopes, []string{}) + + c.Context().SetUserValue(BearerAuthScopes, []string{}) + + c.Context().SetUserValue(Api_keyScopes, []string{}) + + return siw.Handler.GetSystemOperator(c, systemId) +} + +// UpdateSystemOperator operation middleware +func (siw *ServerInterfaceWrapper) UpdateSystemOperator(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "systemId" ------------- + var systemId SystemId + + err = runtime.BindStyledParameterWithOptions("simple", "systemId", c.Params("systemId"), &systemId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter systemId: %w", err).Error()) + } + + c.Context().SetUserValue(CookieAuthScopes, []string{}) + + c.Context().SetUserValue(BearerAuthScopes, []string{}) + + c.Context().SetUserValue(Api_keyScopes, []string{}) + + return siw.Handler.UpdateSystemOperator(c, systemId) +} + // ListTeams operation middleware func (siw *ServerInterfaceWrapper) ListTeams(c *fiber.Ctx) error { @@ -1380,10 +1480,18 @@ func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, option router.Post(options.BaseURL+"/systems", wrapper.CreateSystem) + router.Delete(options.BaseURL+"/systems/:systemId", wrapper.DeleteSystem) + router.Get(options.BaseURL+"/systems/:systemId", wrapper.GetSystem) router.Put(options.BaseURL+"/systems/:systemId", wrapper.UpdateSystem) + router.Delete(options.BaseURL+"/systems/:systemId/operator", wrapper.DeleteSystemOperator) + + router.Get(options.BaseURL+"/systems/:systemId/operator", wrapper.GetSystemOperator) + + router.Put(options.BaseURL+"/systems/:systemId/operator", wrapper.UpdateSystemOperator) + router.Get(options.BaseURL+"/teams", wrapper.ListTeams) router.Post(options.BaseURL+"/teams", wrapper.CreateTeam) @@ -1860,24 +1968,41 @@ func (response CreateSystem201JSONResponse) VisitCreateSystemResponse(ctx *fiber return ctx.JSON(&response) } +type DeleteSystemRequestObject struct { + SystemId SystemId `json:"systemId"` +} + +type DeleteSystemResponseObject interface { + VisitDeleteSystemResponse(ctx *fiber.Ctx) error +} + +type DeleteSystem204Response struct { +} + +func (response DeleteSystem204Response) VisitDeleteSystemResponse(ctx *fiber.Ctx) error { + ctx.Status(204) + return nil +} + type GetSystemRequestObject struct { - SystemId string `json:"systemId"` + SystemId SystemId `json:"systemId"` } type GetSystemResponseObject interface { VisitGetSystemResponse(ctx *fiber.Ctx) error } -type GetSystem200Response struct { -} +type GetSystem200JSONResponse System -func (response GetSystem200Response) VisitGetSystemResponse(ctx *fiber.Ctx) error { +func (response GetSystem200JSONResponse) VisitGetSystemResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") ctx.Status(200) - return nil + + return ctx.JSON(&response) } type UpdateSystemRequestObject struct { - SystemId string `json:"systemId"` + SystemId SystemId `json:"systemId"` Body *UpdateSystemJSONRequestBody } @@ -1894,6 +2019,57 @@ func (response UpdateSystem200JSONResponse) VisitUpdateSystemResponse(ctx *fiber return ctx.JSON(&response) } +type DeleteSystemOperatorRequestObject struct { + SystemId SystemId `json:"systemId"` +} + +type DeleteSystemOperatorResponseObject interface { + VisitDeleteSystemOperatorResponse(ctx *fiber.Ctx) error +} + +type DeleteSystemOperator204Response struct { +} + +func (response DeleteSystemOperator204Response) VisitDeleteSystemOperatorResponse(ctx *fiber.Ctx) error { + ctx.Status(204) + return nil +} + +type GetSystemOperatorRequestObject struct { + SystemId SystemId `json:"systemId"` +} + +type GetSystemOperatorResponseObject interface { + VisitGetSystemOperatorResponse(ctx *fiber.Ctx) error +} + +type GetSystemOperator200JSONResponse Operator + +func (response GetSystemOperator200JSONResponse) VisitGetSystemOperatorResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(200) + + return ctx.JSON(&response) +} + +type UpdateSystemOperatorRequestObject struct { + SystemId SystemId `json:"systemId"` + Body *UpdateSystemOperatorJSONRequestBody +} + +type UpdateSystemOperatorResponseObject interface { + VisitUpdateSystemOperatorResponse(ctx *fiber.Ctx) error +} + +type UpdateSystemOperator200JSONResponse Operator + +func (response UpdateSystemOperator200JSONResponse) VisitUpdateSystemOperatorResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(200) + + return ctx.JSON(&response) +} + type ListTeamsRequestObject struct { Params ListTeamsParams } @@ -2242,12 +2418,24 @@ type StrictServerInterface interface { // Creates a new system // (POST /systems) CreateSystem(ctx context.Context, request CreateSystemRequestObject) (CreateSystemResponseObject, error) - // List all managed systems. + // Deletes a system by ID + // (DELETE /systems/{systemId}) + DeleteSystem(ctx context.Context, request DeleteSystemRequestObject) (DeleteSystemResponseObject, error) + // Gets a system by ID // (GET /systems/{systemId}) GetSystem(ctx context.Context, request GetSystemRequestObject) (GetSystemResponseObject, error) // Updates a system by ID // (PUT /systems/{systemId}) UpdateSystem(ctx context.Context, request UpdateSystemRequestObject) (UpdateSystemResponseObject, error) + // Deletes the operator for a system + // (DELETE /systems/{systemId}/operator) + DeleteSystemOperator(ctx context.Context, request DeleteSystemOperatorRequestObject) (DeleteSystemOperatorResponseObject, error) + // Gets the operator for a system + // (GET /systems/{systemId}/operator) + GetSystemOperator(ctx context.Context, request GetSystemOperatorRequestObject) (GetSystemOperatorResponseObject, error) + // Updates the operator for a system + // (PUT /systems/{systemId}/operator) + UpdateSystemOperator(ctx context.Context, request UpdateSystemOperatorRequestObject) (UpdateSystemOperatorResponseObject, error) // List all teams // (GET /teams) ListTeams(ctx context.Context, request ListTeamsRequestObject) (ListTeamsResponseObject, error) @@ -2967,8 +3155,35 @@ func (sh *strictHandler) CreateSystem(ctx *fiber.Ctx) error { return nil } +// DeleteSystem operation middleware +func (sh *strictHandler) DeleteSystem(ctx *fiber.Ctx, systemId SystemId) error { + var request DeleteSystemRequestObject + + request.SystemId = systemId + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.DeleteSystem(ctx.UserContext(), request.(DeleteSystemRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "DeleteSystem") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(DeleteSystemResponseObject); ok { + if err := validResponse.VisitDeleteSystemResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + // GetSystem operation middleware -func (sh *strictHandler) GetSystem(ctx *fiber.Ctx, systemId string) error { +func (sh *strictHandler) GetSystem(ctx *fiber.Ctx, systemId SystemId) error { var request GetSystemRequestObject request.SystemId = systemId @@ -2995,7 +3210,7 @@ func (sh *strictHandler) GetSystem(ctx *fiber.Ctx, systemId string) error { } // UpdateSystem operation middleware -func (sh *strictHandler) UpdateSystem(ctx *fiber.Ctx, systemId string) error { +func (sh *strictHandler) UpdateSystem(ctx *fiber.Ctx, systemId SystemId) error { var request UpdateSystemRequestObject request.SystemId = systemId @@ -3027,6 +3242,93 @@ func (sh *strictHandler) UpdateSystem(ctx *fiber.Ctx, systemId string) error { return nil } +// DeleteSystemOperator operation middleware +func (sh *strictHandler) DeleteSystemOperator(ctx *fiber.Ctx, systemId SystemId) error { + var request DeleteSystemOperatorRequestObject + + request.SystemId = systemId + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.DeleteSystemOperator(ctx.UserContext(), request.(DeleteSystemOperatorRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "DeleteSystemOperator") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(DeleteSystemOperatorResponseObject); ok { + if err := validResponse.VisitDeleteSystemOperatorResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// GetSystemOperator operation middleware +func (sh *strictHandler) GetSystemOperator(ctx *fiber.Ctx, systemId SystemId) error { + var request GetSystemOperatorRequestObject + + request.SystemId = systemId + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.GetSystemOperator(ctx.UserContext(), request.(GetSystemOperatorRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "GetSystemOperator") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(GetSystemOperatorResponseObject); ok { + if err := validResponse.VisitGetSystemOperatorResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// UpdateSystemOperator operation middleware +func (sh *strictHandler) UpdateSystemOperator(ctx *fiber.Ctx, systemId SystemId) error { + var request UpdateSystemOperatorRequestObject + + request.SystemId = systemId + + var body UpdateSystemOperatorJSONRequestBody + if err := ctx.BodyParser(&body); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + request.Body = &body + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.UpdateSystemOperator(ctx.UserContext(), request.(UpdateSystemOperatorRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "UpdateSystemOperator") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(UpdateSystemOperatorResponseObject); ok { + if err := validResponse.VisitUpdateSystemOperatorResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + // ListTeams operation middleware func (sh *strictHandler) ListTeams(ctx *fiber.Ctx, params ListTeamsParams) error { var request ListTeamsRequestObject