diff --git a/internal/client/planetscale/planetscale.go b/internal/client/planetscale/planetscale.go index 406b5dd..27770a7 100644 --- a/internal/client/planetscale/planetscale.go +++ b/internal/client/planetscale/planetscale.go @@ -117,9 +117,9 @@ type DataImport struct { State string `json:"state" tfsdk:"state"` } type DataSource struct { - Database string `json:"database" tfsdk:"database"` - Hostname string `json:"hostname" tfsdk:"hostname"` - Port string `json:"port" tfsdk:"port"` + Database string `json:"database" tfsdk:"database"` + Hostname string `json:"hostname" tfsdk:"hostname"` + Port float64 `json:"port" tfsdk:"port"` } type Database struct { AllowDataBranching bool `json:"allow_data_branching" tfsdk:"allow_data_branching"` @@ -2159,6 +2159,399 @@ func (cl *Client) RenewPassword(ctx context.Context, organization string, databa return res200, err } +type ListGeneratedQueryPatternsReportsRes_DataItem struct { + ActorId string `json:"actor_id" tfsdk:"actor_id"` + ActorType string `json:"actor_type" tfsdk:"actor_type"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DownloadUrl string `json:"download_url" tfsdk:"download_url"` + FinishedAt string `json:"finished_at" tfsdk:"finished_at"` + Id string `json:"id" tfsdk:"id"` + State string `json:"state" tfsdk:"state"` + Url string `json:"url" tfsdk:"url"` +} +type ListGeneratedQueryPatternsReportsRes struct { + CursorEnd string `json:"cursor_end" tfsdk:"cursor_end"` + CursorStart string `json:"cursor_start" tfsdk:"cursor_start"` + Data []ListGeneratedQueryPatternsReportsRes_DataItem `json:"data" tfsdk:"data"` + HasNext bool `json:"has_next" tfsdk:"has_next"` + HasPrev bool `json:"has_prev" tfsdk:"has_prev"` +} +type ListGeneratedQueryPatternsReportsRes401 struct { + *ErrorResponse +} +type ListGeneratedQueryPatternsReportsRes403 struct { + *ErrorResponse +} +type ListGeneratedQueryPatternsReportsRes404 struct { + *ErrorResponse +} +type ListGeneratedQueryPatternsReportsRes500 struct { + *ErrorResponse +} + +func (cl *Client) ListGeneratedQueryPatternsReports(ctx context.Context, organization string, database string, branch string) (res200 *ListGeneratedQueryPatternsReportsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/query-patterns"}) + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(ListGeneratedQueryPatternsReportsRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(ListGeneratedQueryPatternsReportsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ListGeneratedQueryPatternsReportsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ListGeneratedQueryPatternsReportsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ListGeneratedQueryPatternsReportsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + +type CreateQueryPatternsReportRes struct { + ActorId string `json:"actor_id" tfsdk:"actor_id"` + ActorType string `json:"actor_type" tfsdk:"actor_type"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DownloadUrl string `json:"download_url" tfsdk:"download_url"` + FinishedAt string `json:"finished_at" tfsdk:"finished_at"` + Id string `json:"id" tfsdk:"id"` + State string `json:"state" tfsdk:"state"` + Url string `json:"url" tfsdk:"url"` +} +type CreateQueryPatternsReportRes401 struct { + *ErrorResponse +} +type CreateQueryPatternsReportRes403 struct { + *ErrorResponse +} +type CreateQueryPatternsReportRes404 struct { + *ErrorResponse +} +type CreateQueryPatternsReportRes500 struct { + *ErrorResponse +} + +func (cl *Client) CreateQueryPatternsReport(ctx context.Context, organization string, database string, branch string) (res201 *CreateQueryPatternsReportRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/query-patterns"}) + r, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil) + if err != nil { + return res201, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res201, err + } + defer res.Body.Close() + switch res.StatusCode { + case 201: + res201 = new(CreateQueryPatternsReportRes) + err = json.NewDecoder(res.Body).Decode(&res201) + case 401: + res401 := new(CreateQueryPatternsReportRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CreateQueryPatternsReportRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CreateQueryPatternsReportRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CreateQueryPatternsReportRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res201, err +} + +type GetQueryPatternsReportStatusRes struct { + ActorId string `json:"actor_id" tfsdk:"actor_id"` + ActorType string `json:"actor_type" tfsdk:"actor_type"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DownloadUrl string `json:"download_url" tfsdk:"download_url"` + FinishedAt string `json:"finished_at" tfsdk:"finished_at"` + Id string `json:"id" tfsdk:"id"` + State string `json:"state" tfsdk:"state"` + Url string `json:"url" tfsdk:"url"` +} +type GetQueryPatternsReportStatusRes401 struct { + *ErrorResponse +} +type GetQueryPatternsReportStatusRes403 struct { + *ErrorResponse +} +type GetQueryPatternsReportStatusRes404 struct { + *ErrorResponse +} +type GetQueryPatternsReportStatusRes500 struct { + *ErrorResponse +} + +func (cl *Client) GetQueryPatternsReportStatus(ctx context.Context, organization string, database string, branch string, id string) (res200 *GetQueryPatternsReportStatusRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/query-patterns/" + id}) + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(GetQueryPatternsReportStatusRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(GetQueryPatternsReportStatusRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetQueryPatternsReportStatusRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetQueryPatternsReportStatusRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetQueryPatternsReportStatusRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + +type DeleteQueryPatternsReportRes struct{} +type DeleteQueryPatternsReportRes401 struct { + *ErrorResponse +} +type DeleteQueryPatternsReportRes403 struct { + *ErrorResponse +} +type DeleteQueryPatternsReportRes404 struct { + *ErrorResponse +} +type DeleteQueryPatternsReportRes500 struct { + *ErrorResponse +} + +func (cl *Client) DeleteQueryPatternsReport(ctx context.Context, organization string, database string, branch string, id string) (res204 *DeleteQueryPatternsReportRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/query-patterns/" + id}) + r, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil) + if err != nil { + return res204, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res204, err + } + defer res.Body.Close() + switch res.StatusCode { + case 204: + res204 = new(DeleteQueryPatternsReportRes) + err = json.NewDecoder(res.Body).Decode(&res204) + case 401: + res401 := new(DeleteQueryPatternsReportRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(DeleteQueryPatternsReportRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(DeleteQueryPatternsReportRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(DeleteQueryPatternsReportRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res204, err +} + +type GetQueryPatternsReportRes struct { + ActorId string `json:"actor_id" tfsdk:"actor_id"` + ActorType string `json:"actor_type" tfsdk:"actor_type"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DownloadUrl string `json:"download_url" tfsdk:"download_url"` + FinishedAt string `json:"finished_at" tfsdk:"finished_at"` + Id string `json:"id" tfsdk:"id"` + State string `json:"state" tfsdk:"state"` + Url string `json:"url" tfsdk:"url"` +} +type GetQueryPatternsReportRes401 struct { + *ErrorResponse +} +type GetQueryPatternsReportRes403 struct { + *ErrorResponse +} +type GetQueryPatternsReportRes404 struct { + *ErrorResponse +} +type GetQueryPatternsReportRes500 struct { + *ErrorResponse +} + +func (cl *Client) GetQueryPatternsReport(ctx context.Context, organization string, database string, branch string, id string) (res302 *GetQueryPatternsReportRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/query-patterns/" + id + "/download"}) + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res302, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res302, err + } + defer res.Body.Close() + switch res.StatusCode { + case 302: + res302 = new(GetQueryPatternsReportRes) + err = json.NewDecoder(res.Body).Decode(&res302) + case 401: + res401 := new(GetQueryPatternsReportRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetQueryPatternsReportRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetQueryPatternsReportRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetQueryPatternsReportRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res302, err +} + type GetBranchRes struct { Branch } diff --git a/internal/provider/models_data_source.go b/internal/provider/models_data_source.go index e95e785..624f4a8 100644 --- a/internal/provider/models_data_source.go +++ b/internal/provider/models_data_source.go @@ -163,16 +163,16 @@ func flagsFromClient(flags *planetscale.Flags) *flagsDataSourceModel { } type dataSourceDataSourceModel struct { - Database types.String `tfsdk:"database"` - Hostname types.String `tfsdk:"hostname"` - Port types.String `tfsdk:"port"` + Database types.String `tfsdk:"database"` + Hostname types.String `tfsdk:"hostname"` + Port types.Float64 `tfsdk:"port"` } func dataSourceFromClient(dataSource planetscale.DataSource) dataSourceDataSourceModel { return dataSourceDataSourceModel{ Database: types.StringValue(dataSource.Database), Hostname: types.StringValue(dataSource.Hostname), - Port: types.StringValue(dataSource.Port), + Port: types.Float64Value(dataSource.Port), } } diff --git a/openapi-spec.json b/openapi-spec.json index 19dda46..e292f71 100644 --- a/openapi-spec.json +++ b/openapi-spec.json @@ -1810,6 +1810,512 @@ } } }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns": { + "get": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Query Insights reports" + ], + "summary": "List generated query patterns reports", + "operationId": "list_generated_query_patterns_reports", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Returns the generated query patterns reports", + "schema": { + "type": "object", + "required": [ + "has_next", + "has_prev", + "cursor_start", + "cursor_end", + "data" + ], + "properties": { + "cursor_end": { + "description": "The ID of the last audit log in the current results", + "type": "string" + }, + "cursor_start": { + "description": "The ID of the first audit log in the current results", + "type": "string" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ], + "properties": { + "actor_id": { + "description": "The ID of the actor that created the query patterns download", + "type": "string" + }, + "actor_type": { + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'", + "type": "string" + }, + "created_at": { + "description": "When the query patterns download was created", + "type": "string" + }, + "download_url": { + "description": "The URL to download the query patterns", + "type": "string" + }, + "finished_at": { + "description": "When the query patterns download was completed", + "type": "string" + }, + "id": { + "description": "The ID for the query patterns download", + "type": "string" + }, + "state": { + "description": "Whether the query patterns download is pending, completed, or failed", + "type": "string" + }, + "url": { + "description": "The URL with the status of the query patterns download", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "has_next": { + "description": "Whether there is a next page of results", + "type": "boolean" + }, + "has_prev": { + "description": "Whether there is a previous page of results", + "type": "boolean" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "post": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Query Insights reports" + ], + "summary": "Create a new query patterns report", + "operationId": "create_query_patterns_report", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "The created query patterns download", + "schema": { + "type": "object", + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ], + "properties": { + "actor_id": { + "description": "The ID of the actor that created the query patterns download", + "type": "string" + }, + "actor_type": { + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'", + "type": "string" + }, + "created_at": { + "description": "When the query patterns download was created", + "type": "string" + }, + "download_url": { + "description": "The URL to download the query patterns", + "type": "string" + }, + "finished_at": { + "description": "When the query patterns download was completed", + "type": "string" + }, + "id": { + "description": "The ID for the query patterns download", + "type": "string" + }, + "state": { + "description": "Whether the query patterns download is pending, completed, or failed", + "type": "string" + }, + "url": { + "description": "The URL with the status of the query patterns download", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}": { + "get": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Query Insights reports" + ], + "summary": "Show the status of a query patterns report", + "operationId": "get_query_patterns_report_status", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The ID of the query patterns report", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The retrieved query patterns download", + "schema": { + "type": "object", + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ], + "properties": { + "actor_id": { + "description": "The ID of the actor that created the query patterns download", + "type": "string" + }, + "actor_type": { + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'", + "type": "string" + }, + "created_at": { + "description": "When the query patterns download was created", + "type": "string" + }, + "download_url": { + "description": "The URL to download the query patterns", + "type": "string" + }, + "finished_at": { + "description": "When the query patterns download was completed", + "type": "string" + }, + "id": { + "description": "The ID for the query patterns download", + "type": "string" + }, + "state": { + "description": "Whether the query patterns download is pending, completed, or failed", + "type": "string" + }, + "url": { + "description": "The URL with the status of the query patterns download", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "delete": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Query Insights reports" + ], + "summary": "Delete a query patterns report", + "operationId": "delete_query_patterns_report", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The ID of the query patterns report", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Delete a query patterns report" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}/download": { + "get": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Query Insights reports" + ], + "summary": "Download a finished query patterns report", + "operationId": "get_query_patterns_report", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The ID of the query patterns report", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "302": { + "description": "Redirect to the query patterns download", + "schema": { + "type": "object", + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ], + "properties": { + "actor_id": { + "description": "The ID of the actor that created the query patterns download", + "type": "string" + }, + "actor_type": { + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'", + "type": "string" + }, + "created_at": { + "description": "When the query patterns download was created", + "type": "string" + }, + "download_url": { + "description": "The URL to download the query patterns", + "type": "string" + }, + "finished_at": { + "description": "When the query patterns download was completed", + "type": "string" + }, + "id": { + "description": "The ID for the query patterns download", + "type": "string" + }, + "state": { + "description": "Whether the query patterns download is pending, completed, or failed", + "type": "string" + }, + "url": { + "description": "The URL with the status of the query patterns download", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, "/organizations/{organization}/databases/{database}/branches/{name}": { "get": { "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`, `delete_branch`, `create_branch`, `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |", @@ -4035,7 +4541,7 @@ "type": "boolean" }, "restrict_branch_region": { - "description": "Whether or not to limit branch creation to the AWS us-east-1 region.", + "description": "Whether or not to limit branch creation to the same region as the one selected during database creation.", "type": "boolean" } }, @@ -5424,7 +5930,7 @@ "type": "string" }, "port": { - "type": "string" + "type": "number" } }, "additionalProperties": false @@ -7202,6 +7708,10 @@ "description": " API endpoints for managing organizations.\n", "name": "Organizations" }, + { + "description": " API endpoints for downloading query insights data.\n", + "name": "Query Insights reports" + }, { "description": " API endpoints for fetching user information.\n", "name": "Users" diff --git a/openapi/openapi-spec.json b/openapi/openapi-spec.json index 8787098..5f47d50 100644 --- a/openapi/openapi-spec.json +++ b/openapi/openapi-spec.json @@ -883,7 +883,7 @@ "type": "string" }, "port": { - "type": "string" + "type": "number" }, "database": { "type": "string" @@ -1198,7 +1198,7 @@ "type": "string" }, "port": { - "type": "string" + "type": "number" }, "database": { "type": "string" @@ -4488,6 +4488,517 @@ "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" } }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns": { + "get": { + "tags": [ + "Query Insights reports" + ], + "consumes": [ + "application/json" + ], + "operationId": "list_generated_query_patterns_reports", + "summary": "List generated query patterns reports", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Returns the generated query patterns reports", + "schema": { + "type": "object", + "properties": { + "has_next": { + "type": "boolean", + "description": "Whether there is a next page of results" + }, + "has_prev": { + "type": "boolean", + "description": "Whether there is a previous page of results" + }, + "cursor_start": { + "type": "string", + "description": "The ID of the first audit log in the current results" + }, + "cursor_end": { + "type": "string", + "description": "The ID of the last audit log in the current results" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the query patterns download" + }, + "actor_id": { + "type": "string", + "description": "The ID of the actor that created the query patterns download" + }, + "actor_type": { + "type": "string", + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'" + }, + "state": { + "type": "string", + "description": "Whether the query patterns download is pending, completed, or failed" + }, + "created_at": { + "type": "string", + "description": "When the query patterns download was created" + }, + "finished_at": { + "type": "string", + "description": "When the query patterns download was completed" + }, + "url": { + "type": "string", + "description": "The URL with the status of the query patterns download" + }, + "download_url": { + "type": "string", + "description": "The URL to download the query patterns" + } + }, + "additionalProperties": false, + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "has_next", + "has_prev", + "cursor_start", + "cursor_end", + "data" + ] + }, + "headers": {} + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |" + }, + "post": { + "tags": [ + "Query Insights reports" + ], + "consumes": [ + "application/json" + ], + "operationId": "create_query_patterns_report", + "summary": "Create a new query patterns report", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "201": { + "description": "The created query patterns download", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the query patterns download" + }, + "actor_id": { + "type": "string", + "description": "The ID of the actor that created the query patterns download" + }, + "actor_type": { + "type": "string", + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'" + }, + "state": { + "type": "string", + "description": "Whether the query patterns download is pending, completed, or failed" + }, + "created_at": { + "type": "string", + "description": "When the query patterns download was created" + }, + "finished_at": { + "type": "string", + "description": "When the query patterns download was completed" + }, + "url": { + "type": "string", + "description": "The URL with the status of the query patterns download" + }, + "download_url": { + "type": "string", + "description": "The URL to download the query patterns" + } + }, + "additionalProperties": false, + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ] + }, + "headers": {} + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |" + } + }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}": { + "get": { + "tags": [ + "Query Insights reports" + ], + "consumes": [ + "application/json" + ], + "operationId": "get_query_patterns_report_status", + "summary": "Show the status of a query patterns report", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + }, + { + "name": "id", + "type": "string", + "in": "path", + "required": true, + "description": "The ID of the query patterns report" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "The retrieved query patterns download", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the query patterns download" + }, + "actor_id": { + "type": "string", + "description": "The ID of the actor that created the query patterns download" + }, + "actor_type": { + "type": "string", + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'" + }, + "state": { + "type": "string", + "description": "Whether the query patterns download is pending, completed, or failed" + }, + "created_at": { + "type": "string", + "description": "When the query patterns download was created" + }, + "finished_at": { + "type": "string", + "description": "When the query patterns download was completed" + }, + "url": { + "type": "string", + "description": "The URL with the status of the query patterns download" + }, + "download_url": { + "type": "string", + "description": "The URL to download the query patterns" + } + }, + "additionalProperties": false, + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ] + }, + "headers": {} + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |" + }, + "delete": { + "tags": [ + "Query Insights reports" + ], + "consumes": [ + "application/json" + ], + "operationId": "delete_query_patterns_report", + "summary": "Delete a query patterns report", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + }, + { + "name": "id", + "type": "string", + "in": "path", + "required": true, + "description": "The ID of the query patterns report" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "204": { + "description": "Delete a query patterns report", + "headers": {} + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |" + } + }, + "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns/{id}/download": { + "get": { + "tags": [ + "Query Insights reports" + ], + "consumes": [ + "application/json" + ], + "operationId": "get_query_patterns_report", + "summary": "Download a finished query patterns report", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + }, + { + "name": "id", + "type": "string", + "in": "path", + "required": true, + "description": "The ID of the query patterns report" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "302": { + "description": "Redirect to the query patterns download", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the query patterns download" + }, + "actor_id": { + "type": "string", + "description": "The ID of the actor that created the query patterns download" + }, + "actor_type": { + "type": "string", + "description": "The ID of the actor that created the query patterns download. Such as 'User' or 'ServiceToken'" + }, + "state": { + "type": "string", + "description": "Whether the query patterns download is pending, completed, or failed" + }, + "created_at": { + "type": "string", + "description": "When the query patterns download was created" + }, + "finished_at": { + "type": "string", + "description": "When the query patterns download was completed" + }, + "url": { + "type": "string", + "description": "The URL with the status of the query patterns download" + }, + "download_url": { + "type": "string", + "description": "The URL to download the query patterns" + } + }, + "additionalProperties": false, + "required": [ + "id", + "actor_id", + "actor_type", + "state", + "created_at", + "finished_at", + "url", + "download_url" + ] + }, + "headers": {} + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |\n| Branch | `read_branch` |" + } + }, "/organizations/{organization}/databases/{database}/branches/{name}": { "get": { "tags": [ @@ -10575,7 +11086,7 @@ "type": "string" }, "port": { - "type": "string" + "type": "number" }, "database": { "type": "string" @@ -10807,7 +11318,7 @@ }, "restrict_branch_region": { "type": "boolean", - "description": "Whether or not to limit branch creation to the AWS us-east-1 region." + "description": "Whether or not to limit branch creation to the same region as the one selected during database creation." }, "allow_data_branching": { "type": "boolean", @@ -10910,7 +11421,7 @@ "type": "string" }, "port": { - "type": "string" + "type": "number" }, "database": { "type": "string" @@ -12771,6 +13282,10 @@ "name": "Organizations", "description": " API endpoints for managing organizations.\n" }, + { + "name": "Query Insights reports", + "description": " API endpoints for downloading query insights data.\n" + }, { "name": "Users", "description": " API endpoints for fetching user information.\n"