diff --git a/api/commons/schemas/responseItemWrapper.yaml b/api/commons/schemas/responseItemWrapper.yaml index e995c8399..ac167f904 100644 --- a/api/commons/schemas/responseItemWrapper.yaml +++ b/api/commons/schemas/responseItemWrapper.yaml @@ -6,12 +6,18 @@ allOf: response: type: "object" properties: + kind: + type: "string" + description: > + The data type of each item in the response. + items: + type: "array" + description: > + Array of data objects. + items: + type: "object" count: type: "integer" example: 1 description: > Size of the data object array. - kind: - type: "string" - description: > - The data type of each item in the response. diff --git a/api/services/ocean/rightsizing/parameters/limit.yaml b/api/services/ocean/rightsizing/parameters/limit.yaml new file mode 100644 index 000000000..3b88d1081 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/limit.yaml @@ -0,0 +1,12 @@ +in: query +name: limit +schema: + type: integer + format: int16 + default: 100 + minimum: 1 + maximum: 200 +required: false +example: 100 +description: > + Number of entries to return. \ No newline at end of file diff --git a/api/services/ocean/rightsizing/parameters/namespace.yaml b/api/services/ocean/rightsizing/parameters/namespace.yaml new file mode 100644 index 000000000..58397dd3d --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/namespace.yaml @@ -0,0 +1,9 @@ +in: path +name: namespace +schema: + type: string +required: true +example: kube-system +description: > + Kubernetes namespace. + diff --git a/api/services/ocean/rightsizing/parameters/offset.yaml b/api/services/ocean/rightsizing/parameters/offset.yaml new file mode 100644 index 000000000..44a3668f4 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/offset.yaml @@ -0,0 +1,11 @@ +in: query +name: offset +schema: + type: integer + format: int16 + default: 0 + minimum: 0 + example: 0 +required: false +description: > + Number of entries to skip before returning page. \ No newline at end of file diff --git a/api/services/ocean/rightsizing/parameters/workloadName.yaml b/api/services/ocean/rightsizing/parameters/workloadName.yaml new file mode 100644 index 000000000..b37533fc7 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/workloadName.yaml @@ -0,0 +1,9 @@ +in: path +name: workloadName +schema: + type: string +required: true +example: redis-controller +description: > + Kubernetes workload name. + diff --git a/api/services/ocean/rightsizing/parameters/workloadType.yaml b/api/services/ocean/rightsizing/parameters/workloadType.yaml new file mode 100644 index 000000000..f2a186ae6 --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/workloadType.yaml @@ -0,0 +1,14 @@ +in: path +name: workloadType +schema: + type: string + enum: + - deployment + - daemonSet + - statefulSet + - rollout +required: true +example: deployment +description: > + Workload type as defined in kubernetes. + diff --git a/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationApplicationHistory.yaml b/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationApplicationHistory.yaml new file mode 100644 index 000000000..1ed816e58 --- /dev/null +++ b/api/services/ocean/rightsizing/paths/oceanRightsizingRecommendationApplicationHistory.yaml @@ -0,0 +1,25 @@ +get: + summary: "Get Workload Recommendation Application History" + description: | + Returns a set of recommendation application history records associated with workload. + operationId: "getWorkloadRecommendationApplicationHistory" + tags: + - "Ocean Automatic Rightsizing" + parameters: + - $ref: "../parameters/oceanId.yaml" + - $ref: "../parameters/namespace.yaml" + - $ref: "../parameters/workloadType.yaml" + - $ref: "../parameters/workloadName.yaml" + - $ref: "../../../../commons/parameters/accountId.yaml" + - $ref: "../parameters/offset.yaml" + - $ref: "../parameters/limit.yaml" + responses: + 200: + $ref: "../responses/oceanRightsizingRecommendationApplicationHistoryResponse.yaml" + 400: + description: "Invalid request provided" + 404: + description: "Non existent resource has been queried" + 422: + description: "Business rule violated" + diff --git a/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationApplicationHistoryResponse.yaml b/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationApplicationHistoryResponse.yaml new file mode 100644 index 000000000..a440f5dae --- /dev/null +++ b/api/services/ocean/rightsizing/responses/oceanRightsizingRecommendationApplicationHistoryResponse.yaml @@ -0,0 +1,39 @@ +description: "Ocean Rightsizing Recommendation Application History Response" +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/o-abcd1234/rightSizing/namespaces/kube-system/deployment/redis-controller/recommendation-application-history" + method: + example: "GET" + response: + type: object + properties: + kind: + example: "mcs:ocean:rightSizing:recommendationApplicationHistory" + items: + type: array + items: + $ref: "../schemas/oceanRightsizingRecommendationApplicationHistory.yaml" + example: + - page: + - containerName: "my-app-container" + actionType: "APPLIED" + currentResources: + cpu: 4000 + memory: 16000 + recommendedResources: + cpu: 2000 + memory: 8000 + occurredAt: 1776178797289 + ruleName: "my-app-rule" + count: + example: 1 + diff --git a/api/services/ocean/rightsizing/schemas/oceanRightsizingComputeResource.yaml b/api/services/ocean/rightsizing/schemas/oceanRightsizingComputeResource.yaml new file mode 100644 index 000000000..1e12cc50e --- /dev/null +++ b/api/services/ocean/rightsizing/schemas/oceanRightsizingComputeResource.yaml @@ -0,0 +1,16 @@ +type: object +title: Compute Resource +description: > + Represents CPU and memory resource values. +properties: + cpu: + type: integer + format: int32 + description: CPU resource value in millicores. + example: 4000 + memory: + type: integer + format: int32 + description: Memory resource value in MiB. + example: 16000 + diff --git a/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationHistory.yaml b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationHistory.yaml new file mode 100644 index 000000000..208d8a838 --- /dev/null +++ b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationHistory.yaml @@ -0,0 +1,10 @@ +type: object +title: Recommendation Application History +description: > + A page of recommendation application history records. +properties: + page: + type: array + items: + $ref: "../schemas/oceanRightsizingRecommendationApplicationItem.yaml" + diff --git a/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationItem.yaml b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationItem.yaml new file mode 100644 index 000000000..5984f7998 --- /dev/null +++ b/api/services/ocean/rightsizing/schemas/oceanRightsizingRecommendationApplicationItem.yaml @@ -0,0 +1,37 @@ +type: object +title: Recommendation Application Item +description: > + A single recommendation application history record for a container. +properties: + containerName: + type: string + description: Name of the container. + example: "my-app-container" + actionType: + type: string + description: The type of action that was taken or the reason it was not applied. + enum: + - APPLIED + - CPU_ONLY_APPLIED + - MEMORY_ONLY_APPLIED + - OUTSIDE_OF_TIME_WINDOW + - THRESHOLD_NOT_MET + - HPA_RESTRICTED + - UNSUPPORTED_HPA + - INVALID_HPA + - PRELIMINARY_RESTRICTED + example: "APPLIED" + currentResources: + $ref: "../schemas/oceanRightsizingComputeResource.yaml" + recommendedResources: + $ref: "../schemas/oceanRightsizingComputeResource.yaml" + occurredAt: + type: integer + format: int64 + description: Timestamp (epoch millis) when the action occurred. + example: 1776178797289 + ruleName: + type: string + description: Name of the rightsizing rule that triggered this action. + example: "my-app-rule" + diff --git a/api/spot.yaml b/api/spot.yaml index 6f00edac0..98005ba6b 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -971,6 +971,8 @@ paths: $ref: services/ocean/rightsizing/paths/oceanRightsizingClusterConfiguration.yaml /ocean/{oceanId}/rightSizing/savings: $ref: services/ocean/rightsizing/paths/oceanRightsizingSavings.yaml + /ocean/{oceanId}/rightSizing/namespaces/{namespace}/{workloadType}/{workloadName}/recommendation-application-history: + $ref: services/ocean/rightsizing/paths/oceanRightsizingRecommendationApplicationHistory.yaml /security/v1/compliances: $ref: services/security/v1/paths/compliances.yaml /security/v1/compliances/count: