{
    "swagger": "2.0",
    "info": {
        "description": "This is a billing system server",
        "title": "Billing System OPENAPI",
        "contact": {},
        "version": "v1beta1"
    },
    "host": "billing.tidbapi.com",
    "basePath": "/v1beta1",
    "paths": {
        "/bills/{billedMonth}": {
            "get": {
                "description": "This endpoint retrieves the bill for the given month of a specific organization. You can query a bill up to 6 months prior to the current month. The bill is returned in JSON format.To use this resource, the requesting API Key must have the Organization Billing Admin or Organization Owner role.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return organization monthly bills",
                "parameters": [
                    {
                        "type": "string",
                        "description": "The month of this bill happens for the specified organization, format is YYYY-MM, for example '2023-08'.",
                        "name": "billedMonth",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsExplorer"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsCostExplorer": {
            "post": {
                "description": "This endpoint executes a cost explorer query and returns the usage details. Cost Explorer query:",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Get the usage details according to a cost explorer query",
                "parameters": [
                    {
                        "description": "args",
                        "name": "args",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/forms.TrendsInput"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsCostExplorer"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsCostExplorer/args": {
            "get": {
                "description": "This endpoint retrieves the basic info for a specific organization, including service info, cloud provider info, project info, and cluster info.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return basic info of a specific organization, which contains the key info to execute a cost explorer query",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.TrendsArgs"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsDetails/{billedMonth}": {
            "get": {
                "description": "This endpoint retrieves the bill for the given month of a specific organization with daily usage details. You can query a bill up to 6 months prior to the current month. The bill is returned in JSON format. To use this resource, the requesting API Key must have the Organization Billing Admin or Organization Owner role.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Get the monthly bill of the organization with daily usage details",
                "parameters": [
                    {
                        "type": "string",
                        "description": "The month of this bill happens for the specified organization. The format is `YYYY-MM`, for example '2024-05'.",
                        "name": "billedMonth",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsDetails"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "billing_errors.BaseError": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string"
                },
                "error": {},
                "msgPrefix": {
                    "type": "string"
                },
                "status": {
                    "type": "integer"
                }
            }
        },
        "forms.BillsCostExplorer": {
            "type": "object",
            "properties": {
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "elements": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsCostExplorerElements"
                    }
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsCostExplorerBreakdown": {
            "type": "object",
            "properties": {
                "billedDate": {
                    "type": "string"
                },
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "detailKey": {
                    "type": "string"
                },
                "detailName": {
                    "type": "string"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsCostExplorerElements": {
            "type": "object",
            "properties": {
                "billedDate": {
                    "type": "string"
                },
                "breakdown": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsCostExplorerBreakdown"
                    }
                },
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsDetail": {
            "type": "object",
            "properties": {
                "billedDate": {
                    "description": "The date when this bill happens.",
                    "type": "string"
                },
                "clusterName": {
                    "description": "Name of the cluster.",
                    "type": "string"
                },
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "projectName": {
                    "description": "Name of the project.",
                    "type": "string"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "servicePathName": {
                    "description": "Name of the service.",
                    "type": "string"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsDetails": {
            "type": "object",
            "properties": {
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsDetail"
                    }
                }
            }
        },
        "forms.BillsExplorer": {
            "type": "object",
            "properties": {
                "overview": {
                    "description": "The overall information for a bill in the specified organization.",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.BillsOverview"
                        }
                    ]
                },
                "summaryByProject": {
                    "description": "A breakdown of the bill by project.",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.SummaryByProject"
                        }
                    ]
                },
                "summaryByService": {
                    "description": "A breakdown of the bill by service.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsServiceCosts"
                    }
                }
            }
        },
        "forms.BillsOtherName": {
            "type": "object",
            "properties": {
                "chargeName": {
                    "type": "string",
                    "example": "Support Plan"
                },
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsOverview": {
            "type": "object",
            "properties": {
                "billedMonth": {
                    "description": "The month in which this bill is generated for the specified organization.",
                    "type": "string",
                    "example": "2023-09"
                },
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsProjects": {
            "type": "object",
            "properties": {
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "projectName": {
                    "description": "The name of a project in the specified organization.",
                    "type": "string",
                    "example": "prod-project"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsServiceCosts": {
            "type": "object",
            "properties": {
                "credits": {
                    "description": "The total credits held by the organization in this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "discounts": {
                    "description": "The total amount of discounts applied to this bill. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "runningTotal": {
                    "description": "The sum of services that the specified organization has consumed during this bill period. The value of this field is expressed in cents (100ths of one US Dollar).",
                    "type": "string",
                    "example": "0.00"
                },
                "serviceCosts": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsServiceCosts"
                    }
                },
                "serviceName": {
                    "description": "The name of services provided by TiDB Cloud.",
                    "type": "string",
                    "example": "TiDB Dedicated"
                },
                "totalCost": {
                    "description": "The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.ClusterOpenAPI": {
            "type": "object",
            "properties": {
                "ProjectID": {
                    "type": "string",
                    "example": "0"
                },
                "id": {
                    "type": "string",
                    "example": "0"
                },
                "name": {
                    "type": "string"
                },
                "regionName": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                }
            }
        },
        "forms.CostExplorerProvider": {
            "type": "object",
            "properties": {
                "name": {
                    "description": "The name of the cloud provider to include in the query.",
                    "type": "string"
                },
                "regions": {
                    "description": "A list of region names to include in the query.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "forms.CostExplorerService": {
            "type": "object",
            "properties": {
                "category": {
                    "description": "The service category name (second level).",
                    "type": "string"
                },
                "component": {
                    "description": "The service component name (third level).",
                    "type": "string"
                },
                "product": {
                    "description": "The service product name (first level).",
                    "type": "string"
                },
                "service": {
                    "description": "The full service name, typically combining all levels.",
                    "type": "string"
                }
            }
        },
        "forms.CostExplorerTrendsBreakdownKey": {
            "type": "string",
            "enum": [
                "service",
                "product",
                "project",
                "cluster",
                "provider",
                "region",
                "customer"
            ],
            "x-enum-varnames": [
                "CostExploreTrendsBreakdownKeyService",
                "CostExploreTrendsBreakdownKeyProduct",
                "CostExploreTrendsBreakdownKeyProject",
                "CostExploreTrendsBreakdownKeyCluster",
                "CostExploreTrendsBreakdownKeyProvider",
                "CostExploreTrendsBreakdownKeyRegion",
                "CostExploreTrendsBreakdownKeyCustomer"
            ]
        },
        "forms.CostExplorerTrendsTimeGroup": {
            "type": "string",
            "enum": [
                "day",
                "month",
                "total"
            ],
            "x-enum-varnames": [
                "CostExploreTrendsTimeGroupDay",
                "CostExploreTrendsTimeGroupMonth",
                "CostExploreTrendsTimeGroupTotal"
            ]
        },
        "forms.Groups": {
            "type": "object",
            "properties": {
                "groupBy": {
                    "description": "Specifies categories for grouping query results. Value options are:\n- \"service\": Group query results by service type\n- \"product\": Group query results by product type (TiDB Dedicated, TiDB Serverless, or Support Plan)\n- \"project\": Group query results by project IDs\n- \"cluster\": Group query results by cluster IDs\n- \"provider\": Group query results by cloud provider\n- \"region\": Group query results by cloud provider region",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerTrendsBreakdownKey"
                    }
                },
                "timeGranularity": {
                    "description": "Determines the time-based organization of query results. Value options are:\n- \"day\": Query results are organized daily\n- \"month\": Query results are organized monthly\n- \"total\": Query results are organized as a single total",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.CostExplorerTrendsTimeGroup"
                        }
                    ]
                }
            }
        },
        "forms.ProjectOpenAPI": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string",
                    "example": "0"
                },
                "name": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                }
            }
        },
        "forms.Provider": {
            "type": "object",
            "properties": {
                "name": {
                    "description": "Name of the cloud provider",
                    "type": "string"
                },
                "regions": {
                    "description": "Name of the region",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "forms.SummaryByProject": {
            "type": "object",
            "properties": {
                "otherCharges": {
                    "description": "These charges occur not only within a project but also across the entire organization.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsOtherName"
                    }
                },
                "projects": {
                    "description": "The projects in the specified organization.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsProjects"
                    }
                }
            }
        },
        "forms.TimeRange": {
            "type": "object",
            "properties": {
                "endDate": {
                    "description": "The end date of the time range. The time format follows the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. For example: `\"2023-12-01T00:00:00Z\"`.",
                    "type": "string"
                },
                "startDate": {
                    "description": "The start date of the time range. The time format follows the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. For example: `\"2023-12-01T00:00:00Z\"`.",
                    "type": "string"
                }
            }
        },
        "forms.TrendsArgs": {
            "type": "object",
            "properties": {
                "clusters": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.ClusterOpenAPI"
                    }
                },
                "projects": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.ProjectOpenAPI"
                    }
                },
                "providers": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.Provider"
                    }
                },
                "services": {
                    "description": "The Identifier of TiDB Cloud services consists of 3 levels. For example, \"service\": \"TiDB Dedicated - Node Compute - TiFlash\" consists of the following 3 levels.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerService"
                    }
                }
            }
        },
        "forms.TrendsFilter": {
            "type": "object",
            "properties": {
                "clusters": {
                    "description": "A list of cluster IDs to include in the query.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "customers": {
                    "description": "\"A list of customer IDs to include in the query.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "projects": {
                    "description": "A list of project IDs to include in the query.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "providers": {
                    "description": "A list of providers to include in the query.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerProvider"
                    }
                },
                "services": {
                    "description": "A list of TiDB Cloud services to include in the query.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerService"
                    }
                },
                "timeRange": {
                    "description": "The time period for the query.",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.TimeRange"
                        }
                    ]
                }
            }
        },
        "forms.TrendsInput": {
            "type": "object",
            "properties": {
                "filter": {
                    "$ref": "#/definitions/forms.TrendsFilter"
                },
                "groups": {
                    "$ref": "#/definitions/forms.Groups"
                }
            }
        }
    }
}