From b45eeaa2ac7c20a71e677c205faf07dbd1adae84 Mon Sep 17 00:00:00 2001 From: Leandro Poroli Date: Tue, 2 Jul 2024 10:39:51 -0300 Subject: [PATCH] move tenant UUID param from query to path --- README.md | 7 +- kardinal-cli/cmd/root.go | 41 +-- kardinal-manager/deployment/k8s.yaml | 4 +- .../kardinal-manager/fetcher/fetcher.go | 17 +- kardinal-manager/kardinal-manager/main.go | 7 +- .../api/golang/client/client.gen.go | 306 ++++++++---------- .../api/golang/server/server.gen.go | 261 ++++++++------- .../api/golang/types/types.gen.go | 41 +-- .../api/typescript/client/types.d.ts | 30 +- libs/cli-kontrol-api/specs/api.yaml | 24 +- .../api/golang/client/client.gen.go | 57 ++-- .../api/golang/server/server.gen.go | 89 ++--- .../api/golang/types/types.gen.go | 11 +- .../api/typescript/client/types.d.ts | 12 +- libs/manager-kontrol-api/specs/api.yaml | 12 +- 15 files changed, 411 insertions(+), 508 deletions(-) diff --git a/README.md b/README.md index a7d2853d..4f3802f6 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,8 @@ minikube tunnel Configure it by setting the following environment variables: ```bash -KARDINAL_MANAGER_CLUSTER_CONFIG_ENDPOINT=http://localhost:8080/cluster-resources +KARDINAL_MANAGER_CLUSTER_CONFIG_ENDPOINT=http://localhost:8080/tenant/{36e22127-3c9e-4110-aa83-af552cd94b88}/cluster-resources KARDINAL_MANAGER_FETCHER_JOB_DURATION_SECONDS=10 -KARDINAL_MANAGER_TENANT_UUID=36e22127-3c9e-4110-aa83-af552cd94b88 ``` or in the `kardinal-manager/deployment/k8s.yaml`: @@ -113,11 +112,9 @@ or in the `kardinal-manager/deployment/k8s.yaml`: env: - name: KARDINAL_MANAGER_CLUSTER_CONFIG_ENDPOINT # This is valid for reaching out the Kardinal Kontrol if this is running on the host - value: "http://host.minikube.internal:8080/cluster-resources" + value: "http://localhost:8080/tenant/{36e22127-3c9e-4110-aa83-af552cd94b88}/cluster-resources" - name: KARDINAL_MANAGER_FETCHER_JOB_DURATION_SECONDS value: "10" - - name: KARDINAL_MANAGER_TENANT_UUID - value: "36e22127-3c9e-4110-aa83-af552cd94b88" ``` NOTE: you can get your tenant UUID by running any CLI command diff --git a/kardinal-cli/cmd/root.go b/kardinal-cli/cmd/root.go index 25afe113..9c6c3e6a 100644 --- a/kardinal-cli/cmd/root.go +++ b/kardinal-cli/cmd/root.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/google/uuid" "kardinal.cli/tenant" "log" "net/http" @@ -49,7 +48,8 @@ var deployCmd = &cobra.Command{ if err != nil { log.Fatal("Error getting or creating user tenant UUID", err) } - deploy(tenantUuid, services) + + deploy(tenantUuid.String(), services) }, } @@ -70,7 +70,7 @@ var createCmd = &cobra.Command{ } fmt.Printf("Creating service %s with image %s in development mode...\n", serviceName, imageName) - createDevFlow(tenantUuid, services, imageName, serviceName) + createDevFlow(tenantUuid.String(), services, imageName, serviceName) }, } @@ -88,7 +88,7 @@ var deleteCmd = &cobra.Command{ if err != nil { log.Fatal("Error getting or creating user tenant UUID", err) } - deleteFlow(tenantUuid, services) + deleteFlow(tenantUuid.String(), services) fmt.Print("Deleting dev flow") }, @@ -155,24 +155,17 @@ func parseComposeFile(composeFile string) ([]types.ServiceConfig, error) { return project.Services, nil } -func createDevFlow(tenantUuid uuid.UUID, services []types.ServiceConfig, imageLocator, serviceName string) { +func createDevFlow(tenantUuid api_types.Uuid, services []types.ServiceConfig, imageLocator, serviceName string) { ctx := context.Background() - params := &api_types.PostFlowCreateParams{ - Tenant: tenantUuid.String(), - } - - // fmt.Printf("Services:\n%v", services) - // fmt.Printf("%v", serviceName) - // fmt.Printf("%v", imageLocator) - body := api_types.PostFlowCreateJSONRequestBody{ + body := api_types.PostTenantUuidFlowCreateJSONRequestBody{ DockerCompose: &services, ServiceName: &serviceName, ImageLocator: &imageLocator, } client := getKontrolServiceClient() - resp, err := client.PostFlowCreateWithResponse(ctx, params, body) + resp, err := client.PostTenantUuidFlowCreateWithResponse(ctx, tenantUuid, body) if err != nil { log.Fatalf("Failed to create dev flow: %v", err) } @@ -181,19 +174,15 @@ func createDevFlow(tenantUuid uuid.UUID, services []types.ServiceConfig, imageLo fmt.Printf("Response: %s\n", resp) } -func deploy(tenantUuid uuid.UUID, services []types.ServiceConfig) { +func deploy(tenantUuid api_types.Uuid, services []types.ServiceConfig) { ctx := context.Background() - params := &api_types.PostDeployParams{ - Tenant: tenantUuid.String(), - } - - body := api_types.PostDeployJSONRequestBody{ + body := api_types.PostTenantUuidDeployJSONRequestBody{ DockerCompose: &services, } client := getKontrolServiceClient() - resp, err := client.PostDeployWithResponse(ctx, params, body) + resp, err := client.PostTenantUuidDeployWithResponse(ctx, tenantUuid, body) if err != nil { log.Fatalf("Failed to deploy: %v", err) } @@ -201,19 +190,15 @@ func deploy(tenantUuid uuid.UUID, services []types.ServiceConfig) { fmt.Printf("Response: %s\n", string(resp.Body)) } -func deleteFlow(tenantUuid uuid.UUID, services []types.ServiceConfig) { +func deleteFlow(tenantUuid api_types.Uuid, services []types.ServiceConfig) { ctx := context.Background() - params := &api_types.PostFlowDeleteParams{ - Tenant: tenantUuid.String(), - } - - body := api_types.PostFlowDeleteJSONRequestBody{ + body := api_types.PostTenantUuidFlowDeleteJSONRequestBody{ DockerCompose: &services, } client := getKontrolServiceClient() - resp, err := client.PostFlowDeleteWithResponse(ctx, params, body) + resp, err := client.PostTenantUuidFlowDeleteWithResponse(ctx, tenantUuid, body) if err != nil { log.Fatalf("Failed to delete flow: %v", err) } diff --git a/kardinal-manager/deployment/k8s.yaml b/kardinal-manager/deployment/k8s.yaml index 0e4e7e6b..52b11e6f 100644 --- a/kardinal-manager/deployment/k8s.yaml +++ b/kardinal-manager/deployment/k8s.yaml @@ -57,8 +57,6 @@ spec: value: "443" - name: KARDINAL_MANAGER_CLUSTER_CONFIG_ENDPOINT # This is valid for reaching out the Kardinal Kontrol if this is running on the host - value: "http://host.minikube.internal:8080/cluster-resources" + value: "http://host.minikube.internal:8080/tenant/58d33536-3c9e-4110-aa83-bf112ae94a49/cluster-resources" - name: KARDINAL_MANAGER_FETCHER_JOB_DURATION_SECONDS value: "10" - - name: KARDINAL_MANAGER_TENANT_UUID - value: "58d33536-3c9e-4110-aa83-bf112ae94a49" diff --git a/kardinal-manager/kardinal-manager/fetcher/fetcher.go b/kardinal-manager/kardinal-manager/fetcher/fetcher.go index 47e7c687..8673e05e 100644 --- a/kardinal-manager/kardinal-manager/fetcher/fetcher.go +++ b/kardinal-manager/kardinal-manager/fetcher/fetcher.go @@ -23,11 +23,10 @@ const ( type fetcher struct { clusterManager *cluster_manager.ClusterManager configEndpoint string - tenantUuidStr string } -func NewFetcher(clusterManager *cluster_manager.ClusterManager, configEndpoint string, tenantUuidStr string) *fetcher { - return &fetcher{clusterManager: clusterManager, configEndpoint: configEndpoint, tenantUuidStr: tenantUuidStr} +func NewFetcher(clusterManager *cluster_manager.ClusterManager, configEndpoint string) *fetcher { + return &fetcher{clusterManager: clusterManager, configEndpoint: configEndpoint} } func (fetcher *fetcher) Run(ctx context.Context) error { @@ -78,18 +77,10 @@ func (fetcher *fetcher) getClusterResourcesFromCloud() (*types.ClusterResources, configEndpointURL, err := url.Parse(fetcher.configEndpoint) if err != nil { - return nil, err + return nil, stacktrace.Propagate(err, "An error occurred parsing the config endpoint '%s'", fetcher.configEndpoint) } - queryValues := configEndpointURL.Query() - - queryValues.Add(tenantParamKey, fetcher.tenantUuidStr) - - configEndpointURL.RawQuery = queryValues.Encode() - - configEndpointURLStr := configEndpointURL.String() - - resp, err := http.Get(configEndpointURLStr) + resp, err := http.Get(configEndpointURL.String()) if err != nil { return nil, stacktrace.Propagate(err, "Error fetching cluster resources from endpoint '%s'", fetcher.configEndpoint) } diff --git a/kardinal-manager/kardinal-manager/main.go b/kardinal-manager/kardinal-manager/main.go index dda75967..5b351b04 100644 --- a/kardinal-manager/kardinal-manager/main.go +++ b/kardinal-manager/kardinal-manager/main.go @@ -30,17 +30,12 @@ func main() { logrus.Fatal("An error occurred getting the config endpoint from the env vars!\nError was: %s", err) } - tenantUuidStr, err := utils.GetFromEnvVar(tenantUuidEnvVarKey, "the tenant uuid") - if err != nil { - logrus.Fatal("An error occurred getting the tenant UUID from the env vars!\nError was: %s", err) - } - clusterManager, err := cluster_manager.CreateClusterManager() if err != nil { logrus.Fatal("An error occurred while creating the cluster manager!\nError was: %s", err) } - fetcher := fetcher.NewFetcher(clusterManager, configEndpoint, tenantUuidStr) + fetcher := fetcher.NewFetcher(clusterManager, configEndpoint) if err = fetcher.Run(ctx); err != nil { logrus.Fatalf("An error occurred while running the fetcher!\nError was: %s", err) diff --git a/libs/cli-kontrol-api/api/golang/client/client.gen.go b/libs/cli-kontrol-api/api/golang/client/client.gen.go index 4aba5032..36a38600 100644 --- a/libs/cli-kontrol-api/api/golang/client/client.gen.go +++ b/libs/cli-kontrol-api/api/golang/client/client.gen.go @@ -90,27 +90,27 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption { // The interface specification for the client above. type ClientInterface interface { - // PostDeployWithBody request with any body - PostDeployWithBody(ctx context.Context, params *PostDeployParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostTenantUuidDeployWithBody request with any body + PostTenantUuidDeployWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - PostDeploy(ctx context.Context, params *PostDeployParams, body PostDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + PostTenantUuidDeploy(ctx context.Context, uuid Uuid, body PostTenantUuidDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // PostFlowCreateWithBody request with any body - PostFlowCreateWithBody(ctx context.Context, params *PostFlowCreateParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostTenantUuidFlowCreateWithBody request with any body + PostTenantUuidFlowCreateWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - PostFlowCreate(ctx context.Context, params *PostFlowCreateParams, body PostFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + PostTenantUuidFlowCreate(ctx context.Context, uuid Uuid, body PostTenantUuidFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // PostFlowDeleteWithBody request with any body - PostFlowDeleteWithBody(ctx context.Context, params *PostFlowDeleteParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostTenantUuidFlowDeleteWithBody request with any body + PostTenantUuidFlowDeleteWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - PostFlowDelete(ctx context.Context, params *PostFlowDeleteParams, body PostFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + PostTenantUuidFlowDelete(ctx context.Context, uuid Uuid, body PostTenantUuidFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetTopology request - GetTopology(ctx context.Context, params *GetTopologyParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetTenantUuidTopology request + GetTenantUuidTopology(ctx context.Context, uuid Uuid, params *GetTenantUuidTopologyParams, reqEditors ...RequestEditorFn) (*http.Response, error) } -func (c *Client) PostDeployWithBody(ctx context.Context, params *PostDeployParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostDeployRequestWithBody(c.Server, params, contentType, body) +func (c *Client) PostTenantUuidDeployWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidDeployRequestWithBody(c.Server, uuid, contentType, body) if err != nil { return nil, err } @@ -121,8 +121,8 @@ func (c *Client) PostDeployWithBody(ctx context.Context, params *PostDeployParam return c.Client.Do(req) } -func (c *Client) PostDeploy(ctx context.Context, params *PostDeployParams, body PostDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostDeployRequest(c.Server, params, body) +func (c *Client) PostTenantUuidDeploy(ctx context.Context, uuid Uuid, body PostTenantUuidDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidDeployRequest(c.Server, uuid, body) if err != nil { return nil, err } @@ -133,8 +133,8 @@ func (c *Client) PostDeploy(ctx context.Context, params *PostDeployParams, body return c.Client.Do(req) } -func (c *Client) PostFlowCreateWithBody(ctx context.Context, params *PostFlowCreateParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostFlowCreateRequestWithBody(c.Server, params, contentType, body) +func (c *Client) PostTenantUuidFlowCreateWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidFlowCreateRequestWithBody(c.Server, uuid, contentType, body) if err != nil { return nil, err } @@ -145,8 +145,8 @@ func (c *Client) PostFlowCreateWithBody(ctx context.Context, params *PostFlowCre return c.Client.Do(req) } -func (c *Client) PostFlowCreate(ctx context.Context, params *PostFlowCreateParams, body PostFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostFlowCreateRequest(c.Server, params, body) +func (c *Client) PostTenantUuidFlowCreate(ctx context.Context, uuid Uuid, body PostTenantUuidFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidFlowCreateRequest(c.Server, uuid, body) if err != nil { return nil, err } @@ -157,8 +157,8 @@ func (c *Client) PostFlowCreate(ctx context.Context, params *PostFlowCreateParam return c.Client.Do(req) } -func (c *Client) PostFlowDeleteWithBody(ctx context.Context, params *PostFlowDeleteParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostFlowDeleteRequestWithBody(c.Server, params, contentType, body) +func (c *Client) PostTenantUuidFlowDeleteWithBody(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidFlowDeleteRequestWithBody(c.Server, uuid, contentType, body) if err != nil { return nil, err } @@ -169,8 +169,8 @@ func (c *Client) PostFlowDeleteWithBody(ctx context.Context, params *PostFlowDel return c.Client.Do(req) } -func (c *Client) PostFlowDelete(ctx context.Context, params *PostFlowDeleteParams, body PostFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostFlowDeleteRequest(c.Server, params, body) +func (c *Client) PostTenantUuidFlowDelete(ctx context.Context, uuid Uuid, body PostTenantUuidFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostTenantUuidFlowDeleteRequest(c.Server, uuid, body) if err != nil { return nil, err } @@ -181,8 +181,8 @@ func (c *Client) PostFlowDelete(ctx context.Context, params *PostFlowDeleteParam return c.Client.Do(req) } -func (c *Client) GetTopology(ctx context.Context, params *GetTopologyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetTopologyRequest(c.Server, params) +func (c *Client) GetTenantUuidTopology(ctx context.Context, uuid Uuid, params *GetTenantUuidTopologyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTenantUuidTopologyRequest(c.Server, uuid, params) if err != nil { return nil, err } @@ -193,27 +193,34 @@ func (c *Client) GetTopology(ctx context.Context, params *GetTopologyParams, req return c.Client.Do(req) } -// NewPostDeployRequest calls the generic PostDeploy builder with application/json body -func NewPostDeployRequest(server string, params *PostDeployParams, body PostDeployJSONRequestBody) (*http.Request, error) { +// NewPostTenantUuidDeployRequest calls the generic PostTenantUuidDeploy builder with application/json body +func NewPostTenantUuidDeployRequest(server string, uuid Uuid, body PostTenantUuidDeployJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewPostDeployRequestWithBody(server, params, "application/json", bodyReader) + return NewPostTenantUuidDeployRequestWithBody(server, uuid, "application/json", bodyReader) } -// NewPostDeployRequestWithBody generates requests for PostDeploy with any type of body -func NewPostDeployRequestWithBody(server string, params *PostDeployParams, contentType string, body io.Reader) (*http.Request, error) { +// NewPostTenantUuidDeployRequestWithBody generates requests for PostTenantUuidDeploy with any type of body +func NewPostTenantUuidDeployRequestWithBody(server string, uuid Uuid, contentType string, body io.Reader) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/deploy") + operationPath := fmt.Sprintf("/tenant/%s/deploy", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -223,24 +230,6 @@ func NewPostDeployRequestWithBody(server string, params *PostDeployParams, conte return nil, err } - if params != nil { - queryValues := queryURL.Query() - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tenant", runtime.ParamLocationQuery, params.Tenant); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - queryURL.RawQuery = queryValues.Encode() - } - req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err @@ -251,27 +240,34 @@ func NewPostDeployRequestWithBody(server string, params *PostDeployParams, conte return req, nil } -// NewPostFlowCreateRequest calls the generic PostFlowCreate builder with application/json body -func NewPostFlowCreateRequest(server string, params *PostFlowCreateParams, body PostFlowCreateJSONRequestBody) (*http.Request, error) { +// NewPostTenantUuidFlowCreateRequest calls the generic PostTenantUuidFlowCreate builder with application/json body +func NewPostTenantUuidFlowCreateRequest(server string, uuid Uuid, body PostTenantUuidFlowCreateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewPostFlowCreateRequestWithBody(server, params, "application/json", bodyReader) + return NewPostTenantUuidFlowCreateRequestWithBody(server, uuid, "application/json", bodyReader) } -// NewPostFlowCreateRequestWithBody generates requests for PostFlowCreate with any type of body -func NewPostFlowCreateRequestWithBody(server string, params *PostFlowCreateParams, contentType string, body io.Reader) (*http.Request, error) { +// NewPostTenantUuidFlowCreateRequestWithBody generates requests for PostTenantUuidFlowCreate with any type of body +func NewPostTenantUuidFlowCreateRequestWithBody(server string, uuid Uuid, contentType string, body io.Reader) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/flow/create") + operationPath := fmt.Sprintf("/tenant/%s/flow/create", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -281,24 +277,6 @@ func NewPostFlowCreateRequestWithBody(server string, params *PostFlowCreateParam return nil, err } - if params != nil { - queryValues := queryURL.Query() - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tenant", runtime.ParamLocationQuery, params.Tenant); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - queryURL.RawQuery = queryValues.Encode() - } - req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err @@ -309,27 +287,34 @@ func NewPostFlowCreateRequestWithBody(server string, params *PostFlowCreateParam return req, nil } -// NewPostFlowDeleteRequest calls the generic PostFlowDelete builder with application/json body -func NewPostFlowDeleteRequest(server string, params *PostFlowDeleteParams, body PostFlowDeleteJSONRequestBody) (*http.Request, error) { +// NewPostTenantUuidFlowDeleteRequest calls the generic PostTenantUuidFlowDelete builder with application/json body +func NewPostTenantUuidFlowDeleteRequest(server string, uuid Uuid, body PostTenantUuidFlowDeleteJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewPostFlowDeleteRequestWithBody(server, params, "application/json", bodyReader) + return NewPostTenantUuidFlowDeleteRequestWithBody(server, uuid, "application/json", bodyReader) } -// NewPostFlowDeleteRequestWithBody generates requests for PostFlowDelete with any type of body -func NewPostFlowDeleteRequestWithBody(server string, params *PostFlowDeleteParams, contentType string, body io.Reader) (*http.Request, error) { +// NewPostTenantUuidFlowDeleteRequestWithBody generates requests for PostTenantUuidFlowDelete with any type of body +func NewPostTenantUuidFlowDeleteRequestWithBody(server string, uuid Uuid, contentType string, body io.Reader) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/flow/delete") + operationPath := fmt.Sprintf("/tenant/%s/flow/delete", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -339,24 +324,6 @@ func NewPostFlowDeleteRequestWithBody(server string, params *PostFlowDeleteParam return nil, err } - if params != nil { - queryValues := queryURL.Query() - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tenant", runtime.ParamLocationQuery, params.Tenant); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - queryURL.RawQuery = queryValues.Encode() - } - req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err @@ -367,16 +334,23 @@ func NewPostFlowDeleteRequestWithBody(server string, params *PostFlowDeleteParam return req, nil } -// NewGetTopologyRequest generates requests for GetTopology -func NewGetTopologyRequest(server string, params *GetTopologyParams) (*http.Request, error) { +// NewGetTenantUuidTopologyRequest generates requests for GetTenantUuidTopology +func NewGetTenantUuidTopologyRequest(server string, uuid Uuid, params *GetTenantUuidTopologyParams) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/topology") + operationPath := fmt.Sprintf("/tenant/%s/topology", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -405,18 +379,6 @@ func NewGetTopologyRequest(server string, params *GetTopologyParams) (*http.Requ } - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tenant", runtime.ParamLocationQuery, params.Tenant); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - queryURL.RawQuery = queryValues.Encode() } @@ -471,33 +433,33 @@ func WithBaseURL(baseURL string) ClientOption { // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { - // PostDeployWithBodyWithResponse request with any body - PostDeployWithBodyWithResponse(ctx context.Context, params *PostDeployParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDeployResponse, error) + // PostTenantUuidDeployWithBodyWithResponse request with any body + PostTenantUuidDeployWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidDeployResponse, error) - PostDeployWithResponse(ctx context.Context, params *PostDeployParams, body PostDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDeployResponse, error) + PostTenantUuidDeployWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidDeployResponse, error) - // PostFlowCreateWithBodyWithResponse request with any body - PostFlowCreateWithBodyWithResponse(ctx context.Context, params *PostFlowCreateParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFlowCreateResponse, error) + // PostTenantUuidFlowCreateWithBodyWithResponse request with any body + PostTenantUuidFlowCreateWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowCreateResponse, error) - PostFlowCreateWithResponse(ctx context.Context, params *PostFlowCreateParams, body PostFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFlowCreateResponse, error) + PostTenantUuidFlowCreateWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowCreateResponse, error) - // PostFlowDeleteWithBodyWithResponse request with any body - PostFlowDeleteWithBodyWithResponse(ctx context.Context, params *PostFlowDeleteParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFlowDeleteResponse, error) + // PostTenantUuidFlowDeleteWithBodyWithResponse request with any body + PostTenantUuidFlowDeleteWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowDeleteResponse, error) - PostFlowDeleteWithResponse(ctx context.Context, params *PostFlowDeleteParams, body PostFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFlowDeleteResponse, error) + PostTenantUuidFlowDeleteWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowDeleteResponse, error) - // GetTopologyWithResponse request - GetTopologyWithResponse(ctx context.Context, params *GetTopologyParams, reqEditors ...RequestEditorFn) (*GetTopologyResponse, error) + // GetTenantUuidTopologyWithResponse request + GetTenantUuidTopologyWithResponse(ctx context.Context, uuid Uuid, params *GetTenantUuidTopologyParams, reqEditors ...RequestEditorFn) (*GetTenantUuidTopologyResponse, error) } -type PostDeployResponse struct { +type PostTenantUuidDeployResponse struct { Body []byte HTTPResponse *http.Response JSON200 *string } // Status returns HTTPResponse.Status -func (r PostDeployResponse) Status() string { +func (r PostTenantUuidDeployResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -505,21 +467,21 @@ func (r PostDeployResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PostDeployResponse) StatusCode() int { +func (r PostTenantUuidDeployResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type PostFlowCreateResponse struct { +type PostTenantUuidFlowCreateResponse struct { Body []byte HTTPResponse *http.Response JSON200 *string } // Status returns HTTPResponse.Status -func (r PostFlowCreateResponse) Status() string { +func (r PostTenantUuidFlowCreateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -527,21 +489,21 @@ func (r PostFlowCreateResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PostFlowCreateResponse) StatusCode() int { +func (r PostTenantUuidFlowCreateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type PostFlowDeleteResponse struct { +type PostTenantUuidFlowDeleteResponse struct { Body []byte HTTPResponse *http.Response JSON200 *string } // Status returns HTTPResponse.Status -func (r PostFlowDeleteResponse) Status() string { +func (r PostTenantUuidFlowDeleteResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -549,21 +511,21 @@ func (r PostFlowDeleteResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PostFlowDeleteResponse) StatusCode() int { +func (r PostTenantUuidFlowDeleteResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetTopologyResponse struct { +type GetTenantUuidTopologyResponse struct { Body []byte HTTPResponse *http.Response JSON200 *ClusterTopology } // Status returns HTTPResponse.Status -func (r GetTopologyResponse) Status() string { +func (r GetTenantUuidTopologyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -571,82 +533,82 @@ func (r GetTopologyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetTopologyResponse) StatusCode() int { +func (r GetTenantUuidTopologyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -// PostDeployWithBodyWithResponse request with arbitrary body returning *PostDeployResponse -func (c *ClientWithResponses) PostDeployWithBodyWithResponse(ctx context.Context, params *PostDeployParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostDeployResponse, error) { - rsp, err := c.PostDeployWithBody(ctx, params, contentType, body, reqEditors...) +// PostTenantUuidDeployWithBodyWithResponse request with arbitrary body returning *PostTenantUuidDeployResponse +func (c *ClientWithResponses) PostTenantUuidDeployWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidDeployResponse, error) { + rsp, err := c.PostTenantUuidDeployWithBody(ctx, uuid, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParsePostDeployResponse(rsp) + return ParsePostTenantUuidDeployResponse(rsp) } -func (c *ClientWithResponses) PostDeployWithResponse(ctx context.Context, params *PostDeployParams, body PostDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostDeployResponse, error) { - rsp, err := c.PostDeploy(ctx, params, body, reqEditors...) +func (c *ClientWithResponses) PostTenantUuidDeployWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidDeployResponse, error) { + rsp, err := c.PostTenantUuidDeploy(ctx, uuid, body, reqEditors...) if err != nil { return nil, err } - return ParsePostDeployResponse(rsp) + return ParsePostTenantUuidDeployResponse(rsp) } -// PostFlowCreateWithBodyWithResponse request with arbitrary body returning *PostFlowCreateResponse -func (c *ClientWithResponses) PostFlowCreateWithBodyWithResponse(ctx context.Context, params *PostFlowCreateParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFlowCreateResponse, error) { - rsp, err := c.PostFlowCreateWithBody(ctx, params, contentType, body, reqEditors...) +// PostTenantUuidFlowCreateWithBodyWithResponse request with arbitrary body returning *PostTenantUuidFlowCreateResponse +func (c *ClientWithResponses) PostTenantUuidFlowCreateWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowCreateResponse, error) { + rsp, err := c.PostTenantUuidFlowCreateWithBody(ctx, uuid, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParsePostFlowCreateResponse(rsp) + return ParsePostTenantUuidFlowCreateResponse(rsp) } -func (c *ClientWithResponses) PostFlowCreateWithResponse(ctx context.Context, params *PostFlowCreateParams, body PostFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFlowCreateResponse, error) { - rsp, err := c.PostFlowCreate(ctx, params, body, reqEditors...) +func (c *ClientWithResponses) PostTenantUuidFlowCreateWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidFlowCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowCreateResponse, error) { + rsp, err := c.PostTenantUuidFlowCreate(ctx, uuid, body, reqEditors...) if err != nil { return nil, err } - return ParsePostFlowCreateResponse(rsp) + return ParsePostTenantUuidFlowCreateResponse(rsp) } -// PostFlowDeleteWithBodyWithResponse request with arbitrary body returning *PostFlowDeleteResponse -func (c *ClientWithResponses) PostFlowDeleteWithBodyWithResponse(ctx context.Context, params *PostFlowDeleteParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFlowDeleteResponse, error) { - rsp, err := c.PostFlowDeleteWithBody(ctx, params, contentType, body, reqEditors...) +// PostTenantUuidFlowDeleteWithBodyWithResponse request with arbitrary body returning *PostTenantUuidFlowDeleteResponse +func (c *ClientWithResponses) PostTenantUuidFlowDeleteWithBodyWithResponse(ctx context.Context, uuid Uuid, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowDeleteResponse, error) { + rsp, err := c.PostTenantUuidFlowDeleteWithBody(ctx, uuid, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParsePostFlowDeleteResponse(rsp) + return ParsePostTenantUuidFlowDeleteResponse(rsp) } -func (c *ClientWithResponses) PostFlowDeleteWithResponse(ctx context.Context, params *PostFlowDeleteParams, body PostFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFlowDeleteResponse, error) { - rsp, err := c.PostFlowDelete(ctx, params, body, reqEditors...) +func (c *ClientWithResponses) PostTenantUuidFlowDeleteWithResponse(ctx context.Context, uuid Uuid, body PostTenantUuidFlowDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTenantUuidFlowDeleteResponse, error) { + rsp, err := c.PostTenantUuidFlowDelete(ctx, uuid, body, reqEditors...) if err != nil { return nil, err } - return ParsePostFlowDeleteResponse(rsp) + return ParsePostTenantUuidFlowDeleteResponse(rsp) } -// GetTopologyWithResponse request returning *GetTopologyResponse -func (c *ClientWithResponses) GetTopologyWithResponse(ctx context.Context, params *GetTopologyParams, reqEditors ...RequestEditorFn) (*GetTopologyResponse, error) { - rsp, err := c.GetTopology(ctx, params, reqEditors...) +// GetTenantUuidTopologyWithResponse request returning *GetTenantUuidTopologyResponse +func (c *ClientWithResponses) GetTenantUuidTopologyWithResponse(ctx context.Context, uuid Uuid, params *GetTenantUuidTopologyParams, reqEditors ...RequestEditorFn) (*GetTenantUuidTopologyResponse, error) { + rsp, err := c.GetTenantUuidTopology(ctx, uuid, params, reqEditors...) if err != nil { return nil, err } - return ParseGetTopologyResponse(rsp) + return ParseGetTenantUuidTopologyResponse(rsp) } -// ParsePostDeployResponse parses an HTTP response from a PostDeployWithResponse call -func ParsePostDeployResponse(rsp *http.Response) (*PostDeployResponse, error) { +// ParsePostTenantUuidDeployResponse parses an HTTP response from a PostTenantUuidDeployWithResponse call +func ParsePostTenantUuidDeployResponse(rsp *http.Response) (*PostTenantUuidDeployResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PostDeployResponse{ + response := &PostTenantUuidDeployResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -664,15 +626,15 @@ func ParsePostDeployResponse(rsp *http.Response) (*PostDeployResponse, error) { return response, nil } -// ParsePostFlowCreateResponse parses an HTTP response from a PostFlowCreateWithResponse call -func ParsePostFlowCreateResponse(rsp *http.Response) (*PostFlowCreateResponse, error) { +// ParsePostTenantUuidFlowCreateResponse parses an HTTP response from a PostTenantUuidFlowCreateWithResponse call +func ParsePostTenantUuidFlowCreateResponse(rsp *http.Response) (*PostTenantUuidFlowCreateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PostFlowCreateResponse{ + response := &PostTenantUuidFlowCreateResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -690,15 +652,15 @@ func ParsePostFlowCreateResponse(rsp *http.Response) (*PostFlowCreateResponse, e return response, nil } -// ParsePostFlowDeleteResponse parses an HTTP response from a PostFlowDeleteWithResponse call -func ParsePostFlowDeleteResponse(rsp *http.Response) (*PostFlowDeleteResponse, error) { +// ParsePostTenantUuidFlowDeleteResponse parses an HTTP response from a PostTenantUuidFlowDeleteWithResponse call +func ParsePostTenantUuidFlowDeleteResponse(rsp *http.Response) (*PostTenantUuidFlowDeleteResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PostFlowDeleteResponse{ + response := &PostTenantUuidFlowDeleteResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -716,15 +678,15 @@ func ParsePostFlowDeleteResponse(rsp *http.Response) (*PostFlowDeleteResponse, e return response, nil } -// ParseGetTopologyResponse parses an HTTP response from a GetTopologyWithResponse call -func ParseGetTopologyResponse(rsp *http.Response) (*GetTopologyResponse, error) { +// ParseGetTenantUuidTopologyResponse parses an HTTP response from a GetTenantUuidTopologyWithResponse call +func ParseGetTenantUuidTopologyResponse(rsp *http.Response) (*GetTenantUuidTopologyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetTopologyResponse{ + response := &GetTenantUuidTopologyResponse{ Body: bodyBytes, HTTPResponse: rsp, } diff --git a/libs/cli-kontrol-api/api/golang/server/server.gen.go b/libs/cli-kontrol-api/api/golang/server/server.gen.go index a39a3312..1533cd85 100644 --- a/libs/cli-kontrol-api/api/golang/server/server.gen.go +++ b/libs/cli-kontrol-api/api/golang/server/server.gen.go @@ -25,17 +25,17 @@ import ( // ServerInterface represents all server handlers. type ServerInterface interface { - // (POST /deploy) - PostDeploy(ctx echo.Context, params PostDeployParams) error + // (POST /tenant/{uuid}/deploy) + PostTenantUuidDeploy(ctx echo.Context, uuid Uuid) error - // (POST /flow/create) - PostFlowCreate(ctx echo.Context, params PostFlowCreateParams) error + // (POST /tenant/{uuid}/flow/create) + PostTenantUuidFlowCreate(ctx echo.Context, uuid Uuid) error - // (POST /flow/delete) - PostFlowDelete(ctx echo.Context, params PostFlowDeleteParams) error + // (POST /tenant/{uuid}/flow/delete) + PostTenantUuidFlowDelete(ctx echo.Context, uuid Uuid) error - // (GET /topology) - GetTopology(ctx echo.Context, params GetTopologyParams) error + // (GET /tenant/{uuid}/topology) + GetTenantUuidTopology(ctx echo.Context, uuid Uuid, params GetTenantUuidTopologyParams) error } // ServerInterfaceWrapper converts echo contexts to parameters. @@ -43,66 +43,67 @@ type ServerInterfaceWrapper struct { Handler ServerInterface } -// PostDeploy converts echo context to params. -func (w *ServerInterfaceWrapper) PostDeploy(ctx echo.Context) error { +// PostTenantUuidDeploy converts echo context to params. +func (w *ServerInterfaceWrapper) PostTenantUuidDeploy(ctx echo.Context) error { var err error + // ------------- Path parameter "uuid" ------------- + var uuid Uuid - // Parameter object where we will unmarshal all parameters from the context - var params PostDeployParams - // ------------- Required query parameter "tenant" ------------- - - err = runtime.BindQueryParameter("form", true, true, "tenant", ctx.QueryParams(), ¶ms.Tenant) + err = runtime.BindStyledParameterWithOptions("simple", "uuid", ctx.Param("uuid"), &uuid, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tenant: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err)) } // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostDeploy(ctx, params) + err = w.Handler.PostTenantUuidDeploy(ctx, uuid) return err } -// PostFlowCreate converts echo context to params. -func (w *ServerInterfaceWrapper) PostFlowCreate(ctx echo.Context) error { +// PostTenantUuidFlowCreate converts echo context to params. +func (w *ServerInterfaceWrapper) PostTenantUuidFlowCreate(ctx echo.Context) error { var err error + // ------------- Path parameter "uuid" ------------- + var uuid Uuid - // Parameter object where we will unmarshal all parameters from the context - var params PostFlowCreateParams - // ------------- Required query parameter "tenant" ------------- - - err = runtime.BindQueryParameter("form", true, true, "tenant", ctx.QueryParams(), ¶ms.Tenant) + err = runtime.BindStyledParameterWithOptions("simple", "uuid", ctx.Param("uuid"), &uuid, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tenant: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err)) } // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostFlowCreate(ctx, params) + err = w.Handler.PostTenantUuidFlowCreate(ctx, uuid) return err } -// PostFlowDelete converts echo context to params. -func (w *ServerInterfaceWrapper) PostFlowDelete(ctx echo.Context) error { +// PostTenantUuidFlowDelete converts echo context to params. +func (w *ServerInterfaceWrapper) PostTenantUuidFlowDelete(ctx echo.Context) error { var err error + // ------------- Path parameter "uuid" ------------- + var uuid Uuid - // Parameter object where we will unmarshal all parameters from the context - var params PostFlowDeleteParams - // ------------- Required query parameter "tenant" ------------- - - err = runtime.BindQueryParameter("form", true, true, "tenant", ctx.QueryParams(), ¶ms.Tenant) + err = runtime.BindStyledParameterWithOptions("simple", "uuid", ctx.Param("uuid"), &uuid, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tenant: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err)) } // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostFlowDelete(ctx, params) + err = w.Handler.PostTenantUuidFlowDelete(ctx, uuid) return err } -// GetTopology converts echo context to params. -func (w *ServerInterfaceWrapper) GetTopology(ctx echo.Context) error { +// GetTenantUuidTopology converts echo context to params. +func (w *ServerInterfaceWrapper) GetTenantUuidTopology(ctx echo.Context) error { var err error + // ------------- Path parameter "uuid" ------------- + var uuid Uuid + + err = runtime.BindStyledParameterWithOptions("simple", "uuid", ctx.Param("uuid"), &uuid, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err)) + } // Parameter object where we will unmarshal all parameters from the context - var params GetTopologyParams + var params GetTenantUuidTopologyParams // ------------- Optional query parameter "namespace" ------------- err = runtime.BindQueryParameter("form", true, false, "namespace", ctx.QueryParams(), ¶ms.Namespace) @@ -110,15 +111,8 @@ func (w *ServerInterfaceWrapper) GetTopology(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespace: %s", err)) } - // ------------- Required query parameter "tenant" ------------- - - err = runtime.BindQueryParameter("form", true, true, "tenant", ctx.QueryParams(), ¶ms.Tenant) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tenant: %s", err)) - } - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetTopology(ctx, params) + err = w.Handler.GetTenantUuidTopology(ctx, uuid, params) return err } @@ -150,78 +144,79 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL Handler: si, } - router.POST(baseURL+"/deploy", wrapper.PostDeploy) - router.POST(baseURL+"/flow/create", wrapper.PostFlowCreate) - router.POST(baseURL+"/flow/delete", wrapper.PostFlowDelete) - router.GET(baseURL+"/topology", wrapper.GetTopology) + router.POST(baseURL+"/tenant/:uuid/deploy", wrapper.PostTenantUuidDeploy) + router.POST(baseURL+"/tenant/:uuid/flow/create", wrapper.PostTenantUuidFlowCreate) + router.POST(baseURL+"/tenant/:uuid/flow/delete", wrapper.PostTenantUuidFlowDelete) + router.GET(baseURL+"/tenant/:uuid/topology", wrapper.GetTenantUuidTopology) } -type PostDeployRequestObject struct { - Params PostDeployParams - Body *PostDeployJSONRequestBody +type PostTenantUuidDeployRequestObject struct { + Uuid Uuid `json:"uuid"` + Body *PostTenantUuidDeployJSONRequestBody } -type PostDeployResponseObject interface { - VisitPostDeployResponse(w http.ResponseWriter) error +type PostTenantUuidDeployResponseObject interface { + VisitPostTenantUuidDeployResponse(w http.ResponseWriter) error } -type PostDeploy200JSONResponse string +type PostTenantUuidDeploy200JSONResponse string -func (response PostDeploy200JSONResponse) VisitPostDeployResponse(w http.ResponseWriter) error { +func (response PostTenantUuidDeploy200JSONResponse) VisitPostTenantUuidDeployResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type PostFlowCreateRequestObject struct { - Params PostFlowCreateParams - Body *PostFlowCreateJSONRequestBody +type PostTenantUuidFlowCreateRequestObject struct { + Uuid Uuid `json:"uuid"` + Body *PostTenantUuidFlowCreateJSONRequestBody } -type PostFlowCreateResponseObject interface { - VisitPostFlowCreateResponse(w http.ResponseWriter) error +type PostTenantUuidFlowCreateResponseObject interface { + VisitPostTenantUuidFlowCreateResponse(w http.ResponseWriter) error } -type PostFlowCreate200JSONResponse string +type PostTenantUuidFlowCreate200JSONResponse string -func (response PostFlowCreate200JSONResponse) VisitPostFlowCreateResponse(w http.ResponseWriter) error { +func (response PostTenantUuidFlowCreate200JSONResponse) VisitPostTenantUuidFlowCreateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type PostFlowDeleteRequestObject struct { - Params PostFlowDeleteParams - Body *PostFlowDeleteJSONRequestBody +type PostTenantUuidFlowDeleteRequestObject struct { + Uuid Uuid `json:"uuid"` + Body *PostTenantUuidFlowDeleteJSONRequestBody } -type PostFlowDeleteResponseObject interface { - VisitPostFlowDeleteResponse(w http.ResponseWriter) error +type PostTenantUuidFlowDeleteResponseObject interface { + VisitPostTenantUuidFlowDeleteResponse(w http.ResponseWriter) error } -type PostFlowDelete200JSONResponse string +type PostTenantUuidFlowDelete200JSONResponse string -func (response PostFlowDelete200JSONResponse) VisitPostFlowDeleteResponse(w http.ResponseWriter) error { +func (response PostTenantUuidFlowDelete200JSONResponse) VisitPostTenantUuidFlowDeleteResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type GetTopologyRequestObject struct { - Params GetTopologyParams +type GetTenantUuidTopologyRequestObject struct { + Uuid Uuid `json:"uuid"` + Params GetTenantUuidTopologyParams } -type GetTopologyResponseObject interface { - VisitGetTopologyResponse(w http.ResponseWriter) error +type GetTenantUuidTopologyResponseObject interface { + VisitGetTenantUuidTopologyResponse(w http.ResponseWriter) error } -type GetTopology200JSONResponse ClusterTopology +type GetTenantUuidTopology200JSONResponse ClusterTopology -func (response GetTopology200JSONResponse) VisitGetTopologyResponse(w http.ResponseWriter) error { +func (response GetTenantUuidTopology200JSONResponse) VisitGetTenantUuidTopologyResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) @@ -231,17 +226,17 @@ func (response GetTopology200JSONResponse) VisitGetTopologyResponse(w http.Respo // StrictServerInterface represents all server handlers. type StrictServerInterface interface { - // (POST /deploy) - PostDeploy(ctx context.Context, request PostDeployRequestObject) (PostDeployResponseObject, error) + // (POST /tenant/{uuid}/deploy) + PostTenantUuidDeploy(ctx context.Context, request PostTenantUuidDeployRequestObject) (PostTenantUuidDeployResponseObject, error) - // (POST /flow/create) - PostFlowCreate(ctx context.Context, request PostFlowCreateRequestObject) (PostFlowCreateResponseObject, error) + // (POST /tenant/{uuid}/flow/create) + PostTenantUuidFlowCreate(ctx context.Context, request PostTenantUuidFlowCreateRequestObject) (PostTenantUuidFlowCreateResponseObject, error) - // (POST /flow/delete) - PostFlowDelete(ctx context.Context, request PostFlowDeleteRequestObject) (PostFlowDeleteResponseObject, error) + // (POST /tenant/{uuid}/flow/delete) + PostTenantUuidFlowDelete(ctx context.Context, request PostTenantUuidFlowDeleteRequestObject) (PostTenantUuidFlowDeleteResponseObject, error) - // (GET /topology) - GetTopology(ctx context.Context, request GetTopologyRequestObject) (GetTopologyResponseObject, error) + // (GET /tenant/{uuid}/topology) + GetTenantUuidTopology(ctx context.Context, request GetTenantUuidTopologyRequestObject) (GetTenantUuidTopologyResponseObject, error) } type StrictHandlerFunc = strictecho.StrictEchoHandlerFunc @@ -256,118 +251,119 @@ type strictHandler struct { middlewares []StrictMiddlewareFunc } -// PostDeploy operation middleware -func (sh *strictHandler) PostDeploy(ctx echo.Context, params PostDeployParams) error { - var request PostDeployRequestObject +// PostTenantUuidDeploy operation middleware +func (sh *strictHandler) PostTenantUuidDeploy(ctx echo.Context, uuid Uuid) error { + var request PostTenantUuidDeployRequestObject - request.Params = params + request.Uuid = uuid - var body PostDeployJSONRequestBody + var body PostTenantUuidDeployJSONRequestBody if err := ctx.Bind(&body); err != nil { return err } request.Body = &body handler := func(ctx echo.Context, request interface{}) (interface{}, error) { - return sh.ssi.PostDeploy(ctx.Request().Context(), request.(PostDeployRequestObject)) + return sh.ssi.PostTenantUuidDeploy(ctx.Request().Context(), request.(PostTenantUuidDeployRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PostDeploy") + handler = middleware(handler, "PostTenantUuidDeploy") } response, err := handler(ctx, request) if err != nil { return err - } else if validResponse, ok := response.(PostDeployResponseObject); ok { - return validResponse.VisitPostDeployResponse(ctx.Response()) + } else if validResponse, ok := response.(PostTenantUuidDeployResponseObject); ok { + return validResponse.VisitPostTenantUuidDeployResponse(ctx.Response()) } else if response != nil { return fmt.Errorf("unexpected response type: %T", response) } return nil } -// PostFlowCreate operation middleware -func (sh *strictHandler) PostFlowCreate(ctx echo.Context, params PostFlowCreateParams) error { - var request PostFlowCreateRequestObject +// PostTenantUuidFlowCreate operation middleware +func (sh *strictHandler) PostTenantUuidFlowCreate(ctx echo.Context, uuid Uuid) error { + var request PostTenantUuidFlowCreateRequestObject - request.Params = params + request.Uuid = uuid - var body PostFlowCreateJSONRequestBody + var body PostTenantUuidFlowCreateJSONRequestBody if err := ctx.Bind(&body); err != nil { return err } request.Body = &body handler := func(ctx echo.Context, request interface{}) (interface{}, error) { - return sh.ssi.PostFlowCreate(ctx.Request().Context(), request.(PostFlowCreateRequestObject)) + return sh.ssi.PostTenantUuidFlowCreate(ctx.Request().Context(), request.(PostTenantUuidFlowCreateRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PostFlowCreate") + handler = middleware(handler, "PostTenantUuidFlowCreate") } response, err := handler(ctx, request) if err != nil { return err - } else if validResponse, ok := response.(PostFlowCreateResponseObject); ok { - return validResponse.VisitPostFlowCreateResponse(ctx.Response()) + } else if validResponse, ok := response.(PostTenantUuidFlowCreateResponseObject); ok { + return validResponse.VisitPostTenantUuidFlowCreateResponse(ctx.Response()) } else if response != nil { return fmt.Errorf("unexpected response type: %T", response) } return nil } -// PostFlowDelete operation middleware -func (sh *strictHandler) PostFlowDelete(ctx echo.Context, params PostFlowDeleteParams) error { - var request PostFlowDeleteRequestObject +// PostTenantUuidFlowDelete operation middleware +func (sh *strictHandler) PostTenantUuidFlowDelete(ctx echo.Context, uuid Uuid) error { + var request PostTenantUuidFlowDeleteRequestObject - request.Params = params + request.Uuid = uuid - var body PostFlowDeleteJSONRequestBody + var body PostTenantUuidFlowDeleteJSONRequestBody if err := ctx.Bind(&body); err != nil { return err } request.Body = &body handler := func(ctx echo.Context, request interface{}) (interface{}, error) { - return sh.ssi.PostFlowDelete(ctx.Request().Context(), request.(PostFlowDeleteRequestObject)) + return sh.ssi.PostTenantUuidFlowDelete(ctx.Request().Context(), request.(PostTenantUuidFlowDeleteRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PostFlowDelete") + handler = middleware(handler, "PostTenantUuidFlowDelete") } response, err := handler(ctx, request) if err != nil { return err - } else if validResponse, ok := response.(PostFlowDeleteResponseObject); ok { - return validResponse.VisitPostFlowDeleteResponse(ctx.Response()) + } else if validResponse, ok := response.(PostTenantUuidFlowDeleteResponseObject); ok { + return validResponse.VisitPostTenantUuidFlowDeleteResponse(ctx.Response()) } else if response != nil { return fmt.Errorf("unexpected response type: %T", response) } return nil } -// GetTopology operation middleware -func (sh *strictHandler) GetTopology(ctx echo.Context, params GetTopologyParams) error { - var request GetTopologyRequestObject +// GetTenantUuidTopology operation middleware +func (sh *strictHandler) GetTenantUuidTopology(ctx echo.Context, uuid Uuid, params GetTenantUuidTopologyParams) error { + var request GetTenantUuidTopologyRequestObject + request.Uuid = uuid request.Params = params handler := func(ctx echo.Context, request interface{}) (interface{}, error) { - return sh.ssi.GetTopology(ctx.Request().Context(), request.(GetTopologyRequestObject)) + return sh.ssi.GetTenantUuidTopology(ctx.Request().Context(), request.(GetTenantUuidTopologyRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "GetTopology") + handler = middleware(handler, "GetTenantUuidTopology") } response, err := handler(ctx, request) if err != nil { return err - } else if validResponse, ok := response.(GetTopologyResponseObject); ok { - return validResponse.VisitGetTopologyResponse(ctx.Response()) + } else if validResponse, ok := response.(GetTenantUuidTopologyResponseObject); ok { + return validResponse.VisitGetTenantUuidTopologyResponse(ctx.Response()) } else if response != nil { return fmt.Errorf("unexpected response type: %T", response) } @@ -377,19 +373,20 @@ func (sh *strictHandler) GetTopology(ctx echo.Context, params GetTopologyParams) // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "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", + "Ik4v6lKWpMkw/BcAAP//SreIgXAMAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/libs/cli-kontrol-api/api/golang/types/types.gen.go b/libs/cli-kontrol-api/api/golang/types/types.gen.go index e8921c64..ab3adb9a 100644 --- a/libs/cli-kontrol-api/api/golang/types/types.gen.go +++ b/libs/cli-kontrol-api/api/golang/types/types.gen.go @@ -46,41 +46,20 @@ type ProdFlowSpec struct { DockerCompose *[]compose.ServiceConfig `json:"docker-compose,omitempty"` } -// Tenant defines model for tenant. -type Tenant = string +// Uuid defines model for uuid. +type Uuid = string -// PostDeployParams defines parameters for PostDeploy. -type PostDeployParams struct { - // Tenant UUID of the tenant - Tenant Tenant `form:"tenant" json:"tenant"` -} - -// PostFlowCreateParams defines parameters for PostFlowCreate. -type PostFlowCreateParams struct { - // Tenant UUID of the tenant - Tenant Tenant `form:"tenant" json:"tenant"` -} - -// PostFlowDeleteParams defines parameters for PostFlowDelete. -type PostFlowDeleteParams struct { - // Tenant UUID of the tenant - Tenant Tenant `form:"tenant" json:"tenant"` -} - -// GetTopologyParams defines parameters for GetTopology. -type GetTopologyParams struct { +// GetTenantUuidTopologyParams defines parameters for GetTenantUuidTopology. +type GetTenantUuidTopologyParams struct { // Namespace The namespace for which to retrieve the topology Namespace *string `form:"namespace,omitempty" json:"namespace,omitempty"` - - // Tenant UUID of the tenant - Tenant Tenant `form:"tenant" json:"tenant"` } -// PostDeployJSONRequestBody defines body for PostDeploy for application/json ContentType. -type PostDeployJSONRequestBody = ProdFlowSpec +// PostTenantUuidDeployJSONRequestBody defines body for PostTenantUuidDeploy for application/json ContentType. +type PostTenantUuidDeployJSONRequestBody = ProdFlowSpec -// PostFlowCreateJSONRequestBody defines body for PostFlowCreate for application/json ContentType. -type PostFlowCreateJSONRequestBody = DevFlowSpec +// PostTenantUuidFlowCreateJSONRequestBody defines body for PostTenantUuidFlowCreate for application/json ContentType. +type PostTenantUuidFlowCreateJSONRequestBody = DevFlowSpec -// PostFlowDeleteJSONRequestBody defines body for PostFlowDelete for application/json ContentType. -type PostFlowDeleteJSONRequestBody = ProdFlowSpec +// PostTenantUuidFlowDeleteJSONRequestBody defines body for PostTenantUuidFlowDelete for application/json ContentType. +type PostTenantUuidFlowDeleteJSONRequestBody = ProdFlowSpec diff --git a/libs/cli-kontrol-api/api/typescript/client/types.d.ts b/libs/cli-kontrol-api/api/typescript/client/types.d.ts index 275cabb6..657e5d9e 100644 --- a/libs/cli-kontrol-api/api/typescript/client/types.d.ts +++ b/libs/cli-kontrol-api/api/typescript/client/types.d.ts @@ -5,11 +5,11 @@ export interface paths { - "/flow/create": { + "/tenant/{uuid}/flow/create": { post: { parameters: { - query: { - tenant: components["parameters"]["tenant"]; + path: { + uuid: components["parameters"]["uuid"]; }; }; /** @description Create a dev flow */ @@ -28,11 +28,11 @@ export interface paths { }; }; }; - "/flow/delete": { + "/tenant/{uuid}/flow/delete": { post: { parameters: { - query: { - tenant: components["parameters"]["tenant"]; + path: { + uuid: components["parameters"]["uuid"]; }; }; /** @description Delete dev flow (revert back to prod only) */ @@ -51,11 +51,11 @@ export interface paths { }; }; }; - "/deploy": { + "/tenant/{uuid}/deploy": { post: { parameters: { - query: { - tenant: components["parameters"]["tenant"]; + path: { + uuid: components["parameters"]["uuid"]; }; }; /** @description Deploy a prod only cluster */ @@ -74,13 +74,15 @@ export interface paths { }; }; }; - "/topology": { + "/tenant/{uuid}/topology": { get: { parameters: { - query: { + query?: { /** @description The namespace for which to retrieve the topology */ namespace?: string; - tenant: components["parameters"]["tenant"]; + }; + path: { + uuid: components["parameters"]["uuid"]; }; }; responses: { @@ -130,8 +132,8 @@ export interface components { }; responses: never; parameters: { - /** @description UUID of the tenant */ - tenant: string; + /** @description UUID of the resource */ + uuid: string; }; requestBodies: never; headers: never; diff --git a/libs/cli-kontrol-api/specs/api.yaml b/libs/cli-kontrol-api/specs/api.yaml index d4bbe300..b8a83263 100644 --- a/libs/cli-kontrol-api/specs/api.yaml +++ b/libs/cli-kontrol-api/specs/api.yaml @@ -3,10 +3,10 @@ info: title: CLI/Kontrol API version: 1.0.0 paths: - /flow/create: + /tenant/{uuid}/flow/create: post: parameters: - - $ref: "#/components/parameters/tenant" + - $ref: "#/components/parameters/uuid" requestBody: description: Create a dev flow required: true @@ -21,10 +21,10 @@ paths: application/json: schema: type: string - /flow/delete: + /tenant/{uuid}/flow/delete: post: parameters: - - $ref: "#/components/parameters/tenant" + - $ref: "#/components/parameters/uuid" requestBody: description: Delete dev flow (revert back to prod only) required: true @@ -39,10 +39,10 @@ paths: application/json: schema: type: string - /deploy: + /tenant/{uuid}/deploy: post: parameters: - - $ref: "#/components/parameters/tenant" + - $ref: "#/components/parameters/uuid" requestBody: description: Deploy a prod only cluster required: true @@ -57,7 +57,7 @@ paths: application/json: schema: type: string - /topology: + /tenant/{uuid}/topology: get: parameters: - in: query @@ -66,7 +66,7 @@ paths: type: string required: false description: The namespace for which to retrieve the topology - - $ref: "#/components/parameters/tenant" + - $ref: "#/components/parameters/uuid" responses: "200": description: Topology information @@ -77,11 +77,11 @@ paths: components: parameters: - tenant: - name: tenant - in: query + uuid: + name: uuid + in: path required: true - description: UUID of the tenant + description: UUID of the resource schema: type: string diff --git a/libs/manager-kontrol-api/api/golang/client/client.gen.go b/libs/manager-kontrol-api/api/golang/client/client.gen.go index f9b5b156..6f1b3b1e 100644 --- a/libs/manager-kontrol-api/api/golang/client/client.gen.go +++ b/libs/manager-kontrol-api/api/golang/client/client.gen.go @@ -89,12 +89,12 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption { // The interface specification for the client above. type ClientInterface interface { - // GetClusterResources request - GetClusterResources(ctx context.Context, params *GetClusterResourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetTenantUuidClusterResources request + GetTenantUuidClusterResources(ctx context.Context, uuid Uuid, params *GetTenantUuidClusterResourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) } -func (c *Client) GetClusterResources(ctx context.Context, params *GetClusterResourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetClusterResourcesRequest(c.Server, params) +func (c *Client) GetTenantUuidClusterResources(ctx context.Context, uuid Uuid, params *GetTenantUuidClusterResourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTenantUuidClusterResourcesRequest(c.Server, uuid, params) if err != nil { return nil, err } @@ -105,16 +105,23 @@ func (c *Client) GetClusterResources(ctx context.Context, params *GetClusterReso return c.Client.Do(req) } -// NewGetClusterResourcesRequest generates requests for GetClusterResources -func NewGetClusterResourcesRequest(server string, params *GetClusterResourcesParams) (*http.Request, error) { +// NewGetTenantUuidClusterResourcesRequest generates requests for GetTenantUuidClusterResources +func NewGetTenantUuidClusterResourcesRequest(server string, uuid Uuid, params *GetTenantUuidClusterResourcesParams) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/cluster-resources") + operationPath := fmt.Sprintf("/tenant/%s/cluster-resources", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -143,18 +150,6 @@ func NewGetClusterResourcesRequest(server string, params *GetClusterResourcesPar } - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tenant", runtime.ParamLocationQuery, params.Tenant); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - queryURL.RawQuery = queryValues.Encode() } @@ -209,11 +204,11 @@ func WithBaseURL(baseURL string) ClientOption { // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { - // GetClusterResourcesWithResponse request - GetClusterResourcesWithResponse(ctx context.Context, params *GetClusterResourcesParams, reqEditors ...RequestEditorFn) (*GetClusterResourcesResponse, error) + // GetTenantUuidClusterResourcesWithResponse request + GetTenantUuidClusterResourcesWithResponse(ctx context.Context, uuid Uuid, params *GetTenantUuidClusterResourcesParams, reqEditors ...RequestEditorFn) (*GetTenantUuidClusterResourcesResponse, error) } -type GetClusterResourcesResponse struct { +type GetTenantUuidClusterResourcesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *ClusterResources @@ -221,7 +216,7 @@ type GetClusterResourcesResponse struct { } // Status returns HTTPResponse.Status -func (r GetClusterResourcesResponse) Status() string { +func (r GetTenantUuidClusterResourcesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -229,31 +224,31 @@ func (r GetClusterResourcesResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetClusterResourcesResponse) StatusCode() int { +func (r GetTenantUuidClusterResourcesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -// GetClusterResourcesWithResponse request returning *GetClusterResourcesResponse -func (c *ClientWithResponses) GetClusterResourcesWithResponse(ctx context.Context, params *GetClusterResourcesParams, reqEditors ...RequestEditorFn) (*GetClusterResourcesResponse, error) { - rsp, err := c.GetClusterResources(ctx, params, reqEditors...) +// GetTenantUuidClusterResourcesWithResponse request returning *GetTenantUuidClusterResourcesResponse +func (c *ClientWithResponses) GetTenantUuidClusterResourcesWithResponse(ctx context.Context, uuid Uuid, params *GetTenantUuidClusterResourcesParams, reqEditors ...RequestEditorFn) (*GetTenantUuidClusterResourcesResponse, error) { + rsp, err := c.GetTenantUuidClusterResources(ctx, uuid, params, reqEditors...) if err != nil { return nil, err } - return ParseGetClusterResourcesResponse(rsp) + return ParseGetTenantUuidClusterResourcesResponse(rsp) } -// ParseGetClusterResourcesResponse parses an HTTP response from a GetClusterResourcesWithResponse call -func ParseGetClusterResourcesResponse(rsp *http.Response) (*GetClusterResourcesResponse, error) { +// ParseGetTenantUuidClusterResourcesResponse parses an HTTP response from a GetTenantUuidClusterResourcesWithResponse call +func ParseGetTenantUuidClusterResourcesResponse(rsp *http.Response) (*GetTenantUuidClusterResourcesResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetClusterResourcesResponse{ + response := &GetTenantUuidClusterResourcesResponse{ Body: bodyBytes, HTTPResponse: rsp, } diff --git a/libs/manager-kontrol-api/api/golang/server/server.gen.go b/libs/manager-kontrol-api/api/golang/server/server.gen.go index 6fa171f5..0119bebd 100644 --- a/libs/manager-kontrol-api/api/golang/server/server.gen.go +++ b/libs/manager-kontrol-api/api/golang/server/server.gen.go @@ -25,8 +25,8 @@ import ( // ServerInterface represents all server handlers. type ServerInterface interface { // Cluster resource definition - // (GET /cluster-resources) - GetClusterResources(ctx echo.Context, params GetClusterResourcesParams) error + // (GET /tenant/{uuid}/cluster-resources) + GetTenantUuidClusterResources(ctx echo.Context, uuid Uuid, params GetTenantUuidClusterResourcesParams) error } // ServerInterfaceWrapper converts echo contexts to parameters. @@ -34,12 +34,19 @@ type ServerInterfaceWrapper struct { Handler ServerInterface } -// GetClusterResources converts echo context to params. -func (w *ServerInterfaceWrapper) GetClusterResources(ctx echo.Context) error { +// GetTenantUuidClusterResources converts echo context to params. +func (w *ServerInterfaceWrapper) GetTenantUuidClusterResources(ctx echo.Context) error { var err error + // ------------- Path parameter "uuid" ------------- + var uuid Uuid + + err = runtime.BindStyledParameterWithOptions("simple", "uuid", ctx.Param("uuid"), &uuid, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err)) + } // Parameter object where we will unmarshal all parameters from the context - var params GetClusterResourcesParams + var params GetTenantUuidClusterResourcesParams // ------------- Optional query parameter "namespace" ------------- err = runtime.BindQueryParameter("form", true, false, "namespace", ctx.QueryParams(), ¶ms.Namespace) @@ -47,15 +54,8 @@ func (w *ServerInterfaceWrapper) GetClusterResources(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespace: %s", err)) } - // ------------- Required query parameter "tenant" ------------- - - err = runtime.BindQueryParameter("form", true, true, "tenant", ctx.QueryParams(), ¶ms.Tenant) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tenant: %s", err)) - } - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetClusterResources(ctx, params) + err = w.Handler.GetTenantUuidClusterResources(ctx, uuid, params) return err } @@ -87,35 +87,36 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL Handler: si, } - router.GET(baseURL+"/cluster-resources", wrapper.GetClusterResources) + router.GET(baseURL+"/tenant/:uuid/cluster-resources", wrapper.GetTenantUuidClusterResources) } type NotOkJSONResponse ResponseInfo -type GetClusterResourcesRequestObject struct { - Params GetClusterResourcesParams +type GetTenantUuidClusterResourcesRequestObject struct { + Uuid Uuid `json:"uuid"` + Params GetTenantUuidClusterResourcesParams } -type GetClusterResourcesResponseObject interface { - VisitGetClusterResourcesResponse(w http.ResponseWriter) error +type GetTenantUuidClusterResourcesResponseObject interface { + VisitGetTenantUuidClusterResourcesResponse(w http.ResponseWriter) error } -type GetClusterResources200JSONResponse ClusterResources +type GetTenantUuidClusterResources200JSONResponse ClusterResources -func (response GetClusterResources200JSONResponse) VisitGetClusterResourcesResponse(w http.ResponseWriter) error { +func (response GetTenantUuidClusterResources200JSONResponse) VisitGetTenantUuidClusterResourcesResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type GetClusterResourcesdefaultJSONResponse struct { +type GetTenantUuidClusterResourcesdefaultJSONResponse struct { Body ResponseInfo StatusCode int } -func (response GetClusterResourcesdefaultJSONResponse) VisitGetClusterResourcesResponse(w http.ResponseWriter) error { +func (response GetTenantUuidClusterResourcesdefaultJSONResponse) VisitGetTenantUuidClusterResourcesResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) @@ -125,8 +126,8 @@ func (response GetClusterResourcesdefaultJSONResponse) VisitGetClusterResourcesR // StrictServerInterface represents all server handlers. type StrictServerInterface interface { // Cluster resource definition - // (GET /cluster-resources) - GetClusterResources(ctx context.Context, request GetClusterResourcesRequestObject) (GetClusterResourcesResponseObject, error) + // (GET /tenant/{uuid}/cluster-resources) + GetTenantUuidClusterResources(ctx context.Context, request GetTenantUuidClusterResourcesRequestObject) (GetTenantUuidClusterResourcesResponseObject, error) } type StrictHandlerFunc = strictecho.StrictEchoHandlerFunc @@ -141,25 +142,26 @@ type strictHandler struct { middlewares []StrictMiddlewareFunc } -// GetClusterResources operation middleware -func (sh *strictHandler) GetClusterResources(ctx echo.Context, params GetClusterResourcesParams) error { - var request GetClusterResourcesRequestObject +// GetTenantUuidClusterResources operation middleware +func (sh *strictHandler) GetTenantUuidClusterResources(ctx echo.Context, uuid Uuid, params GetTenantUuidClusterResourcesParams) error { + var request GetTenantUuidClusterResourcesRequestObject + request.Uuid = uuid request.Params = params handler := func(ctx echo.Context, request interface{}) (interface{}, error) { - return sh.ssi.GetClusterResources(ctx.Request().Context(), request.(GetClusterResourcesRequestObject)) + return sh.ssi.GetTenantUuidClusterResources(ctx.Request().Context(), request.(GetTenantUuidClusterResourcesRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "GetClusterResources") + handler = middleware(handler, "GetTenantUuidClusterResources") } response, err := handler(ctx, request) if err != nil { return err - } else if validResponse, ok := response.(GetClusterResourcesResponseObject); ok { - return validResponse.VisitGetClusterResourcesResponse(ctx.Response()) + } else if validResponse, ok := response.(GetTenantUuidClusterResourcesResponseObject); ok { + return validResponse.VisitGetTenantUuidClusterResourcesResponse(ctx.Response()) } else if response != nil { return fmt.Errorf("unexpected response type: %T", response) } @@ -169,18 +171,19 @@ func (sh *strictHandler) GetClusterResources(ctx echo.Context, params GetCluster // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "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", + "DP8EAAD//5cLa3PzBwAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/libs/manager-kontrol-api/api/golang/types/types.gen.go b/libs/manager-kontrol-api/api/golang/types/types.gen.go index 341cd5f8..b35cf525 100644 --- a/libs/manager-kontrol-api/api/golang/types/types.gen.go +++ b/libs/manager-kontrol-api/api/golang/types/types.gen.go @@ -35,17 +35,14 @@ type ResponseInfo struct { // ResponseType defines model for ResponseType. type ResponseType string -// Tenant defines model for tenant. -type Tenant = string +// Uuid defines model for uuid. +type Uuid = string // NotOk defines model for NotOk. type NotOk = ResponseInfo -// GetClusterResourcesParams defines parameters for GetClusterResources. -type GetClusterResourcesParams struct { +// GetTenantUuidClusterResourcesParams defines parameters for GetTenantUuidClusterResources. +type GetTenantUuidClusterResourcesParams struct { // Namespace The namespace for which to retrieve the cluster resources Namespace *string `form:"namespace,omitempty" json:"namespace,omitempty"` - - // Tenant UUID of the tenant - Tenant Tenant `form:"tenant" json:"tenant"` } diff --git a/libs/manager-kontrol-api/api/typescript/client/types.d.ts b/libs/manager-kontrol-api/api/typescript/client/types.d.ts index 1892aa6a..8097c463 100644 --- a/libs/manager-kontrol-api/api/typescript/client/types.d.ts +++ b/libs/manager-kontrol-api/api/typescript/client/types.d.ts @@ -5,14 +5,16 @@ export interface paths { - "/cluster-resources": { + "/tenant/{uuid}/cluster-resources": { /** Cluster resource definition */ get: { parameters: { - query: { + query?: { /** @description The namespace for which to retrieve the cluster resources */ namespace?: string; - tenant: components["parameters"]["tenant"]; + }; + path: { + uuid: components["parameters"]["uuid"]; }; }; responses: { @@ -57,8 +59,8 @@ export interface components { }; }; parameters: { - /** @description UUID of the tenant */ - tenant: string; + /** @description UUID of the resource */ + uuid: string; }; requestBodies: never; headers: never; diff --git a/libs/manager-kontrol-api/specs/api.yaml b/libs/manager-kontrol-api/specs/api.yaml index cf337dd6..a9508b10 100644 --- a/libs/manager-kontrol-api/specs/api.yaml +++ b/libs/manager-kontrol-api/specs/api.yaml @@ -3,7 +3,7 @@ info: title: Manager/Kontrol API version: 1.0.0 paths: - /cluster-resources: + /tenant/{uuid}/cluster-resources: get: tags: - cluster-resources @@ -15,7 +15,7 @@ paths: type: string required: false description: The namespace for which to retrieve the cluster resources - - $ref: "#/components/parameters/tenant" + - $ref: "#/components/parameters/uuid" responses: default: $ref: "#/components/responses/NotOk" @@ -28,11 +28,11 @@ paths: components: parameters: - tenant: - name: tenant - in: query + uuid: + name: uuid + in: path required: true - description: UUID of the tenant + description: UUID of the resource schema: type: string