From c1d8730ebaa8bf90919da133128a9a6fed19039f Mon Sep 17 00:00:00 2001 From: Paul van Wichen <126611130+paul-van-wichen@users.noreply.github.com> Date: Wed, 11 Dec 2024 07:49:57 -0500 Subject: [PATCH] DOC-2166 / SF-18880 - add Cost Intelligence 'Setup CI on Spot account' related API endpoints. (#689) --- api/commons/schemas/errorModel.yaml | 11 +++ api/commons/schemas/errorResponse.yaml | 12 +++ .../schemas/paginatedResponseItemWrapper.yaml | 25 ++++++ api/commons/schemas/paginationInfo.yaml | 15 ++++ .../beci/setup/paths/cbiV1SetupAccount.yaml | 77 +++++++++++++++++++ .../paths/cbiV1SetupAccountValidation.yaml | 34 ++++++++ .../responses/get200cbiV1SetupAccount.yaml | 24 ++++++ .../responses/post200cbiV1SetupAccount.yaml | 24 ++++++ .../post200cbiV1SetupAccountValidation.yaml | 24 ++++++ .../schemas/CIRegisteredAccountResponse.yaml | 37 +++++++++ ...CIRegisteredAccountWithStatusResponse.yaml | 45 +++++++++++ api/services/beci/setup/schemas/account.yaml | 8 ++ .../beci/setup/schemas/accountStatusItem.yaml | 29 +++++++ .../setup/schemas/accountStatusStatistic.yaml | 24 ++++++ .../setup/schemas/accountStatusSummary.yaml | 6 ++ .../beci/setup/schemas/cloudProvider.yaml | 6 ++ .../createCIRegisteredAccountModel.yaml | 7 ++ .../setup/schemas/productOfferingEnum.yaml | 6 ++ .../schemas/validationModelResponse.yaml | 25 ++++++ .../beci/setup/schemas/validationStatus.yaml | 7 ++ api/spot.yaml | 8 +- 21 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 api/commons/schemas/errorModel.yaml create mode 100644 api/commons/schemas/errorResponse.yaml create mode 100644 api/commons/schemas/paginatedResponseItemWrapper.yaml create mode 100644 api/commons/schemas/paginationInfo.yaml create mode 100644 api/services/beci/setup/paths/cbiV1SetupAccount.yaml create mode 100644 api/services/beci/setup/paths/cbiV1SetupAccountValidation.yaml create mode 100644 api/services/beci/setup/responses/get200cbiV1SetupAccount.yaml create mode 100644 api/services/beci/setup/responses/post200cbiV1SetupAccount.yaml create mode 100644 api/services/beci/setup/responses/post200cbiV1SetupAccountValidation.yaml create mode 100644 api/services/beci/setup/schemas/CIRegisteredAccountResponse.yaml create mode 100644 api/services/beci/setup/schemas/CIRegisteredAccountWithStatusResponse.yaml create mode 100644 api/services/beci/setup/schemas/account.yaml create mode 100644 api/services/beci/setup/schemas/accountStatusItem.yaml create mode 100644 api/services/beci/setup/schemas/accountStatusStatistic.yaml create mode 100644 api/services/beci/setup/schemas/accountStatusSummary.yaml create mode 100644 api/services/beci/setup/schemas/cloudProvider.yaml create mode 100644 api/services/beci/setup/schemas/createCIRegisteredAccountModel.yaml create mode 100644 api/services/beci/setup/schemas/productOfferingEnum.yaml create mode 100644 api/services/beci/setup/schemas/validationModelResponse.yaml create mode 100644 api/services/beci/setup/schemas/validationStatus.yaml diff --git a/api/commons/schemas/errorModel.yaml b/api/commons/schemas/errorModel.yaml new file mode 100644 index 000000000..1345b38ca --- /dev/null +++ b/api/commons/schemas/errorModel.yaml @@ -0,0 +1,11 @@ +properties: + code: + type: string + description: Error code. + message: + type: string + description: Error message. +type: object +required: +- message +title: ErrorModel \ No newline at end of file diff --git a/api/commons/schemas/errorResponse.yaml b/api/commons/schemas/errorResponse.yaml new file mode 100644 index 000000000..2eb2bcaa6 --- /dev/null +++ b/api/commons/schemas/errorResponse.yaml @@ -0,0 +1,12 @@ +allOf: + - $ref: "../schemas/responseWrapper.yaml" + - type: "object" + properties: + response: + type: "object" + properties: + errors: + type: "array" + description: List of errors. + items: + $ref: "../schemas/errorModel.yaml" diff --git a/api/commons/schemas/paginatedResponseItemWrapper.yaml b/api/commons/schemas/paginatedResponseItemWrapper.yaml new file mode 100644 index 000000000..fab448a45 --- /dev/null +++ b/api/commons/schemas/paginatedResponseItemWrapper.yaml @@ -0,0 +1,25 @@ +allOf: + - $ref: "../schemas/responseWrapper.yaml" + - type: "object" + properties: + response: + type: "object" + properties: + 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. + paginationInfo: + $ref: "../schemas/paginationInfo.yaml" + nullable: true diff --git a/api/commons/schemas/paginationInfo.yaml b/api/commons/schemas/paginationInfo.yaml new file mode 100644 index 000000000..1a1559926 --- /dev/null +++ b/api/commons/schemas/paginationInfo.yaml @@ -0,0 +1,15 @@ +properties: + totalCount: + type: integer + nullable: true + description: "[Optional/Not supported on all APIs] Total number of items (for all pages)." + nextKey: + type: string + nullable: true + description: Key used to fetch next page of data (if any). + previousKey: + type: string + nullable: true + description: Key used to fetch previous page of data (if any). +type: object +title: PaginationInfo \ No newline at end of file diff --git a/api/services/beci/setup/paths/cbiV1SetupAccount.yaml b/api/services/beci/setup/paths/cbiV1SetupAccount.yaml new file mode 100644 index 000000000..bb06a5fbc --- /dev/null +++ b/api/services/beci/setup/paths/cbiV1SetupAccount.yaml @@ -0,0 +1,77 @@ +post: + tags: + - Accounts + summary: Setup Cost Intelligence + description: Sets up and enables Cost Intelligence functionality on a Spot account. + The Spot account must already have credentials and be linked to a valid cloud + provider account (e.g. AWS account, Azure subscription, etc). + operationId: setupAccountCbiV1SetupAccountPost + requestBody: + required: true + content: + application/json: + schema: + $ref: ../schemas/createCIRegisteredAccountModel.yaml + responses: + '200': + $ref: ../responses/post200cbiV1SetupAccount.yaml + '400': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Invalid request error response. Adjust the request before retrying. + '404': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Not found error response. The requested resource does not exist. + '422': + description: Error response. + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml +get: + tags: + - Accounts + summary: Get Cost Intelligence Registered Accounts + description: Get list of Spot accounts where Cost Intelligence has been setup. + operationId: getAccountsCbiV1SetupAccountGet + parameters: + - name: paginationSize + in: query + required: false + schema: + type: integer + description: Number of items to include in the response + description: Number of items to include in the response + - name: paginationKey + in: query + required: false + schema: + type: string + description: Key used to fetch a specific page of items + description: Key used to fetch a specific page of items + responses: + '200': + $ref: ../responses/get200cbiV1SetupAccount.yaml + '400': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Invalid request error response. Adjust the request before retrying. + '404': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Not found error response. The requested resource does not exist. + '422': + description: Error response. + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml diff --git a/api/services/beci/setup/paths/cbiV1SetupAccountValidation.yaml b/api/services/beci/setup/paths/cbiV1SetupAccountValidation.yaml new file mode 100644 index 000000000..66bc6bbef --- /dev/null +++ b/api/services/beci/setup/paths/cbiV1SetupAccountValidation.yaml @@ -0,0 +1,34 @@ +post: + tags: + - Accounts + summary: Perform Cost Intelligence Setup Validations + description: Validate that Cost Intelligence can be setup on the specified Spot + Account. + operationId: validateSetupAccountCbiV1SetupAccountValidationPost + requestBody: + required: true + content: + application/json: + schema: + $ref: ../schemas/createCIRegisteredAccountModel.yaml + responses: + '200': + $ref: ../responses/post200cbiV1SetupAccountValidation.yaml + '400': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Invalid request error response. Adjust the request before retrying. + '404': + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml + description: Not found error response. The requested resource does not exist. + '422': + description: Error response. + content: + application/json: + schema: + $ref: ../../../../commons/schemas/errorResponse.yaml diff --git a/api/services/beci/setup/responses/get200cbiV1SetupAccount.yaml b/api/services/beci/setup/responses/get200cbiV1SetupAccount.yaml new file mode 100644 index 000000000..ede6ce88d --- /dev/null +++ b/api/services/beci/setup/responses/get200cbiV1SetupAccount.yaml @@ -0,0 +1,24 @@ +description: Successful response +content: + application/json: + schema: + allOf: + - $ref: ../../../../commons/schemas/paginatedResponseItemWrapper.yaml + - type: object + properties: + request: + type: object + properties: + url: + example: /cbi/v1/setup/account + method: + example: GET + response: + type: object + properties: + items: + type: array + items: + $ref: ../schemas/CIRegisteredAccountWithStatusResponse.yaml + kind: + example: string diff --git a/api/services/beci/setup/responses/post200cbiV1SetupAccount.yaml b/api/services/beci/setup/responses/post200cbiV1SetupAccount.yaml new file mode 100644 index 000000000..f08bf5cce --- /dev/null +++ b/api/services/beci/setup/responses/post200cbiV1SetupAccount.yaml @@ -0,0 +1,24 @@ +description: Successful response +content: + application/json: + schema: + allOf: + - $ref: ../../../../commons/schemas/responseItemWrapper.yaml + - type: object + properties: + request: + type: object + properties: + url: + example: /cbi/v1/setup/account + method: + example: POST + response: + type: object + properties: + items: + type: array + items: + $ref: ../schemas/CIRegisteredAccountResponse.yaml + kind: + example: spotinst:cbi:inventory:ciRegisteredAccount diff --git a/api/services/beci/setup/responses/post200cbiV1SetupAccountValidation.yaml b/api/services/beci/setup/responses/post200cbiV1SetupAccountValidation.yaml new file mode 100644 index 000000000..db2376d80 --- /dev/null +++ b/api/services/beci/setup/responses/post200cbiV1SetupAccountValidation.yaml @@ -0,0 +1,24 @@ +description: Successful response +content: + application/json: + schema: + allOf: + - $ref: ../../../../commons/schemas/responseItemWrapper.yaml + - type: object + properties: + request: + type: object + properties: + url: + example: /cbi/v1/setup/account/validation + method: + example: POST + response: + type: object + properties: + items: + type: array + items: + $ref: ../schemas/validationModelResponse.yaml + kind: + example: spotinst:cbi:accountRegistrationValidation diff --git a/api/services/beci/setup/schemas/CIRegisteredAccountResponse.yaml b/api/services/beci/setup/schemas/CIRegisteredAccountResponse.yaml new file mode 100644 index 000000000..56ffe0880 --- /dev/null +++ b/api/services/beci/setup/schemas/CIRegisteredAccountResponse.yaml @@ -0,0 +1,37 @@ +properties: + organizationId: + type: string + description: Spot Organization ID. + example: '60100100100100' + accountId: + type: string + description: Spot Account ID. + example: act-012345 + providerName: + $ref: cloudProvider.yaml + description: Cloud provider of setup account. + example: aws + externalProviderId: + type: string + description: Cloud provider of setup account. + example: '012345678901' + enabledDate: + type: string + format: date-time + description: Date/time when Cost Intelligence was registered on the Spot account. + updatedDate: + type: string + format: date-time + description: Date/time when the Cost Intelligence registration was updated on + the Spot account. +type: object +required: + - organizationId + - accountId + - providerName + - externalProviderId + - enabledDate + - updatedDate +title: CIRegisteredAccountResponse +description: Represents a Spot account on which Cost Intelligence has been registered + / enabled. [kind/spotinst:cbi:inventory:ciRegisteredAccount] diff --git a/api/services/beci/setup/schemas/CIRegisteredAccountWithStatusResponse.yaml b/api/services/beci/setup/schemas/CIRegisteredAccountWithStatusResponse.yaml new file mode 100644 index 000000000..72f14a7e2 --- /dev/null +++ b/api/services/beci/setup/schemas/CIRegisteredAccountWithStatusResponse.yaml @@ -0,0 +1,45 @@ +properties: + organizationId: + type: string + description: Spot Organization ID. + example: '60100100100100' + accountId: + type: string + description: Spot Account ID. + example: act-012345 + providerName: + $ref: cloudProvider.yaml + description: Cloud provider of setup account. + example: aws + externalProviderId: + type: string + description: Cloud provider of setup account. + example: '012345678901' + enabledDate: + type: string + format: date-time + description: Date/time when Cost Intelligence was registered on the Spot account. + updatedDate: + type: string + format: date-time + description: Date/time when the Cost Intelligence registration was updated on + the Spot account. + statusSummary: + $ref: accountStatusSummary.yaml + description: Account status summary. + status: + description: Account status + type: array + items: + $ref: accountStatusItem.yaml + nullable: true +type: object +required: + - organizationId + - accountId + - providerName + - externalProviderId + - enabledDate + - updatedDate + - statusSummary +title: CIRegisteredAccountWithStatusResponse diff --git a/api/services/beci/setup/schemas/account.yaml b/api/services/beci/setup/schemas/account.yaml new file mode 100644 index 000000000..4784d0592 --- /dev/null +++ b/api/services/beci/setup/schemas/account.yaml @@ -0,0 +1,8 @@ +properties: + accountId: + type: string + description: Spot account ID +type: object +required: + - accountId +title: Account diff --git a/api/services/beci/setup/schemas/accountStatusItem.yaml b/api/services/beci/setup/schemas/accountStatusItem.yaml new file mode 100644 index 000000000..e63898753 --- /dev/null +++ b/api/services/beci/setup/schemas/accountStatusItem.yaml @@ -0,0 +1,29 @@ +properties: + productOffering: + $ref: productOfferingEnum.yaml + description: Product offering. + statusType: + type: string + description: Status type. + statusCode: + type: string + description: Status code. + statusMessage: + description: Status message. + type: string + nullable: true + statistics: + description: Status statistics. + $ref: accountStatusStatistic.yaml + nullable: true + statusTimestamp: + type: string + format: date-time + description: Status timestamp. +type: object +required: + - productOffering + - statusType + - statusCode + - statusTimestamp +title: AccountStatusItem diff --git a/api/services/beci/setup/schemas/accountStatusStatistic.yaml b/api/services/beci/setup/schemas/accountStatusStatistic.yaml new file mode 100644 index 000000000..6d69dd418 --- /dev/null +++ b/api/services/beci/setup/schemas/accountStatusStatistic.yaml @@ -0,0 +1,24 @@ +properties: + totalResourceTypeCount: + type: integer + description: Total number of resource types. + failedResourceTypeCount: + type: integer + description: Failed number of resource types. + successfulResourceTypes: + description: Successful resource types. + type: array + items: + type: string + nullable: true + failedResourceTypes: + description: Failed resource types. + type: array + items: + type: string + nullable: true +type: object +required: + - totalResourceTypeCount + - failedResourceTypeCount +title: AccountStatusStatistic diff --git a/api/services/beci/setup/schemas/accountStatusSummary.yaml b/api/services/beci/setup/schemas/accountStatusSummary.yaml new file mode 100644 index 000000000..b21d1e8f2 --- /dev/null +++ b/api/services/beci/setup/schemas/accountStatusSummary.yaml @@ -0,0 +1,6 @@ +type: string +enum: + - connected + - notConnected + - partiallyConnected +title: AccountStatusSummary diff --git a/api/services/beci/setup/schemas/cloudProvider.yaml b/api/services/beci/setup/schemas/cloudProvider.yaml new file mode 100644 index 000000000..bbb7a2c67 --- /dev/null +++ b/api/services/beci/setup/schemas/cloudProvider.yaml @@ -0,0 +1,6 @@ +type: string +enum: + - aws + - azure + - gcp +title: CloudProvider diff --git a/api/services/beci/setup/schemas/createCIRegisteredAccountModel.yaml b/api/services/beci/setup/schemas/createCIRegisteredAccountModel.yaml new file mode 100644 index 000000000..b2d1c2d40 --- /dev/null +++ b/api/services/beci/setup/schemas/createCIRegisteredAccountModel.yaml @@ -0,0 +1,7 @@ +properties: + account: + $ref: account.yaml +type: object +required: + - account +title: CreateCIRegisteredAccountModel diff --git a/api/services/beci/setup/schemas/productOfferingEnum.yaml b/api/services/beci/setup/schemas/productOfferingEnum.yaml new file mode 100644 index 000000000..7da50a4de --- /dev/null +++ b/api/services/beci/setup/schemas/productOfferingEnum.yaml @@ -0,0 +1,6 @@ +type: string +enum: + - common + - cloudBilling + - cbi +title: ProductOfferingEnum diff --git a/api/services/beci/setup/schemas/validationModelResponse.yaml b/api/services/beci/setup/schemas/validationModelResponse.yaml new file mode 100644 index 000000000..6ae3f5436 --- /dev/null +++ b/api/services/beci/setup/schemas/validationModelResponse.yaml @@ -0,0 +1,25 @@ +properties: + id: + type: string + description: Unique ID of the validation step that was performed. + description: + description: Summary of the validation step (i.e. what validation check was performed). + type: string + nullable: true + status: + $ref: validationStatus.yaml + description: Overall status of the validation step. + validationInfo: + description: Additional information about the reason the validation step failed. + type: string + nullable: true + validationInfoDetails: + description: Validation info details + type: object + nullable: true +type: object +required: + - id + - status +title: ValidationModelResponse +description: '[kind/spotinst:cbi:accountRegistrationValidation]' diff --git a/api/services/beci/setup/schemas/validationStatus.yaml b/api/services/beci/setup/schemas/validationStatus.yaml new file mode 100644 index 000000000..83576437f --- /dev/null +++ b/api/services/beci/setup/schemas/validationStatus.yaml @@ -0,0 +1,7 @@ +type: string +enum: + - success + - failed + - warning + - skipped +title: ValidationStatus diff --git a/api/spot.yaml b/api/spot.yaml index c4279b73b..92e187660 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -948,4 +948,10 @@ paths: /security/v1/misconfigurations/rules: $ref: services/security/v1/paths/rules.yaml /security/v1/misconfigurations/rules/count: - $ref: services/security/v1/paths/rules_count.yaml \ No newline at end of file + $ref: services/security/v1/paths/rules_count.yaml + # + /cbi/v1/setup/account: + $ref: services/beci/setup/paths/cbiV1SetupAccount.yaml + /cbi/v1/setup/account/validation: + $ref: services/beci/setup/paths/cbiV1SetupAccountValidation.yaml + #