diff --git a/apps/customer-portal/backend-v2/CLAUDE.md b/apps/customer-portal/backend-v2/CLAUDE.md index c8997c0ef5..7984ddfa06 100644 --- a/apps/customer-portal/backend-v2/CLAUDE.md +++ b/apps/customer-portal/backend-v2/CLAUDE.md @@ -6,16 +6,19 @@ responses for the frontend. This is a Go rewrite of the Ballerina backend at `apps/customer-portal/backend`, modeled on `apps/csm-portal/backend`'s conventions — read that backend's own CLAUDE.md too if something here is underspecified. -**Status: in progress.** 16 routes are wired up so far (`GET /health`, `GET`/`PATCH /users/me`, +**Status: in progress.** 26 routes are wired up so far (`GET /health`, `GET`/`PATCH /users/me`, `POST /accounts/search`, `GET /accounts/{id}`, `POST /projects/search`, `GET /projects/{id}`, `POST /cases/search`, `GET /cases/{id}`, `POST /cases`, `PATCH /cases/{id}`, -`POST /cases/{id}/comments`, `POST /deployments/search`, `POST /deployments`, -`GET /updates/product-update-levels`, `POST /updates/levels/search`) across three upstream -services: entity-service, the WSO2 Updates service, and SCIM. The Ballerina backend exposes ~100 -routes across many more modules (deployed products, attachments, comments, conversations, change -requests, call requests, catalogs, time cards, registry tokens, contacts, escalations, product -vulnerabilities, AI chat/websocket, etc.) — none of those are ported yet. Follow the recipe below -to add the next one. +`POST /cases/{id}/comments`, `POST /cases/{id}/activities/search`, `POST /deployments/search`, +`POST /deployments`, `POST /deployed-products/search`, `POST /deployed-products`, +`PATCH /deployed-products/{id}`, `POST /attachments`, `POST /attachments/search`, +`GET /attachments/{id}/content`, `DELETE /attachments/{id}`, `POST /products/search`, +`POST /products/{id}/versions/search`, `GET /updates/product-update-levels`, +`POST /updates/levels/search`) across three upstream services: entity-service, the WSO2 Updates +service, and SCIM. The Ballerina backend exposes ~100 routes across many more modules (generic +comments, conversations, change requests, call requests, catalogs, time cards, registry tokens, +contacts, escalations, product vulnerabilities, AI chat/websocket, etc.) — none of those are ported +yet. Follow the recipe below to add the next one. ## Which entity-service @@ -99,7 +102,30 @@ a genuine advantage of the DTO-mapping convention over raw passthrough — `apps has to model this as an OpenAPI `oneOf` in its spec and pass the ambiguity on to the frontend; here, it's resolved once in the mapper. Also deliberately excluded from account DTOs: `ArrToday` (annual recurring revenue — WSO2-internal financial data, never expose to the customer) and `Pod` -(WSO2-internal account routing). +(WSO2-internal account routing). `POST /products/search` and `POST /products/{id}/versions/search` +(`internal/entity/types.go`'s `ProductView`/`ProductVersionView`) use the exact same superset-struct +technique — e.g. `ProductVersionView.ReleaseDate` is typed `*string` even though the Postgres shape +is `time.Time` and the ServiceNow shape is a plain string, because a Go `*string` field decodes a +JSON string value regardless of which the source type actually was. + +**`json.RawMessage` on a request field usually means "preserve three states," not "skip validation."** +`entity.UpdateDeployedProductRequest.Description` is `json.RawMessage` specifically so entity-service +can distinguish "field absent" (omit), `"description": null` (clear the value), and +`"description": "value"` (set it) — a plain `*string` can't represent "absent vs. explicitly null." +When a portal request decodes straight into a struct with such a field (no restricted DTO needed +here, since Cores/TPS/Description/Active are all customer-appropriate), the raw bytes the client +sent pass through unchanged and this three-state semantic is preserved automatically — don't +"simplify" the field to `*string` when porting a similar endpoint. + +**Binary responses use a `doBinary`-shaped client method, not `getJSON`/`postJSON`.** +`GET /attachments/{id}/content` returns a raw file, not JSON — `entity.Client.doBinary` (added in +`internal/entity/client.go` alongside `do`) returns `(body []byte, contentType string, error)`, and +the handler (`internal/handler/attachments.go`) writes `Content-Type` from entity-service's own +(already-sanitized) header value and explicitly sets `Content-Disposition: attachment` itself — +never render an attachment inline, since entity-service's own allowlist coercion to +`application/octet-stream` for unrecognized types is a stored-XSS mitigation this backend must not +undo by, say, echoing a client-supplied filename into a `Content-Disposition` you construct +yourself. Request bodies are usually the exception: incoming search/filter/create payloads are decoded directly into the entity package's request structs (e.g. `entity.SearchProjectsRequest`, diff --git a/apps/customer-portal/backend-v2/README.md b/apps/customer-portal/backend-v2/README.md index f9c2623777..f374dcaacd 100644 --- a/apps/customer-portal/backend-v2/README.md +++ b/apps/customer-portal/backend-v2/README.md @@ -5,7 +5,7 @@ Go rewrite of the Ballerina backend at `apps/customer-portal/backend`. It is a b [`entity-service`](../../../entity-service) (this repo's `cs-tools/entity-service`, not the `digiops-cs/entity-service` the Ballerina backend targets), and shapes the responses for the frontend. -This is a work in progress — only the 16 routes listed below are implemented so far, across +This is a work in progress — only the 26 routes listed below are implemented so far, across entity-service, the WSO2 Updates service, and SCIM. Everything else the Ballerina backend exposes still needs a Go handler; add them following the pattern described in [CLAUDE.md](./CLAUDE.md#adding-a-new-endpoint). @@ -133,8 +133,11 @@ backend-v2/ │ │ ├── users.go # GetMe, PatchMe │ │ ├── accounts.go # SearchAccounts, GetAccount │ │ ├── projects.go # SearchProjects, GetProject -│ │ ├── cases.go # SearchCases, GetCase, CreateCase, UpdateCase, CreateCaseComment -│ │ └── deployments.go # SearchDeployments, CreateDeployment +│ │ ├── cases.go # SearchCases, GetCase, CreateCase, UpdateCase, CreateCaseComment, SearchCaseActivities +│ │ ├── deployments.go # SearchDeployments, CreateDeployment +│ │ ├── deployed_products.go # SearchDeployedProducts, CreateDeployedProduct, UpdateDeployedProduct +│ │ ├── attachments.go # CreateAttachment, SearchAttachments, GetAttachmentContent, DeleteAttachment +│ │ └── products.go # SearchProducts, SearchProductVersions │ ├── updates/ # OAuth2 HTTP client for the WSO2 Updates service │ │ ├── client.go # Config/Client/do() │ │ ├── types.go # upstream (snake_case) vs portal (camelCase) structs @@ -149,7 +152,10 @@ backend-v2/ │ │ ├── account.go │ │ ├── project.go │ │ ├── case.go -│ │ └── deployment.go +│ │ ├── deployment.go +│ │ ├── deployed_product.go +│ │ ├── attachment.go +│ │ └── product.go │ ├── middleware/ │ │ ├── auth.go # JWT validation; injects UserInfo into context │ │ ├── correlation.go # X-CSM-Correlation-ID propagation + slog enrichment @@ -160,8 +166,11 @@ backend-v2/ │ ├── users.go # GET/PATCH /users/me │ ├── accounts.go # POST /accounts/search, GET /accounts/{id} │ ├── projects.go # POST /projects/search, GET /projects/{id} -│ ├── cases.go # cases search/get/create/update/comment +│ ├── cases.go # cases search/get/create/update/comment/activities │ ├── deployments.go # POST /deployments/search, POST /deployments +│ ├── deployed_products.go # deployed-product search/create/update +│ ├── attachments.go # attachment create/search/download/delete +│ ├── products.go # POST /products/search, POST /products/{id}/versions/search │ └── updates.go # GET /updates/product-update-levels, POST /updates/levels/search ├── .choreo/component.yaml ├── openapi.yaml @@ -186,6 +195,16 @@ backend-v2/ - `POST /cases/{id}/comments` — add a comment to a case (always a plain customer comment) - `POST /deployments/search` — search deployments - `POST /deployments` — create a deployment (ServiceNow data source only) +- `POST /deployed-products/search` — search deployed products +- `POST /deployed-products` — create a deployed product (ServiceNow data source only) +- `PATCH /deployed-products/{id}` — update a deployed product's cores/tps/description, or deactivate it (ServiceNow data source only) +- `POST /attachments` — create an attachment +- `POST /attachments/search` — search attachments +- `GET /attachments/{id}/content` — download an attachment's raw file content +- `DELETE /attachments/{id}` — delete an attachment +- `POST /cases/{id}/activities/search` — search a case's activity feed (comments, attachments, field changes) +- `POST /products/search` — search products +- `POST /products/{id}/versions/search` — search a product's versions - `GET /updates/product-update-levels` — list product update levels - `POST /updates/levels/search` — search update descriptions between two update levels @@ -254,6 +273,42 @@ curl -X POST http://localhost:8080/deployments \ -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ -d '{"projectId":"","name":"Production"}' +curl -X POST http://localhost:8080/deployed-products/search \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"pagination":{"limit":10,"offset":0},"deploymentIds":[""]}' + +curl -X POST http://localhost:8080/deployed-products \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"projectId":"","deploymentId":"","productId":"","versionId":""}' + +curl -X PATCH http://localhost:8080/deployed-products/ \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"cores":4}' + +curl -X POST http://localhost:8080/attachments \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"referenceId":"","referenceType":"case","name":"log.txt","type":"text/plain","file":""}' + +curl -X POST http://localhost:8080/attachments/search \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"referenceId":"","referenceType":"case","pagination":{"limit":10,"offset":0}}' + +curl -H "x-jwt-assertion: $JWT" http://localhost:8080/attachments//content -o downloaded-file + +curl -X DELETE -H "x-jwt-assertion: $JWT" http://localhost:8080/attachments/ + +curl -X POST http://localhost:8080/cases//activities/search \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"pagination":{"limit":20,"offset":0}}' + +curl -X POST http://localhost:8080/products/search \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"pagination":{"limit":10,"offset":0},"searchQuery":"wso2am"}' + +curl -X POST http://localhost:8080/products//versions/search \ + -H "x-jwt-assertion: $JWT" -H "Content-Type: application/json" \ + -d '{"pagination":{"limit":10,"offset":0}}' + curl -H "x-jwt-assertion: $JWT" http://localhost:8080/updates/product-update-levels curl -X POST http://localhost:8080/updates/levels/search \ diff --git a/apps/customer-portal/backend-v2/cmd/server/main.go b/apps/customer-portal/backend-v2/cmd/server/main.go index da7d70b373..efff5e1de2 100644 --- a/apps/customer-portal/backend-v2/cmd/server/main.go +++ b/apps/customer-portal/backend-v2/cmd/server/main.go @@ -80,6 +80,9 @@ func main() { projectHandler := handler.NewProjectHandler(entityClient) caseHandler := handler.NewCaseHandler(entityClient) deploymentHandler := handler.NewDeploymentHandler(entityClient) + deployedProductHandler := handler.NewDeployedProductHandler(entityClient) + attachmentHandler := handler.NewAttachmentHandler(entityClient) + productHandler := handler.NewProductHandler(entityClient) accountHandler := handler.NewAccountHandler(entityClient) updatesHandler := handler.NewUpdatesHandler(updatesClient) @@ -109,12 +112,27 @@ func main() { mux.HandleFunc("POST /cases", caseHandler.CreateCase) mux.HandleFunc("PATCH /cases/{id}", caseHandler.PatchCase) mux.HandleFunc("POST /cases/{id}/comments", caseHandler.CreateCaseComment) + mux.HandleFunc("POST /cases/{id}/activities/search", caseHandler.SearchCaseActivities) mux.HandleFunc("POST /deployments/search", deploymentHandler.SearchDeployments) // POST /deployments only succeeds against entity-service's ServiceNow // data source — see internal/entity/deployments.go. mux.HandleFunc("POST /deployments", deploymentHandler.CreateDeployment) + mux.HandleFunc("POST /deployed-products/search", deployedProductHandler.SearchDeployedProducts) + // POST/PATCH /deployed-products only succeed against entity-service's + // ServiceNow data source — see internal/entity/deployed_products.go. + mux.HandleFunc("POST /deployed-products", deployedProductHandler.CreateDeployedProduct) + mux.HandleFunc("PATCH /deployed-products/{id}", deployedProductHandler.PatchDeployedProduct) + + mux.HandleFunc("POST /attachments", attachmentHandler.CreateAttachment) + mux.HandleFunc("POST /attachments/search", attachmentHandler.SearchAttachments) + mux.HandleFunc("GET /attachments/{id}/content", attachmentHandler.GetAttachmentContent) + mux.HandleFunc("DELETE /attachments/{id}", attachmentHandler.DeleteAttachment) + + mux.HandleFunc("POST /products/search", productHandler.SearchProducts) + mux.HandleFunc("POST /products/{id}/versions/search", productHandler.SearchProductVersions) + mux.HandleFunc("POST /accounts/search", accountHandler.SearchAccounts) mux.HandleFunc("GET /accounts/{id}", accountHandler.GetAccount) diff --git a/apps/customer-portal/backend-v2/internal/dto/attachment.go b/apps/customer-portal/backend-v2/internal/dto/attachment.go new file mode 100644 index 0000000000..2cca4a4543 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/dto/attachment.go @@ -0,0 +1,102 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package dto + +import ( + "time" + + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" +) + +// AttachmentCreateResponse is the portal's response for POST /attachments. +type AttachmentCreateResponse struct { + ID string `json:"id"` + SizeBytes int `json:"sizeBytes"` + CreatedOn time.Time `json:"createdOn"` + DownloadURL string `json:"downloadUrl"` +} + +// MapAttachmentCreate builds the portal response from entity-service's CreateAttachmentResponse. +func MapAttachmentCreate(r entity.CreateAttachmentResponse) AttachmentCreateResponse { + return AttachmentCreateResponse{ + ID: r.Attachment.ID, + SizeBytes: r.Attachment.SizeBytes, + CreatedOn: r.Attachment.CreatedOn, + DownloadURL: r.Attachment.DownloadURL, + } +} + +// AttachmentSummary is one item of the portal's response for POST /attachments/search. +type AttachmentSummary struct { + ID string `json:"id"` + ReferenceID string `json:"referenceId"` + ReferenceType string `json:"referenceType"` + Name string `json:"name"` + Type string `json:"type"` + SizeBytes int `json:"sizeBytes"` + Description *string `json:"description,omitempty"` + CreatedBy string `json:"createdBy"` + CreatedOn time.Time `json:"createdOn"` + DownloadURL *string `json:"downloadUrl,omitempty"` + PreviewURL *string `json:"previewUrl,omitempty"` +} + +// SearchAttachmentsResponse is the portal's response for POST /attachments/search. +type SearchAttachmentsResponse struct { + Attachments []AttachmentSummary `json:"attachments"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// MapSearchAttachments builds the portal response from entity-service's SearchAttachmentsResponse. +func MapSearchAttachments(r entity.SearchAttachmentsResponse) SearchAttachmentsResponse { + items := make([]AttachmentSummary, 0, len(r.Attachments)) + for _, a := range r.Attachments { + items = append(items, AttachmentSummary{ + ID: a.ID, + ReferenceID: a.ReferenceID, + ReferenceType: string(a.ReferenceType), + Name: a.Name, + Type: a.Type, + SizeBytes: a.SizeBytes, + Description: a.Description, + CreatedBy: a.CreatedBy, + CreatedOn: a.CreatedOn, + DownloadURL: a.DownloadURL, + PreviewURL: a.PreviewURL, + }) + } + return SearchAttachmentsResponse{ + Attachments: items, + Total: r.Total, + Limit: r.Limit, + Offset: r.Offset, + HasMore: r.HasMore, + } +} + +// DeleteResponse is the portal's response for DELETE /attachments/{id}. +type DeleteResponse struct { + Message string `json:"message"` +} + +// MapDeleteAttachment builds the portal response from entity-service's DeleteAttachmentResponse. +func MapDeleteAttachment(r entity.DeleteAttachmentResponse) DeleteResponse { + return DeleteResponse{Message: r.Message} +} diff --git a/apps/customer-portal/backend-v2/internal/dto/case.go b/apps/customer-portal/backend-v2/internal/dto/case.go index cc697fd144..9c180e5987 100644 --- a/apps/customer-portal/backend-v2/internal/dto/case.go +++ b/apps/customer-portal/backend-v2/internal/dto/case.go @@ -395,3 +395,85 @@ func MapCaseComment(r entity.CreateCaseCommentResponse) CaseCommentResponse { CreatedBy: r.Comment.CreatedBy, } } + +// CaseFieldChange describes a single field's value change in a case's activity feed. +type CaseFieldChange struct { + Field string `json:"field"` + FieldLabel string `json:"fieldLabel"` + PreviousValue string `json:"previousValue"` + NewValue string `json:"newValue"` +} + +// CaseActivity is one entry in the portal's response for +// POST /cases/{id}/activities/search — a discriminated union on Type, like +// entity-service's CaseActivity. Deliberately excludes entity-service's +// CreatedByFirstName/CreatedByLastName (redundant with CreatedBy, which +// carries the full name) and the raw internal actor ID. +type CaseActivity struct { + ID string `json:"id"` + Type string `json:"type"` + Content string `json:"content,omitempty"` + CreatedOn time.Time `json:"createdOn"` + CreatedBy string `json:"createdBy"` + CommentType *string `json:"commentType,omitempty"` + FileName string `json:"fileName,omitempty"` + ContentType string `json:"contentType,omitempty"` + SizeBytes int `json:"sizeBytes,omitempty"` + DownloadURL string `json:"downloadUrl,omitempty"` + Changes []CaseFieldChange `json:"changes,omitempty"` +} + +// SearchCaseActivitiesResponse is the portal's response for POST /cases/{id}/activities/search. +type SearchCaseActivitiesResponse struct { + Activity []CaseActivity `json:"activity"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// MapSearchCaseActivities builds the portal response from entity-service's SearchCaseActivitiesResponse. +func MapSearchCaseActivities(r entity.SearchCaseActivitiesResponse) SearchCaseActivitiesResponse { + items := make([]CaseActivity, 0, len(r.Activity)) + for _, a := range r.Activity { + var commentType *string + if a.CommentType != nil { + s := string(*a.CommentType) + commentType = &s + } + + var changes []CaseFieldChange + if len(a.Changes) > 0 { + changes = make([]CaseFieldChange, 0, len(a.Changes)) + for _, c := range a.Changes { + changes = append(changes, CaseFieldChange{ + Field: c.Field, + FieldLabel: c.FieldLabel, + PreviousValue: c.PreviousValue, + NewValue: c.NewValue, + }) + } + } + + items = append(items, CaseActivity{ + ID: a.ID, + Type: string(a.Type), + Content: a.Content, + CreatedOn: a.CreatedOn, + CreatedBy: a.CreatedByFullName, + CommentType: commentType, + FileName: a.FileName, + ContentType: a.ContentType, + SizeBytes: a.SizeBytes, + DownloadURL: a.DownloadURL, + Changes: changes, + }) + } + return SearchCaseActivitiesResponse{ + Activity: items, + Total: r.Total, + Limit: r.Limit, + Offset: r.Offset, + HasMore: r.HasMore, + } +} diff --git a/apps/customer-portal/backend-v2/internal/dto/deployed_product.go b/apps/customer-portal/backend-v2/internal/dto/deployed_product.go new file mode 100644 index 0000000000..46b284d55c --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/dto/deployed_product.go @@ -0,0 +1,121 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package dto + +import ( + "time" + + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" +) + +// DeployedProductVersion is the version reference embedded in a deployed product. +type DeployedProductVersion struct { + ID string `json:"id"` + Name string `json:"name"` + ReleasedDate *time.Time `json:"releasedDate,omitempty"` + SupportEoLDate *time.Time `json:"supportEoLDate,omitempty"` +} + +// DeployedProductSummary is one item of the portal's response for +// POST /deployed-products/search. +type DeployedProductSummary struct { + ID string `json:"id"` + Deployment Ref `json:"deployment"` + Product Ref `json:"product"` + Version *DeployedProductVersion `json:"version,omitempty"` + Cores *string `json:"cores,omitempty"` + TPS *string `json:"tps,omitempty"` + Category *string `json:"category,omitempty"` + CreatedOn time.Time `json:"createdOn"` + UpdatedOn time.Time `json:"updatedOn"` +} + +// SearchDeployedProductsResponse is the portal's response for POST /deployed-products/search. +type SearchDeployedProductsResponse struct { + DeployedProducts []DeployedProductSummary `json:"deployedProducts"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +func mapDeployedProductVersion(v *entity.DeployedProductVersionRef) *DeployedProductVersion { + if v == nil { + return nil + } + return &DeployedProductVersion{ + ID: v.ID, + Name: v.Name, + ReleasedDate: v.ReleasedDate, + SupportEoLDate: v.SupportEoLDate, + } +} + +// MapSearchDeployedProducts builds the portal response from entity-service's SearchDeployedProductsResponse. +func MapSearchDeployedProducts(r entity.SearchDeployedProductsResponse) SearchDeployedProductsResponse { + items := make([]DeployedProductSummary, 0, len(r.DeployedProducts)) + for _, d := range r.DeployedProducts { + items = append(items, DeployedProductSummary{ + ID: d.ID, + Deployment: Ref{ID: d.Deployment.ID, Name: d.Deployment.Name}, + Product: Ref{ID: d.Product.ID, Name: d.Product.Name}, + Version: mapDeployedProductVersion(d.Version), + Cores: d.Cores, + TPS: d.TPS, + Category: d.Category, + CreatedOn: d.CreatedOn, + UpdatedOn: d.UpdatedOn, + }) + } + return SearchDeployedProductsResponse{ + DeployedProducts: items, + Total: r.Total, + Limit: r.Limit, + Offset: r.Offset, + HasMore: r.HasMore, + } +} + +// DeployedProductCreateResponse is the portal's response for POST /deployed-products. +type DeployedProductCreateResponse struct { + ID string `json:"id"` + CreatedOn time.Time `json:"createdOn"` +} + +// MapDeployedProductCreate builds the portal response from entity-service's CreateDeployedProductResponse. +func MapDeployedProductCreate(r entity.CreateDeployedProductResponse) DeployedProductCreateResponse { + return DeployedProductCreateResponse{ + ID: r.DeployedProduct.ID, + CreatedOn: r.DeployedProduct.CreatedOn, + } +} + +// DeployedProductUpdateResponse is the portal's response for PATCH /deployed-products/{id}. +// Deliberately excludes entity-service's UpdatedBy (internal actor identity), +// consistent with the other update responses in this package. +type DeployedProductUpdateResponse struct { + ID string `json:"id"` + UpdatedOn time.Time `json:"updatedOn"` +} + +// MapDeployedProductUpdate builds the portal response from entity-service's UpdateDeployedProductResponse. +func MapDeployedProductUpdate(r entity.UpdateDeployedProductResponse) DeployedProductUpdateResponse { + return DeployedProductUpdateResponse{ + ID: r.DeployedProduct.ID, + UpdatedOn: r.DeployedProduct.UpdatedOn, + } +} diff --git a/apps/customer-portal/backend-v2/internal/dto/product.go b/apps/customer-portal/backend-v2/internal/dto/product.go new file mode 100644 index 0000000000..35a5da1a50 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/dto/product.go @@ -0,0 +1,105 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package dto + +import "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" + +// ProductSummary is one item of the portal's response for POST /products/search. +type ProductSummary struct { + ID string `json:"id"` + Name string `json:"name"` + Class *string `json:"class,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + UpdatedOn *string `json:"updatedOn,omitempty"` +} + +// SearchProductsResponse is the portal's response for POST /products/search. +type SearchProductsResponse struct { + Products []ProductSummary `json:"products"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// MapSearchProducts builds the portal response from entity-service's SearchProductsResponse. +func MapSearchProducts(r entity.SearchProductsResponse) SearchProductsResponse { + items := make([]ProductSummary, 0, len(r.Products)) + for _, p := range r.Products { + items = append(items, ProductSummary{ + ID: p.ID, + Name: p.Name, + Class: p.Class, + CreatedOn: p.CreatedOn, + UpdatedOn: p.UpdatedOn, + }) + } + return SearchProductsResponse{ + Products: items, + Total: r.Total, + Limit: r.Limit, + Offset: r.Offset, + HasMore: r.HasMore, + } +} + +// ProductVersionSummary is one item of the portal's response for +// POST /products/{id}/versions/search. Deliberately excludes entity-service's +// ProductID — already known from the request path, redundant here. +type ProductVersionSummary struct { + ID string `json:"id"` + Version string `json:"version"` + CurrentSupportStatus *string `json:"currentSupportStatus,omitempty"` + ReleaseDate *string `json:"releaseDate,omitempty"` + SupportEOLDate *string `json:"supportEolDate,omitempty"` + EarliestPossibleSupportEOLDate *string `json:"earliestPossibleSupportEolDate,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + UpdatedOn *string `json:"updatedOn,omitempty"` +} + +// SearchProductVersionsResponse is the portal's response for POST /products/{id}/versions/search. +type SearchProductVersionsResponse struct { + ProductVersions []ProductVersionSummary `json:"productVersions"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// MapSearchProductVersions builds the portal response from entity-service's SearchProductVersionsResponse. +func MapSearchProductVersions(r entity.SearchProductVersionsResponse) SearchProductVersionsResponse { + items := make([]ProductVersionSummary, 0, len(r.ProductVersions)) + for _, v := range r.ProductVersions { + items = append(items, ProductVersionSummary{ + ID: v.ID, + Version: v.Version, + CurrentSupportStatus: v.CurrentSupportStatus, + ReleaseDate: v.ReleaseDate, + SupportEOLDate: v.SupportEOLDate, + EarliestPossibleSupportEOLDate: v.EarliestPossibleSupportEOLDate, + CreatedOn: v.CreatedOn, + UpdatedOn: v.UpdatedOn, + }) + } + return SearchProductVersionsResponse{ + ProductVersions: items, + Total: r.Total, + Limit: r.Limit, + Offset: r.Offset, + HasMore: r.HasMore, + } +} diff --git a/apps/customer-portal/backend-v2/internal/entity/attachments.go b/apps/customer-portal/backend-v2/internal/entity/attachments.go new file mode 100644 index 0000000000..67b5bdba24 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/entity/attachments.go @@ -0,0 +1,50 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package entity + +import ( + "context" + "fmt" + "net/url" +) + +// CreateAttachment calls POST /attachments. +func (c *Client) CreateAttachment(ctx context.Context, req CreateAttachmentRequest) (CreateAttachmentResponse, error) { + var out CreateAttachmentResponse + err := c.postJSON(ctx, "/attachments", req, &out) + return out, err +} + +// SearchAttachments calls POST /attachments/search. +func (c *Client) SearchAttachments(ctx context.Context, req SearchAttachmentsRequest) (SearchAttachmentsResponse, error) { + var out SearchAttachmentsResponse + err := c.postJSON(ctx, "/attachments/search", req, &out) + return out, err +} + +// GetAttachmentContent calls GET /attachments/{id}/content and returns the +// raw file bytes together with its Content-Type. +func (c *Client) GetAttachmentContent(ctx context.Context, id string) (body []byte, contentType string, err error) { + return c.doBinary(ctx, fmt.Sprintf("/attachments/%s/content", url.PathEscape(id))) +} + +// DeleteAttachment calls DELETE /attachments/{id}. +func (c *Client) DeleteAttachment(ctx context.Context, id string) (DeleteAttachmentResponse, error) { + var out DeleteAttachmentResponse + err := c.deleteJSON(ctx, fmt.Sprintf("/attachments/%s", url.PathEscape(id)), &out) + return out, err +} diff --git a/apps/customer-portal/backend-v2/internal/entity/cases.go b/apps/customer-portal/backend-v2/internal/entity/cases.go index e085dc6976..5ad3826de6 100644 --- a/apps/customer-portal/backend-v2/internal/entity/cases.go +++ b/apps/customer-portal/backend-v2/internal/entity/cases.go @@ -56,3 +56,11 @@ func (c *Client) CreateCaseComment(ctx context.Context, caseID string, req Creat err := c.postJSON(ctx, fmt.Sprintf("/cases/%s/comments", url.PathEscape(caseID)), req, &out) return out, err } + +// SearchCaseActivities calls POST /cases/{id}/activities/search. +func (c *Client) SearchCaseActivities(ctx context.Context, caseID string, req SearchCaseActivitiesRequest) (SearchCaseActivitiesResponse, error) { + req.CaseID = caseID // never serialized (json:"-"); set for consistency with the struct's doc comment + var out SearchCaseActivitiesResponse + err := c.postJSON(ctx, fmt.Sprintf("/cases/%s/activities/search", url.PathEscape(caseID)), req, &out) + return out, err +} diff --git a/apps/customer-portal/backend-v2/internal/entity/client.go b/apps/customer-portal/backend-v2/internal/entity/client.go index 93b5f78839..1f80951790 100644 --- a/apps/customer-portal/backend-v2/internal/entity/client.go +++ b/apps/customer-portal/backend-v2/internal/entity/client.go @@ -186,6 +186,58 @@ func (c *Client) do(ctx context.Context, method, path string, body []byte) ([]by return respBody, nil } +// maxBinaryResponseBytes bounds attachment downloads specifically — larger +// than maxResponseBodyBytes since attachments (documents, images) are +// legitimately bigger than a typical JSON API response. +const maxBinaryResponseBytes = 25 << 20 // 25 MiB + +// doBinary executes an authenticated GET request against entity-service and +// returns the raw response body together with the upstream Content-Type +// header. Use this instead of do for endpoints that return non-JSON binary +// content (e.g. attachment downloads). +func (c *Client) doBinary(ctx context.Context, path string) (body []byte, contentType string, err error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+path, nil) + if err != nil { + return nil, "", fmt.Errorf("entity: build request GET %s: %w", path, err) + } + if token := userIDTokenFromContext(ctx); token != "" { + req.Header.Set("x-user-id-token", token) + } + if id := correlationIDFromContext(ctx); id != "" { + req.Header.Set("X-CSM-Correlation-ID", id) + } + + resp, err := c.http.Do(req) + if err != nil { + return nil, "", fmt.Errorf("entity: GET %s: %w", path, err) + } + defer resp.Body.Close() + + limited := io.LimitReader(resp.Body, maxBinaryResponseBytes+1) + respBody, err := io.ReadAll(limited) + if err != nil { + return nil, "", fmt.Errorf("entity: read response body: %w", err) + } + if len(respBody) > maxBinaryResponseBytes { + return nil, "", fmt.Errorf("entity: GET %s: response body exceeds %d bytes", path, maxBinaryResponseBytes) + } + + if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { + const maxErrBody = 256 + excerpt := respBody + if len(excerpt) > maxErrBody { + excerpt = excerpt[:maxErrBody] + } + return nil, "", &apierror.Error{StatusCode: resp.StatusCode, Body: string(excerpt)} + } + + ct := resp.Header.Get("Content-Type") + if ct == "" { + ct = "application/octet-stream" + } + return respBody, ct, nil +} + // getJSON issues a GET request and decodes the JSON response into out. func (c *Client) getJSON(ctx context.Context, path string, out any) error { body, err := c.do(ctx, http.MethodGet, path, nil) @@ -231,3 +283,15 @@ func (c *Client) patchJSON(ctx context.Context, path string, reqBody, out any) e } return nil } + +// deleteJSON issues a DELETE request and decodes the JSON response into out. +func (c *Client) deleteJSON(ctx context.Context, path string, out any) error { + body, err := c.do(ctx, http.MethodDelete, path, nil) + if err != nil { + return err + } + if err := json.Unmarshal(body, out); err != nil { + return fmt.Errorf("entity: decode response for DELETE %s: %w", path, err) + } + return nil +} diff --git a/apps/customer-portal/backend-v2/internal/entity/deployed_products.go b/apps/customer-portal/backend-v2/internal/entity/deployed_products.go new file mode 100644 index 0000000000..6e815afe1e --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/entity/deployed_products.go @@ -0,0 +1,51 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package entity + +import ( + "context" + "fmt" + "net/url" +) + +// SearchDeployedProducts calls POST /deployed-products/search. +func (c *Client) SearchDeployedProducts(ctx context.Context, req SearchDeployedProductsRequest) (SearchDeployedProductsResponse, error) { + var out SearchDeployedProductsResponse + err := c.postJSON(ctx, "/deployed-products/search", req, &out) + return out, err +} + +// CreateDeployedProduct calls POST /deployed-products. +// +// NOTE: only entity-service's ServiceNow data source supports this route — +// see CreateDeployedProductRequest's doc comment. +func (c *Client) CreateDeployedProduct(ctx context.Context, req CreateDeployedProductRequest) (CreateDeployedProductResponse, error) { + var out CreateDeployedProductResponse + err := c.postJSON(ctx, "/deployed-products", req, &out) + return out, err +} + +// UpdateDeployedProduct calls PATCH /deployed-products/{id}. +// +// NOTE: only entity-service's ServiceNow data source supports this route — +// see CreateDeployedProductRequest's doc comment. +func (c *Client) UpdateDeployedProduct(ctx context.Context, id string, req UpdateDeployedProductRequest) (UpdateDeployedProductResponse, error) { + req.ID = id // never serialized (json:"-"); set for consistency with the struct's doc comment + var out UpdateDeployedProductResponse + err := c.patchJSON(ctx, fmt.Sprintf("/deployed-products/%s", url.PathEscape(id)), req, &out) + return out, err +} diff --git a/apps/customer-portal/backend-v2/internal/entity/products.go b/apps/customer-portal/backend-v2/internal/entity/products.go new file mode 100644 index 0000000000..4c85804341 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/entity/products.go @@ -0,0 +1,38 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package entity + +import ( + "context" + "fmt" + "net/url" +) + +// SearchProducts calls POST /products/search. +func (c *Client) SearchProducts(ctx context.Context, req SearchProductsRequest) (SearchProductsResponse, error) { + var out SearchProductsResponse + err := c.postJSON(ctx, "/products/search", req, &out) + return out, err +} + +// SearchProductVersions calls POST /products/{id}/versions/search. +func (c *Client) SearchProductVersions(ctx context.Context, productID string, req SearchProductVersionsRequest) (SearchProductVersionsResponse, error) { + req.ProductID = productID // never serialized (json:"-"); set for consistency with the struct's doc comment + var out SearchProductVersionsResponse + err := c.postJSON(ctx, fmt.Sprintf("/products/%s/versions/search", url.PathEscape(productID)), req, &out) + return out, err +} diff --git a/apps/customer-portal/backend-v2/internal/entity/types.go b/apps/customer-portal/backend-v2/internal/entity/types.go index e6e7d88e20..9e83127a55 100644 --- a/apps/customer-portal/backend-v2/internal/entity/types.go +++ b/apps/customer-portal/backend-v2/internal/entity/types.go @@ -613,3 +613,299 @@ type CreateDeploymentResponse struct { Message string `json:"message"` Deployment CreatedDeployment `json:"deployment"` } + +// --- deployed products --- + +// CreateDeployedProductRequest is the input for POST /deployed-products. +// +// NOTE: entity-service only supports deployed-product creation on its +// ServiceNow data source — a Postgres-mode deployment always returns 400 +// for this route (see cs-tools/entity-service/internal/service/deployed_product_service.go). +type CreateDeployedProductRequest struct { + ProjectID string `json:"projectId"` + DeploymentID string `json:"deploymentId"` + ProductID string `json:"productId"` + VersionID string `json:"versionId"` + Cores *int `json:"cores,omitempty"` + TPS *float64 `json:"tps,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CreatedDeployedProduct carries the key fields of a newly created deployed product. +type CreatedDeployedProduct struct { + ID string `json:"id"` + CreatedOn time.Time `json:"createdOn"` + CreatedBy string `json:"createdBy"` +} + +// CreateDeployedProductResponse is entity-service's response for POST /deployed-products. +type CreateDeployedProductResponse struct { + Message string `json:"message"` + DeployedProduct CreatedDeployedProduct `json:"deployedProduct"` +} + +// SearchDeployedProductsRequest is the input for POST /deployed-products/search. +type SearchDeployedProductsRequest struct { + Pagination Pagination `json:"pagination"` + DeploymentIDs []string `json:"deploymentIds,omitempty"` +} + +// DeployedProductVersionRef is the version sub-object in a DeployedProductView. +type DeployedProductVersionRef struct { + ID string `json:"id"` + Name string `json:"name"` + ReleasedDate *time.Time `json:"releasedDate"` + SupportEoLDate *time.Time `json:"supportEoLDate"` +} + +// DeployedProductView is a single search result item from POST /deployed-products/search. +// Cores, TPS, and Category are ServiceNow-only fields, always nil on the +// Postgres data source. +type DeployedProductView struct { + ID string `json:"id"` + Deployment EntityRef `json:"deployment"` + Product EntityRef `json:"product"` + Version *DeployedProductVersionRef `json:"version"` + Cores *string `json:"cores"` + TPS *string `json:"tps"` + Category *string `json:"category"` + CreatedOn time.Time `json:"createdOn"` + UpdatedOn time.Time `json:"updatedOn"` +} + +// SearchDeployedProductsResponse is entity-service's response for POST /deployed-products/search. +type SearchDeployedProductsResponse struct { + DeployedProducts []DeployedProductView `json:"deployedProducts"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// UpdateDeployedProductRequest is the input for PATCH /deployed-products/{id}. +// Either detail fields (Cores, TPS, Description) or Active=false must be +// provided, but not both. Description uses json.RawMessage to preserve three +// states: absent = omit, "null" = clear, `"value"` = set — decoding a client's +// request body directly into this field naturally preserves that semantic. +// +// NOTE: entity-service only supports this route on its ServiceNow data +// source — see CreateDeployedProductRequest's doc comment. +type UpdateDeployedProductRequest struct { + ID string `json:"-"` + DeploymentID *string `json:"deploymentId,omitempty"` + Cores *int `json:"cores,omitempty"` + TPS *float64 `json:"tps,omitempty"` + Description json.RawMessage `json:"description,omitempty"` + Active *bool `json:"active,omitempty"` +} + +// UpdatedDeployedProduct carries the fields that may change after an update. +type UpdatedDeployedProduct struct { + ID string `json:"id"` + UpdatedOn time.Time `json:"updatedOn"` + UpdatedBy string `json:"updatedBy"` +} + +// UpdateDeployedProductResponse is entity-service's response for PATCH /deployed-products/{id}. +type UpdateDeployedProductResponse struct { + Message string `json:"message"` + DeployedProduct UpdatedDeployedProduct `json:"deployedProduct"` +} + +// --- attachments --- + +// ReferenceType identifies which kind of entity an attachment or comment is +// attached to. +type ReferenceType string + +const ( + ReferenceTypeCase ReferenceType = "case" + ReferenceTypeConversation ReferenceType = "conversation" + ReferenceTypeChangeRequest ReferenceType = "change_request" + ReferenceTypeDeployment ReferenceType = "deployment" + ReferenceTypeIncident ReferenceType = "incident" +) + +// CreateAttachmentRequest is the input for POST /attachments. +type CreateAttachmentRequest struct { + ReferenceID string `json:"referenceId"` + ReferenceType ReferenceType `json:"referenceType"` + Name string `json:"name"` + Type string `json:"type"` + File string `json:"file"` + Description *string `json:"description,omitempty"` +} + +// AttachmentDetail holds the core fields returned after creating an attachment. +type AttachmentDetail struct { + ID string `json:"id"` + SizeBytes int `json:"sizeBytes"` + CreatedOn time.Time `json:"createdOn"` + CreatedBy string `json:"createdBy"` + DownloadURL string `json:"downloadUrl"` +} + +// CreateAttachmentResponse is entity-service's response for POST /attachments. +type CreateAttachmentResponse struct { + Message string `json:"message"` + Attachment AttachmentDetail `json:"attachment"` +} + +// SearchAttachmentsRequest is the input for POST /attachments/search. +type SearchAttachmentsRequest struct { + ReferenceID string `json:"referenceId"` + ReferenceType ReferenceType `json:"referenceType"` + Pagination Pagination `json:"pagination"` +} + +// Attachment is a single search result item from POST /attachments/search. +type Attachment struct { + ID string `json:"id"` + ReferenceID string `json:"referenceId"` + ReferenceType ReferenceType `json:"referenceType"` + Name string `json:"name"` + Type string `json:"type"` + SizeBytes int `json:"sizeBytes"` + Description *string `json:"description"` + CreatedBy string `json:"createdBy"` + CreatedOn time.Time `json:"createdOn"` + DownloadURL *string `json:"downloadUrl"` + PreviewURL *string `json:"previewUrl"` +} + +// SearchAttachmentsResponse is entity-service's response for POST /attachments/search. +type SearchAttachmentsResponse struct { + Attachments []Attachment `json:"attachments"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// DeleteAttachmentResponse is entity-service's response for DELETE /attachments/{id}. +type DeleteAttachmentResponse struct { + Message string `json:"message"` +} + +// --- case activities --- + +// ActivityType discriminates the kind of entry in a case's activity feed. +type ActivityType string + +const ( + ActivityTypeComment ActivityType = "comment" + ActivityTypeAttachment ActivityType = "attachment" + ActivityTypeFieldChange ActivityType = "field_change" +) + +// FieldChange describes a single field's value change, present only on +// CaseActivity entries with Type == ActivityTypeFieldChange. +type FieldChange struct { + Field string `json:"field"` + FieldLabel string `json:"fieldLabel"` + PreviousValue string `json:"previousValue"` + NewValue string `json:"newValue"` +} + +// CaseActivity is a single entry in a case's activity feed — a discriminated +// union on Type. The shared fields are always present; type-specific fields +// are populated only for the matching Type (CommentType for comments; +// FileName/ContentType/SizeBytes/DownloadURL for attachments; Changes for +// field changes). Field types/omitempty here mirror entity-service's struct +// exactly (see its doc comment) — do not change to pointers. +type CaseActivity struct { + ID string `json:"id"` + Type ActivityType `json:"type"` + Content string `json:"content"` + CreatedOn time.Time `json:"createdOn"` + CreatedBy string `json:"createdBy"` + CreatedByFirstName string `json:"createdByFirstName"` + CreatedByLastName string `json:"createdByLastName"` + CreatedByFullName string `json:"createdByFullName"` + CommentType *CommentType `json:"commentType,omitempty"` + FileName string `json:"fileName,omitempty"` + ContentType string `json:"contentType,omitempty"` + SizeBytes int `json:"sizeBytes,omitempty"` + DownloadURL string `json:"downloadUrl,omitempty"` + Changes []FieldChange `json:"changes,omitempty"` +} + +// SearchCaseActivitiesRequest is the input for POST /cases/{id}/activities/search. +// CaseID is populated from the URL path parameter and is not part of the JSON body. +type SearchCaseActivitiesRequest struct { + CaseID string `json:"-"` + Pagination Pagination `json:"pagination"` + IncludeFieldChanges *bool `json:"includeFieldChanges,omitempty"` +} + +// SearchCaseActivitiesResponse is entity-service's response for POST /cases/{id}/activities/search. +type SearchCaseActivitiesResponse struct { + Activity []CaseActivity `json:"activity"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// --- products --- +// +// Like accounts, entity-service returns a different wire shape for these +// routes depending on its DATA_SOURCE. The structs below are a superset of +// both shapes for the same reasons documented on AccountSummary/AccountDetail +// above: no colliding JSON keys, and every ambiguous-typed field (class, +// dates) is typed as *string so either shape decodes cleanly. + +// ProductView is a single search result item from POST /products/search. +type ProductView struct { + ID string `json:"id"` + Name string `json:"name"` + Class *string `json:"class,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + UpdatedOn *string `json:"updatedOn,omitempty"` +} + +// SearchProductsRequest is the input for POST /products/search. +type SearchProductsRequest struct { + Pagination Pagination `json:"pagination"` + SearchQuery string `json:"searchQuery,omitempty"` +} + +// SearchProductsResponse is entity-service's response for POST /products/search. +type SearchProductsResponse struct { + Products []ProductView `json:"products"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} + +// SearchProductVersionsRequest is the input for POST /products/{id}/versions/search. +// ProductID is populated from the URL path parameter and is not part of the JSON body. +type SearchProductVersionsRequest struct { + Pagination Pagination `json:"pagination"` + ProductID string `json:"-"` + SearchQuery string `json:"searchQuery,omitempty"` +} + +// ProductVersionView is a single search result item from +// POST /products/{id}/versions/search. +type ProductVersionView struct { + ID string `json:"id"` + ProductID string `json:"productId"` + Version string `json:"version"` + CurrentSupportStatus *string `json:"currentSupportStatus,omitempty"` + ReleaseDate *string `json:"releaseDate,omitempty"` + SupportEOLDate *string `json:"supportEolDate,omitempty"` + EarliestPossibleSupportEOLDate *string `json:"earliestPossibleSupportEolDate,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + UpdatedOn *string `json:"updatedOn,omitempty"` +} + +// SearchProductVersionsResponse is entity-service's response for POST /products/{id}/versions/search. +type SearchProductVersionsResponse struct { + ProductVersions []ProductVersionView `json:"productVersions"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` + HasMore bool `json:"hasMore"` +} diff --git a/apps/customer-portal/backend-v2/internal/handler/attachments.go b/apps/customer-portal/backend-v2/internal/handler/attachments.go new file mode 100644 index 0000000000..6713e19e83 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/handler/attachments.go @@ -0,0 +1,159 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package handler + +import ( + "context" + "encoding/json" + "log/slog" + "net/http" + + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/dto" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/middleware" +) + +// entityAttachmentClient abstracts the entity-service attachment operations +// used by AttachmentHandler. +type entityAttachmentClient interface { + CreateAttachment(ctx context.Context, req entity.CreateAttachmentRequest) (entity.CreateAttachmentResponse, error) + SearchAttachments(ctx context.Context, req entity.SearchAttachmentsRequest) (entity.SearchAttachmentsResponse, error) + GetAttachmentContent(ctx context.Context, id string) (body []byte, contentType string, err error) + DeleteAttachment(ctx context.Context, id string) (entity.DeleteAttachmentResponse, error) +} + +// AttachmentHandler handles HTTP requests for attachment operations. +type AttachmentHandler struct { + entity entityAttachmentClient +} + +// NewAttachmentHandler creates an AttachmentHandler backed by the given entity client. +func NewAttachmentHandler(entity entityAttachmentClient) *AttachmentHandler { + return &AttachmentHandler{entity: entity} +} + +// CreateAttachment handles POST /attachments. +func (h *AttachmentHandler) CreateAttachment(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.CreateAttachmentRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.CreateAttachment(r.Context(), req) + if err != nil { + slog.ErrorContext(r.Context(), "entity CreateAttachment failed", "userID", user.UserID, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to create attachment.") + return + } + + writeJSONValue(w, http.StatusCreated, dto.MapAttachmentCreate(result)) +} + +// SearchAttachments handles POST /attachments/search. +func (h *AttachmentHandler) SearchAttachments(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.SearchAttachmentsRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.SearchAttachments(r.Context(), req) + if err != nil { + slog.ErrorContext(r.Context(), "entity SearchAttachments failed", "userID", user.UserID, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to search attachments.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapSearchAttachments(result)) +} + +// GetAttachmentContent handles GET /attachments/{id}/content. The response is +// the raw file content, not JSON. Content-Disposition: attachment is always +// set (mirroring entity-service's own XSS mitigation for this endpoint) so +// browsers never render an attachment inline. +func (h *AttachmentHandler) GetAttachmentContent(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + id := r.PathValue("id") + if id == "" || !uuidRe.MatchString(id) { + writeError(w, http.StatusBadRequest, ErrMsgInvalidUUID) + return + } + + content, contentType, err := h.entity.GetAttachmentContent(r.Context(), id) + if err != nil { + slog.ErrorContext(r.Context(), "entity GetAttachmentContent failed", "userID", user.UserID, "attachmentID", id, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to download attachment.") + return + } + + w.Header().Set("Content-Type", contentType) + w.Header().Set("Content-Disposition", "attachment") + w.WriteHeader(http.StatusOK) + _, _ = w.Write(content) // #nosec G705 -- Content-Type set from entity-service's own sanitized value; Content-Disposition forces download, never inline rendering +} + +// DeleteAttachment handles DELETE /attachments/{id}. +func (h *AttachmentHandler) DeleteAttachment(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + id := r.PathValue("id") + if id == "" || !uuidRe.MatchString(id) { + writeError(w, http.StatusBadRequest, ErrMsgInvalidUUID) + return + } + + result, err := h.entity.DeleteAttachment(r.Context(), id) + if err != nil { + slog.ErrorContext(r.Context(), "entity DeleteAttachment failed", "userID", user.UserID, "attachmentID", id, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to delete attachment.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapDeleteAttachment(result)) +} diff --git a/apps/customer-portal/backend-v2/internal/handler/cases.go b/apps/customer-portal/backend-v2/internal/handler/cases.go index 4b1afae630..502d2a6499 100644 --- a/apps/customer-portal/backend-v2/internal/handler/cases.go +++ b/apps/customer-portal/backend-v2/internal/handler/cases.go @@ -34,6 +34,7 @@ type entityCaseClient interface { CreateCase(ctx context.Context, req entity.CreateCaseRequest) (entity.CreateCaseResponse, error) UpdateCase(ctx context.Context, id string, req entity.UpdateCaseRequest) (entity.UpdateCaseResponse, error) CreateCaseComment(ctx context.Context, caseID string, req entity.CreateCaseCommentRequest) (entity.CreateCaseCommentResponse, error) + SearchCaseActivities(ctx context.Context, caseID string, req entity.SearchCaseActivitiesRequest) (entity.SearchCaseActivitiesResponse, error) } // CaseHandler handles HTTP requests for case operations. @@ -217,3 +218,38 @@ func (h *CaseHandler) CreateCaseComment(w http.ResponseWriter, r *http.Request) writeJSONValue(w, http.StatusCreated, dto.MapCaseComment(result)) } + +// SearchCaseActivities handles POST /cases/{id}/activities/search. +func (h *CaseHandler) SearchCaseActivities(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + id := r.PathValue("id") + if id == "" || !uuidRe.MatchString(id) { + writeError(w, http.StatusBadRequest, ErrMsgInvalidUUID) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.SearchCaseActivitiesRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.SearchCaseActivities(r.Context(), id, req) + if err != nil { + slog.ErrorContext(r.Context(), "entity SearchCaseActivities failed", "userID", user.UserID, "caseID", id, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to search case activities.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapSearchCaseActivities(result)) +} diff --git a/apps/customer-portal/backend-v2/internal/handler/deployed_products.go b/apps/customer-portal/backend-v2/internal/handler/deployed_products.go new file mode 100644 index 0000000000..7670cacc77 --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/handler/deployed_products.go @@ -0,0 +1,161 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package handler + +import ( + "context" + "encoding/json" + "log/slog" + "net/http" + + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/dto" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/middleware" +) + +// entityDeployedProductClient abstracts the entity-service deployed-product +// operations used by DeployedProductHandler. +type entityDeployedProductClient interface { + SearchDeployedProducts(ctx context.Context, req entity.SearchDeployedProductsRequest) (entity.SearchDeployedProductsResponse, error) + CreateDeployedProduct(ctx context.Context, req entity.CreateDeployedProductRequest) (entity.CreateDeployedProductResponse, error) + UpdateDeployedProduct(ctx context.Context, id string, req entity.UpdateDeployedProductRequest) (entity.UpdateDeployedProductResponse, error) +} + +// DeployedProductHandler handles HTTP requests for deployed-product operations. +type DeployedProductHandler struct { + entity entityDeployedProductClient +} + +// NewDeployedProductHandler creates a DeployedProductHandler backed by the given entity client. +func NewDeployedProductHandler(entity entityDeployedProductClient) *DeployedProductHandler { + return &DeployedProductHandler{entity: entity} +} + +// SearchDeployedProducts handles POST /deployed-products/search. +func (h *DeployedProductHandler) SearchDeployedProducts(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.SearchDeployedProductsRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.SearchDeployedProducts(r.Context(), req) + if err != nil { + slog.ErrorContext(r.Context(), "entity SearchDeployedProducts failed", "userID", user.UserID, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to search deployed products.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapSearchDeployedProducts(result)) +} + +// CreateDeployedProduct handles POST /deployed-products. +// +// NOTE: entity-service only supports this route on its ServiceNow data +// source — see internal/entity/deployed_products.go. +func (h *DeployedProductHandler) CreateDeployedProduct(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.CreateDeployedProductRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.CreateDeployedProduct(r.Context(), req) + if err != nil { + slog.ErrorContext(r.Context(), "entity CreateDeployedProduct failed", "userID", user.UserID, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to create deployed product.") + return + } + + writeJSONValue(w, http.StatusCreated, dto.MapDeployedProductCreate(result)) +} + +// PatchDeployedProduct handles PATCH /deployed-products/{id}. +// +// NOTE: entity-service only supports this route on its ServiceNow data +// source — see internal/entity/deployed_products.go. +func (h *DeployedProductHandler) PatchDeployedProduct(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + id := r.PathValue("id") + if id == "" || !uuidRe.MatchString(id) { + writeError(w, http.StatusBadRequest, ErrMsgInvalidUUID) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + // Decoded directly into entity-service's request struct (no restricted + // portal DTO) — every field here is customer-appropriate, including + // DeploymentID: per entity-service's own doc comment on + // UpdateDeployedProductRequest, it isn't a mutation field but an + // IDOR-style scope guard ("the deployed product must belong to that + // deployment or the operation returns a NotFoundError") — a legitimate + // safety check for the frontend to supply, unlike the case-update + // endpoint's genuinely internal-only fields (see dto.UpdateCaseRequest). + var req entity.UpdateDeployedProductRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + // entity-service requires exactly one of the detail-fields group + // (cores/tps/description) or active=false — never both, never neither. + detailFieldsSet := req.Cores != nil || req.TPS != nil || len(req.Description) > 0 + activeSet := req.Active != nil + if detailFieldsSet == activeSet { + writeError(w, http.StatusBadRequest, "Provide either cores/tps/description or active, but not both.") + return + } + + result, err := h.entity.UpdateDeployedProduct(r.Context(), id, req) + if err != nil { + slog.ErrorContext(r.Context(), "entity UpdateDeployedProduct failed", "userID", user.UserID, "deployedProductID", id, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to update deployed product.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapDeployedProductUpdate(result)) +} diff --git a/apps/customer-portal/backend-v2/internal/handler/products.go b/apps/customer-portal/backend-v2/internal/handler/products.go new file mode 100644 index 0000000000..759aaa448e --- /dev/null +++ b/apps/customer-portal/backend-v2/internal/handler/products.go @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package handler + +import ( + "context" + "encoding/json" + "log/slog" + "net/http" + + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/dto" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/entity" + "github.com/wso2-open-operations/cs-tools/apps/customer-portal/backend-v2/internal/middleware" +) + +// entityProductClient abstracts the entity-service product operations used by ProductHandler. +type entityProductClient interface { + SearchProducts(ctx context.Context, req entity.SearchProductsRequest) (entity.SearchProductsResponse, error) + SearchProductVersions(ctx context.Context, productID string, req entity.SearchProductVersionsRequest) (entity.SearchProductVersionsResponse, error) +} + +// ProductHandler handles HTTP requests for product operations. +type ProductHandler struct { + entity entityProductClient +} + +// NewProductHandler creates a ProductHandler backed by the given entity client. +func NewProductHandler(entity entityProductClient) *ProductHandler { + return &ProductHandler{entity: entity} +} + +// SearchProducts handles POST /products/search. +func (h *ProductHandler) SearchProducts(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.SearchProductsRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.SearchProducts(r.Context(), req) + if err != nil { + slog.ErrorContext(r.Context(), "entity SearchProducts failed", "userID", user.UserID, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to search products.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapSearchProducts(result)) +} + +// SearchProductVersions handles POST /products/{id}/versions/search. +func (h *ProductHandler) SearchProductVersions(w http.ResponseWriter, r *http.Request) { + user := middleware.UserInfoFromContext(r.Context()) + if user == nil { + writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) + return + } + + id := r.PathValue("id") + if id == "" || !uuidRe.MatchString(id) { + writeError(w, http.StatusBadRequest, ErrMsgInvalidUUID) + return + } + + body, ok := readJSONBody(w, r) + if !ok { + return + } + + var req entity.SearchProductVersionsRequest + if err := json.Unmarshal(body, &req); err != nil { + writeError(w, http.StatusBadRequest, ErrMsgBadRequest) + return + } + + result, err := h.entity.SearchProductVersions(r.Context(), id, req) + if err != nil { + slog.ErrorContext(r.Context(), "entity SearchProductVersions failed", "userID", user.UserID, "productID", id, "err", summarizeErr(err)) + mapUpstreamError(w, err, "Failed to search product versions.") + return + } + + writeJSONValue(w, http.StatusOK, dto.MapSearchProductVersions(result)) +} diff --git a/apps/customer-portal/backend-v2/openapi.yaml b/apps/customer-portal/backend-v2/openapi.yaml index 06f23bded5..e95b9113c8 100644 --- a/apps/customer-portal/backend-v2/openapi.yaml +++ b/apps/customer-portal/backend-v2/openapi.yaml @@ -693,19 +693,23 @@ paths: schema: $ref: '#/components/schemas/ErrorPayload' - /updates/product-update-levels: - get: - summary: Get product update levels. - operationId: getUpdatesProductUpdateLevels + /deployed-products/search: + post: + summary: Search deployed products. + operationId: postDeployedProductsSearch + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SearchDeployedProductsRequest' + required: true responses: "200": description: Ok content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/ProductUpdateLevel' + $ref: '#/components/schemas/SearchDeployedProductsResponse' "400": description: BadRequest content: @@ -724,6 +728,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' "500": description: InternalServerError content: @@ -731,15 +741,77 @@ paths: schema: $ref: '#/components/schemas/ErrorPayload' - /updates/levels/search: + /deployed-products: post: - summary: Search update descriptions between two update levels. - operationId: postUpdatesLevelsSearch + summary: Create a deployed product. + description: > + Only entity-service's ServiceNow data source supports this route — + a Postgres-mode deployment always returns 400. + operationId: postDeployedProducts requestBody: content: application/json: schema: - $ref: '#/components/schemas/UpdatesSearchPayload' + $ref: '#/components/schemas/CreateDeployedProductRequest' + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/DeployedProductCreateResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /deployed-products/{id}: + patch: + summary: Update a deployed product. + description: > + Provide either cores/tps/description or active=false, but not both. + Only entity-service's ServiceNow data source supports this route — + a Postgres-mode deployment always returns 400. + operationId: patchDeployedProductsId + parameters: + - name: id + in: path + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateDeployedProductRequest' required: true responses: "200": @@ -747,9 +819,7 @@ paths: content: application/json: schema: - type: object - additionalProperties: - $ref: '#/components/schemas/UpdateLevelGroup' + $ref: '#/components/schemas/DeployedProductUpdateResponse' "400": description: BadRequest content: @@ -768,6 +838,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorPayload' + "404": + description: NotFound + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' "413": description: RequestEntityTooLarge content: @@ -781,230 +857,1134 @@ paths: schema: $ref: '#/components/schemas/ErrorPayload' -components: - securitySchemes: - bearerAuth: - type: apiKey - in: header - name: x-jwt-assertion - - schemas: - ErrorPayload: - type: object - properties: - message: - type: string - - Pagination: - type: object - properties: - limit: - type: integer - minimum: 1 - offset: - type: integer - minimum: 0 - - Ref: - type: object - properties: - id: - type: string - name: - type: string - - NumberRef: - type: object - properties: - id: - type: string - number: - type: string - - PersonRef: - type: object - properties: - name: - type: string - email: - type: string + /attachments: + post: + summary: Create an attachment. + operationId: postAttachments + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateAttachmentRequest' + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/AttachmentCreateResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' - # ---- users ---- + /attachments/search: + post: + summary: Search attachments. + operationId: postAttachmentsSearch + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SearchAttachmentsRequest' + required: true + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/SearchAttachmentsResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' - UserMeResponse: - type: object - properties: - id: - type: string - email: - type: string - firstName: - type: string - lastName: - type: string - timeZone: - type: string - roles: - type: array - items: + /attachments/{id}/content: + get: + summary: Download an attachment's raw file content. + description: > + Response body is the raw file, not JSON. Content-Disposition: + attachment is always set, forcing a download rather than inline + rendering, mirroring entity-service's own XSS mitigation for this + endpoint. + operationId: getAttachmentsIdContent + parameters: + - name: id + in: path + required: true + schema: type: string - phoneNumber: - type: string - - UserUpdateRequest: - type: object - properties: - phoneNumber: - type: string - timeZone: - type: string - - UserUpdateResponse: - type: object + format: uuid + responses: + "200": + description: Ok + content: + application/octet-stream: + schema: + type: string + format: binary + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "404": + description: NotFound + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /attachments/{id}: + delete: + summary: Delete an attachment. + operationId: deleteAttachmentsId + parameters: + - name: id + in: path + required: true + schema: + type: string + format: uuid + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "404": + description: NotFound + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /cases/{id}/activities/search: + post: + summary: Search a case's activity feed (comments, attachments, field changes). + operationId: postCasesIdActivitiesSearch + parameters: + - name: id + in: path + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SearchCaseActivitiesRequest' + required: true + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/SearchCaseActivitiesResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "404": + description: NotFound + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /products/search: + post: + summary: Search products. + operationId: postProductsSearch + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SearchProductsRequest' + required: true + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/SearchProductsResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /products/{id}/versions/search: + post: + summary: Search a product's versions. + operationId: postProductsIdVersionsSearch + parameters: + - name: id + in: path + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SearchProductVersionsRequest' + required: true + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/SearchProductVersionsResponse' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "404": + description: NotFound + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /updates/product-update-levels: + get: + summary: Get product update levels. + operationId: getUpdatesProductUpdateLevels + responses: + "200": + description: Ok + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProductUpdateLevel' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + + /updates/levels/search: + post: + summary: Search update descriptions between two update levels. + operationId: postUpdatesLevelsSearch + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdatesSearchPayload' + required: true + responses: + "200": + description: Ok + content: + application/json: + schema: + type: object + additionalProperties: + $ref: '#/components/schemas/UpdateLevelGroup' + "400": + description: BadRequest + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "413": + description: RequestEntityTooLarge + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + "500": + description: InternalServerError + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorPayload' + +components: + securitySchemes: + bearerAuth: + type: apiKey + in: header + name: x-jwt-assertion + + schemas: + ErrorPayload: + type: object + properties: + message: + type: string + + Pagination: + type: object + properties: + limit: + type: integer + minimum: 1 + offset: + type: integer + minimum: 0 + + Ref: + type: object + properties: + id: + type: string + name: + type: string + + NumberRef: + type: object + properties: + id: + type: string + number: + type: string + + PersonRef: + type: object + properties: + name: + type: string + email: + type: string + + # ---- users ---- + + UserMeResponse: + type: object + properties: + id: + type: string + email: + type: string + firstName: + type: string + lastName: + type: string + timeZone: + type: string + roles: + type: array + items: + type: string + phoneNumber: + type: string + + UserUpdateRequest: + type: object + properties: + phoneNumber: + type: string + timeZone: + type: string + + UserUpdateResponse: + type: object + properties: + phoneNumber: + type: string + timeZone: + type: string + + # ---- accounts ---- + + SearchAccountsRequest: + type: object + properties: + pagination: + $ref: '#/components/schemas/Pagination' + filters: + type: object + properties: + searchQuery: + type: string + active: + type: boolean + pod: + type: string + classification: + type: string + + AccountSummary: + type: object + properties: + id: + type: string + name: + type: string + tier: + type: string + region: + type: string + supportTier: + type: string + owner: + $ref: '#/components/schemas/Ref' + technicalOwner: + $ref: '#/components/schemas/Ref' + activationDate: + type: string + deactivationDate: + type: string + hasAgent: + type: boolean + hasKbReferences: + type: boolean + createdOn: + type: string + + SearchAccountsResponse: + type: object + properties: + accounts: + type: array + items: + $ref: '#/components/schemas/AccountSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean + + AccountDetails: + type: object + properties: + id: + type: string + name: + type: string + tier: + type: string + region: + type: string + supportTier: + type: string + owner: + $ref: '#/components/schemas/Ref' + technicalOwner: + $ref: '#/components/schemas/Ref' + activationDate: + type: string + deactivationDate: + type: string + hasAgent: + type: boolean + hasKbReferences: + type: boolean + createdOn: + type: string + updatedOn: + type: string + + # ---- projects ---- + + SearchProjectsRequest: + type: object + properties: + pagination: + $ref: '#/components/schemas/Pagination' + searchQuery: + type: string + closureStatus: + type: string + endDateFrom: + type: string + endDateTo: + type: string + sortBy: + type: string + sortOrder: + type: string + + ProjectSummary: + type: object + properties: + id: + type: string + name: + type: string + key: + type: string + subscriptionType: + type: string + endDate: + type: string + createdOn: + type: string + closureState: + type: string + + SearchProjectsResponse: + type: object + properties: + projects: + type: array + items: + $ref: '#/components/schemas/ProjectSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean + + ProjectAccount: + type: object + properties: + id: + type: string + name: + type: string + tier: + type: string + region: + type: string + + ProjectDetails: + type: object + properties: + id: + type: string + account: + $ref: '#/components/schemas/ProjectAccount' + name: + type: string + key: + type: string + subscriptionType: + type: string + startDate: + type: string + endDate: + type: string + createdOn: + type: string + updatedOn: + type: string + closureState: + type: string + + # ---- cases ---- + + SearchCasesRequest: + type: object + properties: + pagination: + $ref: '#/components/schemas/Pagination' + sortBy: + type: object + properties: + field: + type: string + order: + type: string + filters: + type: object + properties: + types: + type: array + items: + type: string + searchQuery: + type: string + projectIds: + type: array + items: + type: string + deploymentIds: + type: array + items: + type: string + states: + type: array + items: + type: string + severities: + type: array + items: + type: string + issueTypes: + type: array + items: + type: string + engagementTypes: + type: array + items: + type: string + createdBy: + type: array + items: + type: string + createdByMe: + type: boolean + workStates: + type: array + items: + type: string + assignedUserIds: + type: array + items: + type: string + productNames: + type: array + items: + type: string + tags: + type: array + items: + type: string + parentId: + type: string + + CaseSummary: + type: object + properties: + id: + type: string + number: + type: string + subject: + type: string + description: + type: string + state: + type: string + severity: + type: string + issueType: + type: string + engagementType: + type: string + workState: + type: string + type: + type: string + createdOn: + type: string + project: + $ref: '#/components/schemas/Ref' + deployment: + $ref: '#/components/schemas/Ref' + product: + $ref: '#/components/schemas/Ref' + assignedTeam: + $ref: '#/components/schemas/Ref' + + SearchCasesResponse: + type: object properties: - phoneNumber: + cases: + type: array + items: + $ref: '#/components/schemas/CaseSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + + CaseTag: + type: object + properties: + label: type: string - timeZone: + color: type: string - # ---- accounts ---- - - SearchAccountsRequest: + LinkedServiceRequest: type: object properties: - pagination: - $ref: '#/components/schemas/Pagination' - filters: - type: object - properties: - searchQuery: - type: string - active: - type: boolean - pod: - type: string - classification: - type: string + id: + type: string + number: + type: string + name: + type: string - AccountSummary: + CaseDetails: type: object properties: id: type: string - name: + number: type: string - tier: + subject: type: string - region: + description: type: string - supportTier: + severity: type: string - owner: + issueType: + type: string + state: + type: string + workState: + type: string + type: + type: string + engagementType: + type: string + createdOn: + type: string + updatedOn: + type: string + closedOn: + type: string + createdBy: + $ref: '#/components/schemas/PersonRef' + project: $ref: '#/components/schemas/Ref' - technicalOwner: + deployment: $ref: '#/components/schemas/Ref' - activationDate: + deployedProduct: + $ref: '#/components/schemas/Ref' + product: + $ref: '#/components/schemas/Ref' + assignedTeam: + $ref: '#/components/schemas/Ref' + conversation: + $ref: '#/components/schemas/Ref' + assignedEngineer: + $ref: '#/components/schemas/PersonRef' + parentCase: + $ref: '#/components/schemas/NumberRef' + relatedCase: + $ref: '#/components/schemas/NumberRef' + linkedServiceRequests: + type: array + items: + $ref: '#/components/schemas/LinkedServiceRequest' + resolvedOn: type: string - deactivationDate: + resolutionCode: + type: string + cause: + type: string + resolutionNotes: + type: string + fixEta: + type: string + tags: + type: array + items: + $ref: '#/components/schemas/CaseTag' + + CaseCreateRequest: + type: object + required: [type, projectId, deploymentId, subject, description, severity, issueType] + properties: + type: + type: string + description: "\"case\", \"service_request\", or \"security_report_analysis\"" + projectId: + type: string + format: uuid + deploymentId: + type: string + format: uuid + deployedProductId: + type: string + format: uuid + subject: + type: string + description: + type: string + severity: + type: string + issueType: + type: string + catalogId: + type: string + description: Required when type is "service_request". + catalogItemId: + type: string + description: Required when type is "service_request". + variables: + type: array + items: + type: object + properties: + id: + type: string + value: + type: string + relatedCaseId: + type: string + format: uuid + conversationId: + type: string + format: uuid + watchList: + type: array + items: + type: string + attachments: + type: array + description: Required (at least one) when type is "security_report_analysis". + items: + type: object + properties: + name: + type: string + file: + type: string + description: Base64 data URI, e.g. "data:application/pdf;base64,...". + + CaseCreateResponse: + type: object + properties: + id: + type: string + number: type: string - hasAgent: - type: boolean - hasKbReferences: - type: boolean createdOn: type: string + state: + type: string - SearchAccountsResponse: + CaseUpdateRequest: + description: > + Exactly one of state/severity/subject/description/watchList is + required. resolutionCode/cause/closeNotes are only accepted + alongside a closing state transition. type: object properties: - accounts: + state: + type: string + severity: + type: string + subject: + type: string + description: + type: string + watchList: type: array items: - $ref: '#/components/schemas/AccountSummary' - total: - type: integer - limit: - type: integer - offset: - type: integer - hasMore: - type: boolean + type: string + resolutionCode: + type: string + cause: + type: string + closeNotes: + type: string - AccountDetails: + CaseUpdateResponse: type: object properties: id: type: string - name: + updatedOn: type: string - tier: + state: type: string - region: + severity: type: string - supportTier: + workState: type: string - owner: - $ref: '#/components/schemas/Ref' - technicalOwner: - $ref: '#/components/schemas/Ref' - activationDate: + watchList: + type: array + items: + type: string + assignedTo: + $ref: '#/components/schemas/PersonRef' + resolutionCode: + type: string + cause: + type: string + closeNotes: + type: string + resolvedOn: + type: string + parentCase: + $ref: '#/components/schemas/NumberRef' + fixEta: + type: string + + CaseCommentRequest: + type: object + required: [content] + properties: + content: type: string - deactivationDate: + + CaseCommentResponse: + type: object + properties: + id: type: string - hasAgent: - type: boolean - hasKbReferences: - type: boolean createdOn: type: string - updatedOn: + createdBy: type: string - # ---- projects ---- + # ---- deployments ---- - SearchProjectsRequest: + SearchDeploymentsRequest: type: object properties: pagination: $ref: '#/components/schemas/Pagination' searchQuery: type: string - closureStatus: - type: string - endDateFrom: - type: string - endDateTo: - type: string - sortBy: - type: string - sortOrder: - type: string + projectIds: + type: array + items: + type: string + deploymentTypes: + type: array + items: + type: string - ProjectSummary: + DeploymentSummary: type: object properties: id: type: string - name: + number: type: string - key: + name: type: string - subscriptionType: + type: type: string - endDate: + description: type: string + createdBy: + $ref: '#/components/schemas/Ref' + project: + $ref: '#/components/schemas/Ref' createdOn: type: string - closureState: + updatedOn: type: string - SearchProjectsResponse: + SearchDeploymentsResponse: type: object properties: - projects: + deployments: type: array items: - $ref: '#/components/schemas/ProjectSummary' + $ref: '#/components/schemas/DeploymentSummary' total: type: integer limit: @@ -1014,443 +1994,344 @@ components: hasMore: type: boolean - ProjectAccount: + CreateDeploymentRequest: type: object + required: [projectId, name] properties: - id: + projectId: type: string + format: uuid name: type: string - tier: + type: type: string - region: + description: type: string - ProjectDetails: + DeploymentCreateResponse: type: object properties: id: type: string - account: - $ref: '#/components/schemas/ProjectAccount' - name: - type: string - key: - type: string - subscriptionType: - type: string - startDate: - type: string - endDate: - type: string createdOn: type: string - updatedOn: - type: string - closureState: - type: string - # ---- cases ---- + # ---- deployed products ---- - SearchCasesRequest: + SearchDeployedProductsRequest: type: object properties: pagination: $ref: '#/components/schemas/Pagination' - sortBy: - type: object - properties: - field: - type: string - order: - type: string - filters: - type: object - properties: - types: - type: array - items: - type: string - searchQuery: - type: string - projectIds: - type: array - items: - type: string - deploymentIds: - type: array - items: - type: string - states: - type: array - items: - type: string - severities: - type: array - items: - type: string - issueTypes: - type: array - items: - type: string - engagementTypes: - type: array - items: - type: string - createdBy: - type: array - items: - type: string - createdByMe: - type: boolean - workStates: - type: array - items: - type: string - assignedUserIds: - type: array - items: - type: string - productNames: - type: array - items: - type: string - tags: - type: array - items: - type: string - parentId: - type: string - - CaseSummary: - type: object - properties: - id: - type: string - number: - type: string - subject: - type: string - description: - type: string - state: - type: string - severity: - type: string - issueType: - type: string - engagementType: - type: string - workState: - type: string - type: - type: string - createdOn: - type: string - project: - $ref: '#/components/schemas/Ref' - deployment: - $ref: '#/components/schemas/Ref' - product: - $ref: '#/components/schemas/Ref' - assignedTeam: - $ref: '#/components/schemas/Ref' - - SearchCasesResponse: - type: object - properties: - cases: + deploymentIds: type: array items: - $ref: '#/components/schemas/CaseSummary' - total: - type: integer - limit: - type: integer - offset: - type: integer - - CaseTag: - type: object - properties: - label: - type: string - color: - type: string + type: string - LinkedServiceRequest: + DeployedProductVersion: type: object properties: id: type: string - number: - type: string name: type: string + releasedDate: + type: string + supportEoLDate: + type: string - CaseDetails: + DeployedProductSummary: type: object properties: id: type: string - number: - type: string - subject: - type: string - description: - type: string - severity: - type: string - issueType: - type: string - state: - type: string - workState: - type: string - type: - type: string - engagementType: - type: string - createdOn: - type: string - updatedOn: - type: string - closedOn: - type: string - createdBy: - $ref: '#/components/schemas/PersonRef' - project: - $ref: '#/components/schemas/Ref' deployment: $ref: '#/components/schemas/Ref' - deployedProduct: - $ref: '#/components/schemas/Ref' product: $ref: '#/components/schemas/Ref' - assignedTeam: - $ref: '#/components/schemas/Ref' - conversation: - $ref: '#/components/schemas/Ref' - assignedEngineer: - $ref: '#/components/schemas/PersonRef' - parentCase: - $ref: '#/components/schemas/NumberRef' - relatedCase: - $ref: '#/components/schemas/NumberRef' - linkedServiceRequests: - type: array - items: - $ref: '#/components/schemas/LinkedServiceRequest' - resolvedOn: + version: + $ref: '#/components/schemas/DeployedProductVersion' + cores: type: string - resolutionCode: + tps: type: string - cause: + category: type: string - resolutionNotes: + createdOn: type: string - fixEta: + updatedOn: type: string - tags: + + SearchDeployedProductsResponse: + type: object + properties: + deployedProducts: type: array items: - $ref: '#/components/schemas/CaseTag' + $ref: '#/components/schemas/DeployedProductSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean - CaseCreateRequest: + CreateDeployedProductRequest: type: object - required: [type, projectId, deploymentId, subject, description, severity, issueType] + required: [projectId, deploymentId, productId, versionId] properties: - type: - type: string - description: "\"case\", \"service_request\", or \"security_report_analysis\"" projectId: type: string format: uuid deploymentId: type: string format: uuid - deployedProductId: + productId: type: string format: uuid - subject: + versionId: type: string + format: uuid + cores: + type: integer + tps: + type: number description: type: string - severity: - type: string - issueType: - type: string - catalogId: + + DeployedProductCreateResponse: + type: object + properties: + id: type: string - description: Required when type is "service_request". - catalogItemId: + createdOn: type: string - description: Required when type is "service_request". - variables: - type: array - items: - type: object - properties: - id: - type: string - value: - type: string - relatedCaseId: + + UpdateDeployedProductRequest: + description: Provide either cores/tps/description or active=false, but not both. + type: object + properties: + deploymentId: type: string format: uuid - conversationId: + description: Optional — scopes the update to this deployment. + cores: + type: integer + tps: + type: number + description: type: string - format: uuid - watchList: - type: array - items: - type: string - attachments: - type: array - description: Required (at least one) when type is "security_report_analysis". - items: - type: object - properties: - name: - type: string - file: - type: string - description: Base64 data URI, e.g. "data:application/pdf;base64,...". + active: + type: boolean - CaseCreateResponse: + DeployedProductUpdateResponse: type: object properties: id: type: string - number: - type: string - createdOn: - type: string - state: + updatedOn: type: string - CaseUpdateRequest: - description: > - Exactly one of state/severity/subject/description/watchList is - required. resolutionCode/cause/closeNotes are only accepted - alongside a closing state transition. + # ---- attachments ---- + + CreateAttachmentRequest: type: object + required: [referenceId, referenceType, name, type, file] properties: - state: + referenceId: type: string - severity: + format: uuid + referenceType: type: string - subject: + description: "\"case\", \"conversation\", \"change_request\", \"deployment\", or \"incident\"" + name: + type: string + type: + type: string + description: MIME/content type of the file. + file: type: string + description: Base64-encoded file content. description: type: string - watchList: - type: array - items: - type: string - resolutionCode: + + AttachmentCreateResponse: + type: object + properties: + id: type: string - cause: + sizeBytes: + type: integer + createdOn: type: string - closeNotes: + downloadUrl: type: string - CaseUpdateResponse: + SearchAttachmentsRequest: + type: object + required: [referenceId, referenceType] + properties: + referenceId: + type: string + format: uuid + referenceType: + type: string + pagination: + $ref: '#/components/schemas/Pagination' + + AttachmentSummary: type: object properties: id: type: string - updatedOn: + referenceId: type: string - state: + referenceType: type: string - severity: + name: type: string - workState: + type: type: string - watchList: - type: array - items: - type: string - assignedTo: - $ref: '#/components/schemas/PersonRef' - resolutionCode: + sizeBytes: + type: integer + description: type: string - cause: + createdBy: type: string - closeNotes: + createdOn: type: string - resolvedOn: + downloadUrl: type: string - parentCase: - $ref: '#/components/schemas/NumberRef' - fixEta: + previewUrl: type: string - CaseCommentRequest: + SearchAttachmentsResponse: type: object - required: [content] properties: - content: + attachments: + type: array + items: + $ref: '#/components/schemas/AttachmentSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean + + DeleteResponse: + type: object + properties: + message: type: string - CaseCommentResponse: + # ---- case activities ---- + + CaseFieldChange: + type: object + properties: + field: + type: string + fieldLabel: + type: string + previousValue: + type: string + newValue: + type: string + + CaseActivity: + description: > + A discriminated union on type: "comment" entries additionally carry + commentType; "attachment" entries carry fileName/contentType/ + sizeBytes/downloadUrl; "field_change" entries carry changes. type: object properties: id: type: string + type: + type: string + description: "\"comment\", \"attachment\", or \"field_change\"" + content: + type: string createdOn: type: string createdBy: type: string + commentType: + type: string + fileName: + type: string + contentType: + type: string + sizeBytes: + type: integer + downloadUrl: + type: string + changes: + type: array + items: + $ref: '#/components/schemas/CaseFieldChange' - # ---- deployments ---- + SearchCaseActivitiesRequest: + type: object + properties: + pagination: + $ref: '#/components/schemas/Pagination' + includeFieldChanges: + type: boolean + description: When false or omitted, only comment and attachment entries are returned. - SearchDeploymentsRequest: + SearchCaseActivitiesResponse: + type: object + properties: + activity: + type: array + items: + $ref: '#/components/schemas/CaseActivity' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean + + # ---- products ---- + + SearchProductsRequest: type: object properties: pagination: $ref: '#/components/schemas/Pagination' searchQuery: type: string - projectIds: - type: array - items: - type: string - deploymentTypes: - type: array - items: - type: string - DeploymentSummary: + ProductSummary: type: object properties: id: type: string - number: - type: string name: type: string - type: - type: string - description: + class: type: string - createdBy: - $ref: '#/components/schemas/Ref' - project: - $ref: '#/components/schemas/Ref' createdOn: type: string updatedOn: type: string - SearchDeploymentsResponse: + SearchProductsResponse: type: object properties: - deployments: + products: type: array items: - $ref: '#/components/schemas/DeploymentSummary' + $ref: '#/components/schemas/ProductSummary' total: type: integer limit: @@ -1460,27 +2341,49 @@ components: hasMore: type: boolean - CreateDeploymentRequest: + SearchProductVersionsRequest: type: object - required: [projectId, name] properties: - projectId: - type: string - format: uuid - name: - type: string - type: - type: string - description: + pagination: + $ref: '#/components/schemas/Pagination' + searchQuery: type: string - DeploymentCreateResponse: + ProductVersionSummary: type: object properties: id: type: string + version: + type: string + currentSupportStatus: + type: string + releaseDate: + type: string + supportEolDate: + type: string + earliestPossibleSupportEolDate: + type: string createdOn: type: string + updatedOn: + type: string + + SearchProductVersionsResponse: + type: object + properties: + productVersions: + type: array + items: + $ref: '#/components/schemas/ProductVersionSummary' + total: + type: integer + limit: + type: integer + offset: + type: integer + hasMore: + type: boolean # ---- updates ----