diff --git a/api-runtime/rest-runtime/PriceInfoRest.go b/api-runtime/rest-runtime/PriceInfoRest.go index e2acb6b22..476ae2529 100644 --- a/api-runtime/rest-runtime/PriceInfoRest.go +++ b/api-runtime/rest-runtime/PriceInfoRest.go @@ -18,12 +18,30 @@ import ( ) // ================ PriceInfo Handler + +// ProductFamilyListResponse represents the response body structure for the ListProductFamily API. +type ProductFamilyListResponse struct { + Result []string `json:"productfamily" validate:"required" description:"A list of product families"` +} + +// listProductFamily godoc +// @ID list-product-family +// @Summary List Product Families +// @Description Retrieve a list of Product Families associated with a specific connection and region. +// @Tags [Cloud Metadata] Price +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to list Product Families for" +// @Param RegionName path string true "The name of the Region to list Product Families for" +// @Success 200 {object} ProductFamilyListResponse "List of Product Families" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid query parameter" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /productfamily/{RegionName} [get] func ListProductFamily(c echo.Context) error { cblog.Info("call ListProductFamily()") - var req struct { - ConnectionName string - } + req := ConnectionRequest{} if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -40,20 +58,41 @@ func ListProductFamily(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - var jsonResult struct { - Result []string `json:"productfamily"` - } + var jsonResult ProductFamilyListResponse jsonResult.Result = result return c.JSON(http.StatusOK, &jsonResult) } +// PriceInfoRequest represents the request body structure for the GetPriceInfo API. +type PriceInfoRequest struct { + ConnectionName string `json:"connectionName" validate:"required" description:"The name of the Connection to get Price Information for"` + FilterList []cres.KeyValue `json:"filterList" description:"A list of filters to apply to the price information request"` +} + +// PriceInfoResponse represents the response body structure for the GetPriceInfo API. +type PriceInfoResponse struct { + cres.CloudPriceData `json:",inline" description:"Price information details"` +} + +// getPriceInfo godoc +// @ID get-price-info +// @Summary Get Price Information +// @Description Retrieve price details of a specific Product Family in a specific Region.
* example body: {"connectionName":"aws-connection","FilterList":[{"Key":"instanceType","Value":"t2.micro"}]} +// @Tags [Cloud Metadata] Price +// @Accept json +// @Produce json +// @Param ProductFamily path string true "The name of the Product Family to retrieve price information for" example("Compute Instance") +// @Param RegionName path string true "The name of the Region to retrieve price information for" example("us-east-1") +// @Param PriceInfoRequest body PriceInfoRequest false "The request body containing additional filters for price information" +// @Success 200 {object} PriceInfoResponse "Price Information Details" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid query parameter" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /priceinfo/{ProductFamily}/{RegionName} [post] func GetPriceInfo(c echo.Context) error { cblog.Info("call GetPriceInfo()") - var req struct { - ConnectionName string - FilterList []cres.KeyValue - } + var req PriceInfoRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -70,8 +109,7 @@ func GetPriceInfo(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - var Result cres.CloudPriceData - json.Unmarshal([]byte(result), &Result) - return c.JSON(http.StatusOK, Result) - + var response PriceInfoResponse + json.Unmarshal([]byte(result), &response) + return c.JSON(http.StatusOK, response) } diff --git a/api/docs.go b/api/docs.go index 314c0b7ff..b6ed4faf8 100644 --- a/api/docs.go +++ b/api/docs.go @@ -2493,6 +2493,132 @@ const docTemplate = `{ } } }, + "/priceinfo/{ProductFamily}/{RegionName}": { + "post": { + "description": "Retrieve price details of a specific Product Family in a specific Region. \u003cbr\u003e * example body: {\"connectionName\":\"aws-connection\",\"FilterList\":[{\"Key\":\"instanceType\",\"Value\":\"t2.micro\"}]}", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[Cloud Metadata] Price" + ], + "summary": "Get Price Information", + "operationId": "get-price-info", + "parameters": [ + { + "type": "string", + "example": "\"Compute Instance\"", + "description": "The name of the Product Family to retrieve price information for", + "name": "ProductFamily", + "in": "path", + "required": true + }, + { + "type": "string", + "example": "\"us-east-1\"", + "description": "The name of the Region to retrieve price information for", + "name": "RegionName", + "in": "path", + "required": true + }, + { + "description": "The request body containing additional filters for price information", + "name": "PriceInfoRequest", + "in": "body", + "schema": { + "$ref": "#/definitions/spider.PriceInfoRequest" + } + } + ], + "responses": { + "200": { + "description": "Price Information Details", + "schema": { + "$ref": "#/definitions/spider.PriceInfoResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/productfamily/{RegionName}": { + "get": { + "description": "Retrieve a list of Product Families associated with a specific connection and region.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[Cloud Metadata] Price" + ], + "summary": "List Product Families", + "operationId": "list-product-family", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list Product Families for", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "The name of the Region to list Product Families for", + "name": "RegionName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "List of Product Families", + "schema": { + "$ref": "#/definitions/spider.ProductFamilyListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/regdisk": { "post": { "description": "Register a new Disk with the specified name, zone, and CSP ID.", @@ -4815,6 +4941,27 @@ const docTemplate = `{ } }, "definitions": { + "spider.CloudPrice": { + "type": "object", + "required": [ + "cloudName", + "priceList" + ], + "properties": { + "cloudName": { + "description": "Name of the cloud provider", + "type": "string", + "example": "AWS" + }, + "priceList": { + "description": "List of prices for different services/products", + "type": "array", + "items": { + "$ref": "#/definitions/spider.Price" + } + } + } + }, "spider.DiskInfo": { "type": "object", "required": [ @@ -5058,6 +5205,24 @@ const docTemplate = `{ } } }, + "spider.Meta": { + "type": "object", + "required": [ + "version" + ], + "properties": { + "description": { + "description": "Description of the pricing data", + "type": "string", + "example": "Cloud price data" + }, + "version": { + "description": "Version of the pricing data", + "type": "string", + "example": "1.0" + } + } + }, "spider.MyImageInfo": { "type": "object", "required": [ @@ -5125,6 +5290,218 @@ const docTemplate = `{ "WINDOWS" ] }, + "spider.Price": { + "type": "object", + "required": [ + "priceInfo", + "productInfo" + ], + "properties": { + "priceInfo": { + "description": "Pricing details of the product", + "allOf": [ + { + "$ref": "#/definitions/spider.PriceInfo" + } + ] + }, + "productInfo": { + "description": "Information about the product", + "allOf": [ + { + "$ref": "#/definitions/spider.ProductInfo" + } + ] + } + } + }, + "spider.PriceInfo": { + "type": "object", + "required": [ + "cspPriceInfo", + "pricingPolicies" + ], + "properties": { + "cspPriceInfo": { + "description": "Additional price information specific to CSP" + }, + "pricingPolicies": { + "description": "List of pricing policies", + "type": "array", + "items": { + "$ref": "#/definitions/spider.PricingPolicies" + } + } + } + }, + "spider.PricingPolicies": { + "type": "object", + "required": [ + "currency", + "price", + "pricingId", + "pricingPolicy", + "unit" + ], + "properties": { + "currency": { + "description": "Currency of the pricing", + "type": "string", + "example": "USD" + }, + "description": { + "description": "Description of the pricing policy", + "type": "string", + "example": "Pricing for t2.micro" + }, + "price": { + "description": "Price in the specified currency per unit", + "type": "string", + "example": "0.02" + }, + "pricingId": { + "description": "ID of the pricing policy", + "type": "string", + "example": "price-123" + }, + "pricingPolicy": { + "description": "Name of the pricing policy", + "type": "string", + "example": "On-Demand" + }, + "pricingPolicyInfo": { + "description": "Detail information about the pricing policy", + "allOf": [ + { + "$ref": "#/definitions/spider.PricingPolicyInfo" + } + ] + }, + "unit": { + "description": "Unit of the pricing (e.g., per hour)", + "type": "string", + "example": "hour" + } + } + }, + "spider.PricingPolicyInfo": { + "type": "object", + "properties": { + "LeaseContractLength": { + "description": "Length of the lease contract", + "type": "string", + "example": "1 year" + }, + "OfferingClass": { + "description": "Offering class (e.g., standard, convertible)", + "type": "string", + "example": "standard" + }, + "PurchaseOption": { + "description": "Purchase option (e.g., no upfront, partial upfront)", + "type": "string", + "example": "No Upfront" + } + } + }, + "spider.ProductInfo": { + "type": "object", + "required": [ + "cspProductInfo", + "productId", + "regionName" + ], + "properties": { + "cspProductInfo": { + "description": "Additional product information specific to CSP" + }, + "description": { + "description": "Description of the product", + "type": "string", + "example": "General purpose instance" + }, + "gpu": { + "description": "Number of GPUs", + "type": "string", + "example": "1" + }, + "gpuMemory": { + "description": "GPU memory size in MB", + "type": "string", + "example": "8192" + }, + "instanceType": { + "description": "--------- Compute Instance Info", + "type": "string", + "example": "t2.micro" + }, + "maxIopsvolume": { + "description": "Maximum IOPS for the volume", + "type": "string", + "example": "3000" + }, + "maxThroughputvolume": { + "description": "Maximum throughput for the volume in MB/s", + "type": "string", + "example": "250" + }, + "maxVolumeSize": { + "description": "Maximum volume size in GB", + "type": "string", + "example": "16384" + }, + "memory": { + "description": "Amount of memory in MB", + "type": "string", + "example": "4096" + }, + "operatingSystem": { + "description": "Operating system type", + "type": "string", + "example": "Linux" + }, + "preInstalledSw": { + "description": "Pre-installed software", + "type": "string", + "example": "None" + }, + "productId": { + "description": "ID of the product", + "type": "string", + "example": "prod-123" + }, + "regionName": { + "description": "Name of the region", + "type": "string", + "example": "us-east-1" + }, + "storage": { + "description": "Root-disk storage size in GB", + "type": "string", + "example": "100" + }, + "storageMedia": { + "description": "Storage media type", + "type": "string", + "example": "SSD" + }, + "vcpu": { + "description": "Number of vCPUs", + "type": "string", + "example": "2" + }, + "volumeType": { + "description": "--------- Storage Info // Data-Disk(AWS:EBS)", + "type": "string", + "example": "gp2" + }, + "zoneName": { + "description": "Name of the zone", + "type": "string", + "example": "us-east-1a" + } + } + }, "spider.RegionInfo": { "type": "object", "required": [ @@ -6331,6 +6708,55 @@ const docTemplate = `{ } } }, + "spider.PriceInfoRequest": { + "type": "object", + "required": [ + "connectionName" + ], + "properties": { + "connectionName": { + "type": "string" + }, + "filterList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + } + } + }, + "spider.PriceInfoResponse": { + "type": "object", + "required": [ + "cloudPriceList", + "meta" + ], + "properties": { + "cloudPriceList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.CloudPrice" + } + }, + "meta": { + "$ref": "#/definitions/spider.Meta" + } + } + }, + "spider.ProductFamilyListResponse": { + "type": "object", + "required": [ + "productfamily" + ], + "properties": { + "productfamily": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "spider.RegionZoneListResponse": { "type": "object", "required": [ diff --git a/api/swagger.json b/api/swagger.json index d1d58ad38..e5562a898 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -2490,6 +2490,132 @@ } } }, + "/priceinfo/{ProductFamily}/{RegionName}": { + "post": { + "description": "Retrieve price details of a specific Product Family in a specific Region. \u003cbr\u003e * example body: {\"connectionName\":\"aws-connection\",\"FilterList\":[{\"Key\":\"instanceType\",\"Value\":\"t2.micro\"}]}", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[Cloud Metadata] Price" + ], + "summary": "Get Price Information", + "operationId": "get-price-info", + "parameters": [ + { + "type": "string", + "example": "\"Compute Instance\"", + "description": "The name of the Product Family to retrieve price information for", + "name": "ProductFamily", + "in": "path", + "required": true + }, + { + "type": "string", + "example": "\"us-east-1\"", + "description": "The name of the Region to retrieve price information for", + "name": "RegionName", + "in": "path", + "required": true + }, + { + "description": "The request body containing additional filters for price information", + "name": "PriceInfoRequest", + "in": "body", + "schema": { + "$ref": "#/definitions/spider.PriceInfoRequest" + } + } + ], + "responses": { + "200": { + "description": "Price Information Details", + "schema": { + "$ref": "#/definitions/spider.PriceInfoResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/productfamily/{RegionName}": { + "get": { + "description": "Retrieve a list of Product Families associated with a specific connection and region.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[Cloud Metadata] Price" + ], + "summary": "List Product Families", + "operationId": "list-product-family", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list Product Families for", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "The name of the Region to list Product Families for", + "name": "RegionName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "List of Product Families", + "schema": { + "$ref": "#/definitions/spider.ProductFamilyListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/regdisk": { "post": { "description": "Register a new Disk with the specified name, zone, and CSP ID.", @@ -4812,6 +4938,27 @@ } }, "definitions": { + "spider.CloudPrice": { + "type": "object", + "required": [ + "cloudName", + "priceList" + ], + "properties": { + "cloudName": { + "description": "Name of the cloud provider", + "type": "string", + "example": "AWS" + }, + "priceList": { + "description": "List of prices for different services/products", + "type": "array", + "items": { + "$ref": "#/definitions/spider.Price" + } + } + } + }, "spider.DiskInfo": { "type": "object", "required": [ @@ -5055,6 +5202,24 @@ } } }, + "spider.Meta": { + "type": "object", + "required": [ + "version" + ], + "properties": { + "description": { + "description": "Description of the pricing data", + "type": "string", + "example": "Cloud price data" + }, + "version": { + "description": "Version of the pricing data", + "type": "string", + "example": "1.0" + } + } + }, "spider.MyImageInfo": { "type": "object", "required": [ @@ -5122,6 +5287,218 @@ "WINDOWS" ] }, + "spider.Price": { + "type": "object", + "required": [ + "priceInfo", + "productInfo" + ], + "properties": { + "priceInfo": { + "description": "Pricing details of the product", + "allOf": [ + { + "$ref": "#/definitions/spider.PriceInfo" + } + ] + }, + "productInfo": { + "description": "Information about the product", + "allOf": [ + { + "$ref": "#/definitions/spider.ProductInfo" + } + ] + } + } + }, + "spider.PriceInfo": { + "type": "object", + "required": [ + "cspPriceInfo", + "pricingPolicies" + ], + "properties": { + "cspPriceInfo": { + "description": "Additional price information specific to CSP" + }, + "pricingPolicies": { + "description": "List of pricing policies", + "type": "array", + "items": { + "$ref": "#/definitions/spider.PricingPolicies" + } + } + } + }, + "spider.PricingPolicies": { + "type": "object", + "required": [ + "currency", + "price", + "pricingId", + "pricingPolicy", + "unit" + ], + "properties": { + "currency": { + "description": "Currency of the pricing", + "type": "string", + "example": "USD" + }, + "description": { + "description": "Description of the pricing policy", + "type": "string", + "example": "Pricing for t2.micro" + }, + "price": { + "description": "Price in the specified currency per unit", + "type": "string", + "example": "0.02" + }, + "pricingId": { + "description": "ID of the pricing policy", + "type": "string", + "example": "price-123" + }, + "pricingPolicy": { + "description": "Name of the pricing policy", + "type": "string", + "example": "On-Demand" + }, + "pricingPolicyInfo": { + "description": "Detail information about the pricing policy", + "allOf": [ + { + "$ref": "#/definitions/spider.PricingPolicyInfo" + } + ] + }, + "unit": { + "description": "Unit of the pricing (e.g., per hour)", + "type": "string", + "example": "hour" + } + } + }, + "spider.PricingPolicyInfo": { + "type": "object", + "properties": { + "LeaseContractLength": { + "description": "Length of the lease contract", + "type": "string", + "example": "1 year" + }, + "OfferingClass": { + "description": "Offering class (e.g., standard, convertible)", + "type": "string", + "example": "standard" + }, + "PurchaseOption": { + "description": "Purchase option (e.g., no upfront, partial upfront)", + "type": "string", + "example": "No Upfront" + } + } + }, + "spider.ProductInfo": { + "type": "object", + "required": [ + "cspProductInfo", + "productId", + "regionName" + ], + "properties": { + "cspProductInfo": { + "description": "Additional product information specific to CSP" + }, + "description": { + "description": "Description of the product", + "type": "string", + "example": "General purpose instance" + }, + "gpu": { + "description": "Number of GPUs", + "type": "string", + "example": "1" + }, + "gpuMemory": { + "description": "GPU memory size in MB", + "type": "string", + "example": "8192" + }, + "instanceType": { + "description": "--------- Compute Instance Info", + "type": "string", + "example": "t2.micro" + }, + "maxIopsvolume": { + "description": "Maximum IOPS for the volume", + "type": "string", + "example": "3000" + }, + "maxThroughputvolume": { + "description": "Maximum throughput for the volume in MB/s", + "type": "string", + "example": "250" + }, + "maxVolumeSize": { + "description": "Maximum volume size in GB", + "type": "string", + "example": "16384" + }, + "memory": { + "description": "Amount of memory in MB", + "type": "string", + "example": "4096" + }, + "operatingSystem": { + "description": "Operating system type", + "type": "string", + "example": "Linux" + }, + "preInstalledSw": { + "description": "Pre-installed software", + "type": "string", + "example": "None" + }, + "productId": { + "description": "ID of the product", + "type": "string", + "example": "prod-123" + }, + "regionName": { + "description": "Name of the region", + "type": "string", + "example": "us-east-1" + }, + "storage": { + "description": "Root-disk storage size in GB", + "type": "string", + "example": "100" + }, + "storageMedia": { + "description": "Storage media type", + "type": "string", + "example": "SSD" + }, + "vcpu": { + "description": "Number of vCPUs", + "type": "string", + "example": "2" + }, + "volumeType": { + "description": "--------- Storage Info // Data-Disk(AWS:EBS)", + "type": "string", + "example": "gp2" + }, + "zoneName": { + "description": "Name of the zone", + "type": "string", + "example": "us-east-1a" + } + } + }, "spider.RegionInfo": { "type": "object", "required": [ @@ -6328,6 +6705,55 @@ } } }, + "spider.PriceInfoRequest": { + "type": "object", + "required": [ + "connectionName" + ], + "properties": { + "connectionName": { + "type": "string" + }, + "filterList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + } + } + }, + "spider.PriceInfoResponse": { + "type": "object", + "required": [ + "cloudPriceList", + "meta" + ], + "properties": { + "cloudPriceList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.CloudPrice" + } + }, + "meta": { + "$ref": "#/definitions/spider.Meta" + } + } + }, + "spider.ProductFamilyListResponse": { + "type": "object", + "required": [ + "productfamily" + ], + "properties": { + "productfamily": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "spider.RegionZoneListResponse": { "type": "object", "required": [ diff --git a/api/swagger.yaml b/api/swagger.yaml index 760dbcd6d..fbf3d4902 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1,5 +1,20 @@ basePath: /spider definitions: + spider.CloudPrice: + properties: + cloudName: + description: Name of the cloud provider + example: AWS + type: string + priceList: + description: List of prices for different services/products + items: + $ref: '#/definitions/spider.Price' + type: array + required: + - cloudName + - priceList + type: object spider.DiskInfo: properties: CreatedTime: @@ -171,6 +186,19 @@ definitions: required: - Key type: object + spider.Meta: + properties: + description: + description: Description of the pricing data + example: Cloud price data + type: string + version: + description: Version of the pricing data + example: "1.0" + type: string + required: + - version + type: object spider.MyImageInfo: properties: CreatedTime: @@ -215,6 +243,162 @@ definitions: x-enum-varnames: - LINUX_UNIX - WINDOWS + spider.Price: + properties: + priceInfo: + allOf: + - $ref: '#/definitions/spider.PriceInfo' + description: Pricing details of the product + productInfo: + allOf: + - $ref: '#/definitions/spider.ProductInfo' + description: Information about the product + required: + - priceInfo + - productInfo + type: object + spider.PriceInfo: + properties: + cspPriceInfo: + description: Additional price information specific to CSP + pricingPolicies: + description: List of pricing policies + items: + $ref: '#/definitions/spider.PricingPolicies' + type: array + required: + - cspPriceInfo + - pricingPolicies + type: object + spider.PricingPolicies: + properties: + currency: + description: Currency of the pricing + example: USD + type: string + description: + description: Description of the pricing policy + example: Pricing for t2.micro + type: string + price: + description: Price in the specified currency per unit + example: "0.02" + type: string + pricingId: + description: ID of the pricing policy + example: price-123 + type: string + pricingPolicy: + description: Name of the pricing policy + example: On-Demand + type: string + pricingPolicyInfo: + allOf: + - $ref: '#/definitions/spider.PricingPolicyInfo' + description: Detail information about the pricing policy + unit: + description: Unit of the pricing (e.g., per hour) + example: hour + type: string + required: + - currency + - price + - pricingId + - pricingPolicy + - unit + type: object + spider.PricingPolicyInfo: + properties: + LeaseContractLength: + description: Length of the lease contract + example: 1 year + type: string + OfferingClass: + description: Offering class (e.g., standard, convertible) + example: standard + type: string + PurchaseOption: + description: Purchase option (e.g., no upfront, partial upfront) + example: No Upfront + type: string + type: object + spider.ProductInfo: + properties: + cspProductInfo: + description: Additional product information specific to CSP + description: + description: Description of the product + example: General purpose instance + type: string + gpu: + description: Number of GPUs + example: "1" + type: string + gpuMemory: + description: GPU memory size in MB + example: "8192" + type: string + instanceType: + description: '--------- Compute Instance Info' + example: t2.micro + type: string + maxIopsvolume: + description: Maximum IOPS for the volume + example: "3000" + type: string + maxThroughputvolume: + description: Maximum throughput for the volume in MB/s + example: "250" + type: string + maxVolumeSize: + description: Maximum volume size in GB + example: "16384" + type: string + memory: + description: Amount of memory in MB + example: "4096" + type: string + operatingSystem: + description: Operating system type + example: Linux + type: string + preInstalledSw: + description: Pre-installed software + example: None + type: string + productId: + description: ID of the product + example: prod-123 + type: string + regionName: + description: Name of the region + example: us-east-1 + type: string + storage: + description: Root-disk storage size in GB + example: "100" + type: string + storageMedia: + description: Storage media type + example: SSD + type: string + vcpu: + description: Number of vCPUs + example: "2" + type: string + volumeType: + description: '--------- Storage Info // Data-Disk(AWS:EBS)' + example: gp2 + type: string + zoneName: + description: Name of the zone + example: us-east-1a + type: string + required: + - cspProductInfo + - productId + - regionName + type: object spider.RegionInfo: properties: Region: @@ -1056,6 +1240,38 @@ definitions: required: - ZoneInfo type: object + spider.PriceInfoRequest: + properties: + connectionName: + type: string + filterList: + items: + $ref: '#/definitions/spider.KeyValue' + type: array + required: + - connectionName + type: object + spider.PriceInfoResponse: + properties: + cloudPriceList: + items: + $ref: '#/definitions/spider.CloudPrice' + type: array + meta: + $ref: '#/definitions/spider.Meta' + required: + - cloudPriceList + - meta + type: object + spider.ProductFamilyListResponse: + properties: + productfamily: + items: + type: string + type: array + required: + - productfamily + type: object spider.RegionZoneListResponse: properties: regionzone: @@ -3098,6 +3314,94 @@ paths: summary: Get Pre-configured Region Zone tags: - '[Cloud Metadata] Region/Zone' + /priceinfo/{ProductFamily}/{RegionName}: + post: + consumes: + - application/json + description: 'Retrieve price details of a specific Product Family in a specific + Region.
* example body: {"connectionName":"aws-connection","FilterList":[{"Key":"instanceType","Value":"t2.micro"}]}' + operationId: get-price-info + parameters: + - description: The name of the Product Family to retrieve price information + for + example: '"Compute Instance"' + in: path + name: ProductFamily + required: true + type: string + - description: The name of the Region to retrieve price information for + example: '"us-east-1"' + in: path + name: RegionName + required: true + type: string + - description: The request body containing additional filters for price information + in: body + name: PriceInfoRequest + schema: + $ref: '#/definitions/spider.PriceInfoRequest' + produces: + - application/json + responses: + "200": + description: Price Information Details + schema: + $ref: '#/definitions/spider.PriceInfoResponse' + "400": + description: Bad Request, possibly due to invalid query parameter + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Get Price Information + tags: + - '[Cloud Metadata] Price' + /productfamily/{RegionName}: + get: + consumes: + - application/json + description: Retrieve a list of Product Families associated with a specific + connection and region. + operationId: list-product-family + parameters: + - description: The name of the Connection to list Product Families for + in: query + name: ConnectionName + required: true + type: string + - description: The name of the Region to list Product Families for + in: path + name: RegionName + required: true + type: string + produces: + - application/json + responses: + "200": + description: List of Product Families + schema: + $ref: '#/definitions/spider.ProductFamilyListResponse' + "400": + description: Bad Request, possibly due to invalid query parameter + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: List Product Families + tags: + - '[Cloud Metadata] Price' /regdisk: post: consumes: diff --git a/cloud-control-manager/cloud-driver/interfaces/resources/PriceInfoHandler.go b/cloud-control-manager/cloud-driver/interfaces/resources/PriceInfoHandler.go index bb356236f..9bd017f53 100644 --- a/cloud-control-manager/cloud-driver/interfaces/resources/PriceInfoHandler.go +++ b/cloud-control-manager/cloud-driver/interfaces/resources/PriceInfoHandler.go @@ -10,73 +10,79 @@ package resources +// CloudPriceData represents the structure of cloud pricing data. type CloudPriceData struct { - Meta Meta `json:"meta"` - CloudPriceList []CloudPrice `json:"cloudPriceList"` + Meta Meta `json:"meta" validate:"required" description:"Metadata information about the price data"` + CloudPriceList []CloudPrice `json:"cloudPriceList" validate:"required" description:"List of cloud prices"` } +// Meta contains metadata information about the price data. type Meta struct { - Version string `json:"version"` - Description string `json:"description"` + Version string `json:"version" validate:"required" example:"1.0"` // Version of the pricing data + Description string `json:"description,omitempty" example:"Cloud price data"` // Description of the pricing data } +// CloudPrice represents the pricing information for a specific cloud provider. type CloudPrice struct { - CloudName string `json:"cloudName"` - PriceList []Price `json:"priceList"` + CloudName string `json:"cloudName" validate:"required" example:"AWS"` // Name of the cloud provider + PriceList []Price `json:"priceList" validate:"required" description:"List of prices"` // List of prices for different services/products } +// Price represents the price information for a specific product. type Price struct { - ProductInfo ProductInfo `json:"productInfo"` - PriceInfo PriceInfo `json:"priceInfo"` + ProductInfo ProductInfo `json:"productInfo" validate:"required" description:"Information about the product"` // Information about the product + PriceInfo PriceInfo `json:"priceInfo" validate:"required" description:"Pricing details of the product"` // Pricing details of the product } +// ProductInfo represents the product details. type ProductInfo struct { - ProductId string `json:"productId"` - RegionName string `json:"regionName"` - ZoneName string `json:"zoneName"` + ProductId string `json:"productId" validate:"required" example:"prod-123"` // ID of the product + RegionName string `json:"regionName" validate:"required" example:"us-east-1"` // Name of the region + ZoneName string `json:"zoneName,omitempty" example:"us-east-1a"` // Name of the zone - //--------- Compute Instance - InstanceType string `json:"instanceType,omitempty"` - Vcpu string `json:"vcpu,omitempty"` - Memory string `json:"memory,omitempty"` - Storage string `json:"storage,omitempty"` // Root-Disk - Gpu string `json:"gpu,omitempty"` - GpuMemory string `json:"gpuMemory,omitempty"` - OperatingSystem string `json:"operatingSystem,omitempty"` - PreInstalledSw string `json:"preInstalledSw,omitempty"` - //--------- Compute Instance + //--------- Compute Instance Info + InstanceType string `json:"instanceType,omitempty" example:"t2.micro"` // Type of the instance + Vcpu string `json:"vcpu,omitempty" example:"2"` // Number of vCPUs + Memory string `json:"memory,omitempty" example:"4096"` // Amount of memory in MB + Storage string `json:"storage,omitempty" example:"100"` // Root-disk storage size in GB + Gpu string `json:"gpu,omitempty" example:"1"` // Number of GPUs + GpuMemory string `json:"gpuMemory,omitempty" example:"8192"` // GPU memory size in MB + OperatingSystem string `json:"operatingSystem,omitempty" example:"Linux"` // Operating system type + PreInstalledSw string `json:"preInstalledSw,omitempty" example:"None"` // Pre-installed software - //--------- Storage // Data-Disk(AWS:EBS) - VolumeType string `json:"volumeType,omitempty"` - StorageMedia string `json:"storageMedia,omitempty"` - MaxVolumeSize string `json:"maxVolumeSize,omitempty"` - MaxIOPSVolume string `json:"maxIopsvolume,omitempty"` - MaxThroughputVolume string `json:"maxThroughputvolume,omitempty"` - //--------- Storage // Data-Disk(AWS:EBS) + //--------- Storage Info // Data-Disk(AWS:EBS) + VolumeType string `json:"volumeType,omitempty" example:"gp2"` // Type of volume + StorageMedia string `json:"storageMedia,omitempty" example:"SSD"` // Storage media type + MaxVolumeSize string `json:"maxVolumeSize,omitempty" example:"16384"` // Maximum volume size in GB + MaxIOPSVolume string `json:"maxIopsvolume,omitempty" example:"3000"` // Maximum IOPS for the volume + MaxThroughputVolume string `json:"maxThroughputvolume,omitempty" example:"250"` // Maximum throughput for the volume in MB/s - Description string `json:"description"` - CSPProductInfo interface{} `json:"cspProductInfo"` + Description string `json:"description,omitempty" example:"General purpose instance"` // Description of the product + CSPProductInfo interface{} `json:"cspProductInfo" validate:"required" description:"Additional product info"` // Additional product information specific to CSP } +// PriceInfo represents the pricing details for a product. type PriceInfo struct { - PricingPolicies []PricingPolicies `json:"pricingPolicies"` - CSPPriceInfo interface{} `json:"cspPriceInfo"` + PricingPolicies []PricingPolicies `json:"pricingPolicies" validate:"required" description:"List of pricing policies"` // List of pricing policies + CSPPriceInfo interface{} `json:"cspPriceInfo" validate:"required" description:"Additional price info"` // Additional price information specific to CSP } +// PricingPolicies represents a single pricing policy. type PricingPolicies struct { - PricingId string `json:"pricingId"` - PricingPolicy string `json:"pricingPolicy"` - Unit string `json:"unit"` - Currency string `json:"currency"` - Price string `json:"price"` - Description string `json:"description"` - PricingPolicyInfo *PricingPolicyInfo `json:"pricingPolicyInfo,omitempty"` + PricingId string `json:"pricingId" validate:"required" example:"price-123"` // ID of the pricing policy + PricingPolicy string `json:"pricingPolicy" validate:"required" example:"On-Demand"` // Name of the pricing policy + Unit string `json:"unit" validate:"required" example:"hour"` // Unit of the pricing (e.g., per hour) + Currency string `json:"currency" validate:"required" example:"USD"` // Currency of the pricing + Price string `json:"price" validate:"required" example:"0.02"` // Price in the specified currency per unit + Description string `json:"description,omitempty" example:"Pricing for t2.micro"` // Description of the pricing policy + PricingPolicyInfo *PricingPolicyInfo `json:"pricingPolicyInfo" description:"Detailed info about pricing"` // Detail information about the pricing policy } +// PricingPolicyInfo represents additional details about a pricing policy. type PricingPolicyInfo struct { - LeaseContractLength string `json:"LeaseContractLength"` - OfferingClass string `json:"OfferingClass"` - PurchaseOption string `json:"PurchaseOption"` + LeaseContractLength string `json:"LeaseContractLength,omitempty" example:"1 year"` // Length of the lease contract + OfferingClass string `json:"OfferingClass,omitempty" example:"standard"` // Offering class (e.g., standard, convertible) + PurchaseOption string `json:"PurchaseOption,omitempty" example:"No Upfront"` // Purchase option (e.g., no upfront, partial upfront) } type PriceInfoHandler interface {