From 2fd21a838498e558b33179ca869e8663bd7d1bd2 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 17 Jun 2026 20:28:48 +0000 Subject: [PATCH] Regenerate client from commit 5371379 of spec repo --- .generator/schemas/v2/openapi.yaml | 519 ++++++++++++++++++ features/v2/governance_insights.feature | 24 + features/v2/undo.json | 6 + packages/datadog-api-client/README.md | 1 + .../src/support/scenarios_model_mapping.ts | 15 + services/governance_insights/.yarnrc.yml | 1 + services/governance_insights/README.md | 47 ++ services/governance_insights/package.json | 43 ++ services/governance_insights/src/index.ts | 3 + .../src/v2/GovernanceInsightsApi.ts | 260 +++++++++ services/governance_insights/src/v2/index.ts | 22 + .../src/v2/models/APIErrorResponse.ts | 45 ++ .../GovernanceBestPracticeDefinition.ts | 158 ++++++ .../v2/models/GovernanceInsightAttributes.ts | 210 +++++++ .../models/GovernanceInsightAuditCompute.ts | 72 +++ .../v2/models/GovernanceInsightAuditQuery.ts | 74 +++ .../src/v2/models/GovernanceInsightData.ts | 66 +++ .../models/GovernanceInsightEventCompute.ts | 55 ++ .../v2/models/GovernanceInsightEventQuery.ts | 64 +++ .../v2/models/GovernanceInsightMetricQuery.ts | 63 +++ .../GovernanceInsightPercentageQuery.ts | 56 ++ .../v2/models/GovernanceInsightQueryConfig.ts | 81 +++ .../models/GovernanceInsightResourceType.ts | 7 + .../v2/models/GovernanceInsightUsageQuery.ts | 54 ++ .../v2/models/GovernanceInsightsResponse.ts | 47 ++ .../src/v2/models/JSONAPIErrorItem.ts | 78 +++ .../src/v2/models/JSONAPIErrorItemSource.ts | 60 ++ .../src/v2/models/JSONAPIErrorResponse.ts | 47 ++ .../src/v2/models/TypingInfo.ts | 43 ++ services/governance_insights/tsconfig.json | 28 + yarn.lock | 9 + 31 files changed, 2258 insertions(+) create mode 100644 features/v2/governance_insights.feature create mode 100644 services/governance_insights/.yarnrc.yml create mode 100644 services/governance_insights/README.md create mode 100644 services/governance_insights/package.json create mode 100644 services/governance_insights/src/index.ts create mode 100644 services/governance_insights/src/v2/GovernanceInsightsApi.ts create mode 100644 services/governance_insights/src/v2/index.ts create mode 100644 services/governance_insights/src/v2/models/APIErrorResponse.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceBestPracticeDefinition.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightAttributes.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightAuditCompute.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightAuditQuery.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightData.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightEventCompute.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightEventQuery.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightMetricQuery.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightPercentageQuery.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightQueryConfig.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightResourceType.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightUsageQuery.ts create mode 100644 services/governance_insights/src/v2/models/GovernanceInsightsResponse.ts create mode 100644 services/governance_insights/src/v2/models/JSONAPIErrorItem.ts create mode 100644 services/governance_insights/src/v2/models/JSONAPIErrorItemSource.ts create mode 100644 services/governance_insights/src/v2/models/JSONAPIErrorResponse.ts create mode 100644 services/governance_insights/src/v2/models/TypingInfo.ts create mode 100644 services/governance_insights/tsconfig.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ed5cb6857f86..b17c8433bd55 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -41047,6 +41047,390 @@ components: - id - type type: object + GovernanceBestPracticeDefinition: + description: |- + The best practice associated with an insight. Populated with the first active best practice + matched to the insight; `null` when no best practice is attached. + properties: + category: + description: |- + The value driver the best practice is grouped under, such as `access_governance`, + `security`, `compliance`, or `operational_hygiene`. + example: "access_governance" + type: string + deep_link: + description: A relative link to the configuration page where the best practice can be acted upon. + example: "/organization-settings/users?status=inactive" + type: string + description: + description: The full rationale and guidance for the best practice. + example: "Review and deactivate users who have not logged in within the last 90 days." + type: string + detection_type: + description: An optional association to a control's detection type. `null` when not associated with a control. + example: + nullable: true + type: string + id: + description: The unique identifier of the best practice. + example: "bp_monitor_inactive_users" + type: string + impact: + description: The expected impact of following the best practice. + example: "Reduces unauthorized access risk." + type: string + impact_hint: + description: |- + A priority hint for ordering best practices by expected impact. Lower values indicate + higher priority. + example: 1 + format: int64 + type: integer + permissions: + description: The permissions required for the user to act on the best practice. + example: + - "user_access_manage" + items: + description: A permission required to act on the best practice. + type: string + type: array + status: + description: Whether the best practice is currently `active` or `deprecated`. + example: "active" + type: string + summary: + description: A one-line explanation of why this best practice matters. + example: "Inactive users with access increase your security surface area." + type: string + title: + description: A short, human-readable name for the best practice. + example: "Monitor inactive users" + type: string + trigger_condition: + description: |- + The condition that surfaces the best practice. For an `insight` trigger, the insight + slug; for a `static` trigger, a descriptive condition key. + example: "active_users" + type: string + trigger_type: + description: |- + How the best practice is surfaced. `insight` ties it to an insight; `static` surfaces it + unless its condition is met. + example: "insight" + type: string + required: + - id + - title + - summary + - description + - category + - impact + - trigger_type + - trigger_condition + - deep_link + - permissions + - impact_hint + - status + type: object + GovernanceInsightAttributes: + description: The attributes of a governance insight. + properties: + audit_query: + $ref: "#/components/schemas/GovernanceInsightAuditQuery" + nullable: true + best_practice: + $ref: "#/components/schemas/GovernanceBestPracticeDefinition" + nullable: true + deep_link: + description: A relative link to the product surface where the insight can be acted upon. + example: "" + type: string + description: + description: A human-readable description of what the insight measures. + example: "Number of users who have used the Dashboard in the last 30 days" + type: string + display_name: + description: Human-readable name of the insight. + example: "Active Dashboards" + type: string + event_query: + $ref: "#/components/schemas/GovernanceInsightEventQuery" + nullable: true + metric_query: + $ref: "#/components/schemas/GovernanceInsightMetricQuery" + nullable: true + old_value: + description: |- + The value of the insight over the previous comparison window. `null` when values were + not requested or could not be computed. + example: 3274 + format: double + nullable: true + type: number + percentage_query: + $ref: "#/components/schemas/GovernanceInsightPercentageQuery" + nullable: true + product: + description: The product the insight belongs to. + example: "Usage" + type: string + query_config: + $ref: "#/components/schemas/GovernanceInsightQueryConfig" + nullable: true + sort_order: + description: The relative order in which the insight should be displayed. + example: 1 + format: int64 + type: integer + state: + description: |- + The state of the insight. A `critical` insight receives extra UI treatment to draw + attention to it. + example: "critical" + type: string + sub_product: + description: The sub-product the insight belongs to, if any. + example: "Indexes" + type: string + time_range: + description: The time range the insight value is computed over, if applicable. + example: "month" + type: string + unit_name: + description: The unit that the insight's value is measured in. + example: "active dashboards" + type: string + usage_query: + $ref: "#/components/schemas/GovernanceInsightUsageQuery" + nullable: true + value: + description: The current value of the insight. `null` when values were not requested or could not be computed. + example: 3601 + format: double + nullable: true + type: number + required: + - display_name + - product + - best_practice + - sub_product + - unit_name + - description + - time_range + - state + - deep_link + - value + - old_value + - metric_query + - event_query + - usage_query + - audit_query + - percentage_query + type: object + GovernanceInsightAuditCompute: + description: The aggregation applied to an audit log query. + properties: + aggregation: + description: The aggregation function to apply. + example: "cardinality" + type: string + interval: + description: The aggregation time window, in milliseconds. + example: 86400000 + format: int64 + type: integer + metric: + description: The metric or attribute to aggregate. + example: "@usr.id" + type: string + rollup: + description: An optional secondary aggregation applied to the audit query result. + example: "" + type: string + required: + - aggregation + - metric + - interval + type: object + GovernanceInsightAuditQuery: + description: An audit log query used to compute an insight value. + properties: + compute: + $ref: "#/components/schemas/GovernanceInsightAuditCompute" + indexes: + description: The audit log indexes the query runs against. + example: + - "main" + items: + description: An audit log index name. + type: string + type: array + query: + description: The audit log search query string. + example: "@evt.name:Dashboard" + type: string + source: + description: The data source the query runs against. + example: "audit" + type: string + required: + - source + - query + - indexes + - compute + type: object + GovernanceInsightData: + description: A governance insight resource. + properties: + attributes: + $ref: "#/components/schemas/GovernanceInsightAttributes" + id: + description: The unique identifier of the insight. + example: "498ee21f-8037-48b8-a961-a488692902f4" + type: string + type: + $ref: "#/components/schemas/GovernanceInsightResourceType" + required: + - id + - type + - attributes + type: object + GovernanceInsightEventCompute: + description: The aggregation applied to an event query. + properties: + aggregation: + description: The aggregation function to apply. + example: "count" + type: string + interval: + description: The aggregation time window, in milliseconds. + example: 86400000 + format: int64 + type: integer + required: + - aggregation + - interval + type: object + GovernanceInsightEventQuery: + description: An event query used to compute an insight value. + properties: + compute: + $ref: "#/components/schemas/GovernanceInsightEventCompute" + nullable: true + indexes: + description: The event indexes the query runs against. + example: + - "main" + items: + description: An event index name. + type: string + type: array + query: + description: The event search query string. + example: "source:cloudtrail" + type: string + required: + - query + - indexes + type: object + GovernanceInsightMetricQuery: + description: A metric query used to compute an insight value. + properties: + query: + description: The query string. + example: "avg:system.cpu.user{*}" + type: string + reducer: + description: How the query result series is reduced to a single value. + example: "avg" + type: string + source: + description: The data source the query runs against. + example: "metrics" + type: string + required: + - source + - query + - reducer + type: object + GovernanceInsightPercentageQuery: + description: A percentage query that computes an insight value as a ratio of two metric queries. + properties: + denominator_query: + $ref: "#/components/schemas/GovernanceInsightMetricQuery" + numerator_query: + $ref: "#/components/schemas/GovernanceInsightMetricQuery" + required: + - numerator_query + - denominator_query + type: object + GovernanceInsightQueryConfig: + description: Query execution context that allows the frontend to execute insight queries directly. + properties: + chart_type: + description: The chart type the frontend should use to render the insight. + example: "line" + type: string + comparison_shift: + description: The window used for the previous value comparison, for example `week` or `month`. + example: "month" + type: string + default_value: + description: The default value to display when no data is available. + example: 0 + format: int64 + type: integer + directionality: + description: |- + Whether an increase in the value is good, bad, or neutral. One of `neutral`, + `increase_better`, or `decrease_better`. + example: "neutral" + type: string + effective_time_window_days: + description: The number of days the insight value is computed over. + example: 30 + format: int64 + type: integer + required: + - effective_time_window_days + - comparison_shift + type: object + GovernanceInsightResourceType: + description: JSON:API resource type for a governance insight. + enum: + - insight + example: "insight" + type: string + x-enum-varnames: + - INSIGHT + GovernanceInsightUsageQuery: + description: A usage query used to compute an insight value. + properties: + query: + description: The usage query string. + example: "logs_indexed_events" + type: string + reducer: + description: How the query result series is reduced to a single value. + example: "sum" + type: string + required: + - query + - reducer + type: object + GovernanceInsightsDataArray: + description: An array of governance insight resources. + items: + $ref: "#/components/schemas/GovernanceInsightData" + type: array + GovernanceInsightsResponse: + description: A list of governance insights. + properties: + data: + $ref: "#/components/schemas/GovernanceInsightsDataArray" + required: + - data + type: object GreyNoiseAPIKey: description: The definition of the `GreyNoiseAPIKey` object. properties: @@ -131857,6 +132241,135 @@ paths: operator: OR permissions: - user_access_read + /api/v2/governance/insights: + get: + description: |- + Retrieve the list of governance insights available to the organization. By default, only + insight metadata is returned; pass `withValues=true` to also compute and include each + insight's current and previous values. Insights can be filtered by product. + operationId: ListGovernanceInsights + parameters: + - description: |- + Whether to compute and include the current and previous value of each insight. + Defaults to `false`, in which case only insight metadata is returned. + example: true + in: query + name: withValues + required: false + schema: + type: boolean + - description: |- + The UUID of the organization to compute insights for. Defaults to the organization of + the authenticated user. Used to retrieve insights for a child organization from a + parent organization. + example: "11111111-2222-3333-4444-555555555555" + in: query + name: orgUuid + required: false + schema: + type: string + - description: |- + Restrict the results to insights belonging to the given products. May be repeated to + filter by multiple products. Matching is case-insensitive. + example: + - "Usage" + - "Logs Settings" + in: query + name: filter[product] + required: false + schema: + items: + type: string + type: array + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + audit_query: + best_practice: + deep_link: "" + description: "" + display_name: "Active Dashboards" + event_query: + metric_query: + old_value: 3274 + percentage_query: + product: "Usage" + state: "" + sub_product: "" + time_range: "" + unit_name: "active dashboards" + usage_query: + value: 3601 + id: "498ee21f-8037-48b8-a961-a488692902f4" + type: "insight" + - attributes: + audit_query: + best_practice: + category: "access_governance" + deep_link: "/organization-settings/users?status=inactive" + description: "Review and deactivate users who have not logged in within the last 90 days." + detection_type: + id: "bp_monitor_inactive_users" + impact: "Reduces unauthorized access risk." + impact_hint: 1 + permissions: + - "user_access_manage" + status: "active" + summary: "Inactive users with access increase your security surface area." + title: "Monitor inactive users" + trigger_condition: "active_users" + trigger_type: "insight" + deep_link: "" + description: "Number of users who have used the Dashboard in the last 30 days" + display_name: "Active Users" + event_query: + metric_query: + old_value: 1173 + percentage_query: + product: "Usage" + state: "" + sub_product: "" + time_range: "month" + unit_name: "active users" + usage_query: + value: 1291 + id: "a3248d1b-5578-4345-a34e-fe9657300f22" + type: "insight" + schema: + $ref: "#/components/schemas/GovernanceInsightsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List governance insights + tags: + - Governance Insights + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/hamr: get: description: |- @@ -190013,6 +190526,12 @@ tags: description: For more information about the Datadog Google Chat integration, see the integration page. url: https://docs.datadoghq.com/integrations/google-hangouts-chat/ name: Google Chat Integration + - description: |- + Governance Insights surface key usage, configuration, and best-practice signals for an + organization within the Governance Console. Each insight reports a current value (and, + optionally, a previous value for comparison) along with the query used to compute it, so + that the Console can render trends and highlight areas that need attention. + name: Governance Insights - description: |- Configure High Availability Multi-Region (HAMR) connections between Datadog organizations. HAMR provides disaster recovery capabilities by maintaining synchronized data between primary diff --git a/features/v2/governance_insights.feature b/features/v2/governance_insights.feature new file mode 100644 index 000000000000..0327e119c540 --- /dev/null +++ b/features/v2/governance_insights.feature @@ -0,0 +1,24 @@ +@endpoint(governance-insights) @endpoint(governance-insights-v2) +Feature: Governance Insights + Governance Insights surface key usage, configuration, and best-practice + signals for an organization within the Governance Console. Each insight + reports a current value (and, optionally, a previous value for comparison) + along with the query used to compute it, so that the Console can render + trends and highlight areas that need attention. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "GovernanceInsights" API + And operation "ListGovernanceInsights" enabled + And new "ListGovernanceInsights" request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: List governance insights returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: List governance insights returns "OK" response + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index 8729c7318e64..049cc1252219 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2762,6 +2762,12 @@ "type": "safe" } }, + "ListGovernanceInsights": { + "tag": "Governance Insights", + "undo": { + "type": "safe" + } + }, "GetHamrOrgConnection": { "tag": "High Availability MultiRegion", "undo": { diff --git a/packages/datadog-api-client/README.md b/packages/datadog-api-client/README.md index 387b309a379e..9ed5056d71cf 100644 --- a/packages/datadog-api-client/README.md +++ b/packages/datadog-api-client/README.md @@ -405,6 +405,7 @@ apiInstance | Forms | @datadog/datadog-api-client-forms | [README.md](../../services/forms/README.md) | | GCP Integration | @datadog/datadog-api-client-gcp-integration | [README.md](../../services/gcp-integration/README.md) | | Google Chat Integration | @datadog/datadog-api-client-google-chat-integration | [README.md](../../services/google-chat-integration/README.md) | +| Governance Insights | @datadog/datadog-api-client-governance-insights | [README.md](../../services/governance-insights/README.md) | | High Availability MultiRegion | @datadog/datadog-api-client-high-availability-multi-region | [README.md](../../services/high-availability-multi-region/README.md) | | Hosts | @datadog/datadog-api-client-hosts | [README.md](../../services/hosts/README.md) | | Incidents | @datadog/datadog-api-client-incidents | [README.md](../../services/incidents/README.md) | diff --git a/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 7c4f05cf9880..ac277e254975 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -9371,6 +9371,21 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "SAMLConfigurationResponse", }, + "GovernanceInsightsApi.V2.ListGovernanceInsights": { + withValues: { + type: "boolean", + format: "", + }, + orgUuid: { + type: "string", + format: "", + }, + filterProduct: { + type: "Array", + format: "", + }, + operationResponseType: "GovernanceInsightsResponse", + }, "HighAvailabilityMultiRegionApi.V2.GetHamrOrgConnection": { operationResponseType: "HamrOrgConnectionResponse", }, diff --git a/services/governance_insights/.yarnrc.yml b/services/governance_insights/.yarnrc.yml new file mode 100644 index 000000000000..3186f3f0795a --- /dev/null +++ b/services/governance_insights/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/services/governance_insights/README.md b/services/governance_insights/README.md new file mode 100644 index 000000000000..3f739fee49bd --- /dev/null +++ b/services/governance_insights/README.md @@ -0,0 +1,47 @@ +# @datadog/datadog-api-client-governance-insights + +## Description + +Governance Insights surface key usage, configuration, and best-practice signals for an +organization within the Governance Console. Each insight reports a current value (and, +optionally, a previous value for comparison) along with the query used to compute it, so +that the Console can render trends and highlight areas that need attention. + +## Navigation + +- [Installation](#installation) +- [Getting Started](#getting-started) + +## Installation + +```sh +# NPM +npm install @datadog/datadog-api-client-governance-insights +# Yarn +yarn add @datadog/datadog-api-client-governance-insights +``` + +## Getting Started +```ts +import { createConfiguration } from "@datadog/datadog-api-client"; +import { GovernanceInsightsApiV2 } from "@datadog/datadog-api-client-governance-insights"; +import { v2 } from "@datadog/datadog-api-client-governance-insights"; + +const configuration = createConfiguration(); +// Enable unstable operations +const configurationOpts = { + unstableOperations: { + "GovernanceInsightsApi.v2.listGovernanceInsights": true + } +} + +const configuration = createConfiguration(configurationOpts); +const apiInstance = new GovernanceInsightsApiV2(configuration); +const params = {/* parameters */}; + +apiInstance.listGovernanceInsights(params).then((data) => { + console.log("API called successfully. Returned data: " + JSON.stringify(data)); +}).catch((error) => { + console.error("Error calling API: " + error); +}); +``` \ No newline at end of file diff --git a/services/governance_insights/package.json b/services/governance_insights/package.json new file mode 100644 index 000000000000..d44906b2f104 --- /dev/null +++ b/services/governance_insights/package.json @@ -0,0 +1,43 @@ +{ + "name": "@datadog/datadog-api-client-governance-insights", + "description": "", + "author": "", + "keywords": [ + "api", + "fetch", + "typescript" + ], + "license": "Apache-2.0", + "licenses": [ + { + "type": "Apache-2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/DataDog/datadog-api-client-typescript.git", + "directory": "services/governance-insights" + }, + "files": [ + "dist/**/*" + ], + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "prepack": "yarn workspace @datadog/datadog-api-client build && yarn build", + "build": "yarn generate-version-files && tsc", + "generate-version-files": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version)\" > src/version.ts" + }, + "dependencies": { + "@datadog/datadog-api-client": "^2.0.0-beta.2" + }, + "devDependencies": { + "typescript": "5.8.3" + }, + "engines": { + "node": ">=18.0.0" + }, + "version": "0.0.1", + "packageManager": "yarn@4.9.1" +} diff --git a/services/governance_insights/src/index.ts b/services/governance_insights/src/index.ts new file mode 100644 index 000000000000..34f5f16b3e46 --- /dev/null +++ b/services/governance_insights/src/index.ts @@ -0,0 +1,3 @@ +export * as v2 from "./v2"; + +export { GovernanceInsightsApi as GovernanceInsightsApiV2 } from "./v2/GovernanceInsightsApi"; diff --git a/services/governance_insights/src/v2/GovernanceInsightsApi.ts b/services/governance_insights/src/v2/GovernanceInsightsApi.ts new file mode 100644 index 000000000000..bad0370d5165 --- /dev/null +++ b/services/governance_insights/src/v2/GovernanceInsightsApi.ts @@ -0,0 +1,260 @@ +import { + ApiException, + BaseAPIRequestFactory, + BaseServerConfiguration, + buildUserAgent, + Configuration, + createConfiguration, + deserialize, + getPreferredMediaType, + HttpMethod, + isBrowser, + logger, + normalizeMediaType, + parse, + RequiredError, + RequestContext, + ResponseContext, + serialize, + ServerConfiguration, + stringify, + applySecurityAuthentication, +} from "@datadog/datadog-api-client"; + +import { TypingInfo } from "./models/TypingInfo"; +import { APIErrorResponse } from "./models/APIErrorResponse"; +import { GovernanceInsightsResponse } from "./models/GovernanceInsightsResponse"; +import { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; +import { version } from "../version"; + +export class GovernanceInsightsApiRequestFactory extends BaseAPIRequestFactory { + public userAgent: string | undefined; + + public constructor(configuration: Configuration) { + super(configuration); + if (!isBrowser) { + this.userAgent = buildUserAgent("governance-insights", version); + } + } + public async listGovernanceInsights( + withValues?: boolean, + orgUuid?: string, + filterProduct?: Array, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + if ( + !_config.unstableOperations[ + "GovernanceInsightsApi.v2.listGovernanceInsights" + ] + ) { + throw new Error( + "Unstable operation 'listGovernanceInsights' is disabled. Enable it by setting `configuration.unstableOperations['GovernanceInsightsApi.v2.listGovernanceInsights'] = true`", + ); + } + + // Path Params + const localVarPath = "/api/v2/governance/insights"; + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "GovernanceInsightsApi.v2.listGovernanceInsights", + GovernanceInsightsApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.GET, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Query Params + if (withValues !== undefined) { + requestContext.setQueryParam( + "withValues", + serialize(withValues, TypingInfo, "boolean", ""), + "", + ); + } + if (orgUuid !== undefined) { + requestContext.setQueryParam( + "orgUuid", + serialize(orgUuid, TypingInfo, "string", ""), + "", + ); + } + if (filterProduct !== undefined) { + requestContext.setQueryParam( + "filter[product]", + serialize(filterProduct, TypingInfo, "Array", ""), + "multi", + ); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } +} + +export class GovernanceInsightsApiResponseProcessor { + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listGovernanceInsights + * @throws ApiException if the response code was not in [200, 299] + */ + public async listGovernanceInsights( + response: ResponseContext, + ): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: GovernanceInsightsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "GovernanceInsightsResponse", + ) as GovernanceInsightsResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 401 || + response.httpStatusCode === 403 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: GovernanceInsightsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "GovernanceInsightsResponse", + "", + ) as GovernanceInsightsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } +} + +export interface GovernanceInsightsApiListGovernanceInsightsRequest { + /** + * Whether to compute and include the current and previous value of each insight. + * Defaults to `false`, in which case only insight metadata is returned. + * @type boolean + */ + withValues?: boolean; + /** + * The UUID of the organization to compute insights for. Defaults to the organization of + * the authenticated user. Used to retrieve insights for a child organization from a + * parent organization. + * @type string + */ + orgUuid?: string; + /** + * Restrict the results to insights belonging to the given products. May be repeated to + * filter by multiple products. Matching is case-insensitive. + * @type Array + */ + filterProduct?: Array; +} + +export class GovernanceInsightsApi { + private requestFactory: GovernanceInsightsApiRequestFactory; + private responseProcessor: GovernanceInsightsApiResponseProcessor; + private configuration: Configuration; + + static operationServers: { [key: string]: BaseServerConfiguration[] } = {}; + + public constructor( + configuration?: Configuration, + requestFactory?: GovernanceInsightsApiRequestFactory, + responseProcessor?: GovernanceInsightsApiResponseProcessor, + ) { + this.configuration = configuration || createConfiguration(); + this.requestFactory = + requestFactory || + new GovernanceInsightsApiRequestFactory(this.configuration); + this.responseProcessor = + responseProcessor || new GovernanceInsightsApiResponseProcessor(); + } + + /** + * Retrieve the list of governance insights available to the organization. By default, only + * insight metadata is returned; pass `withValues=true` to also compute and include each + * insight's current and previous values. Insights can be filtered by product. + * @param param The request object + */ + public listGovernanceInsights( + param: GovernanceInsightsApiListGovernanceInsightsRequest = {}, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.listGovernanceInsights( + param.withValues, + param.orgUuid, + param.filterProduct, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.listGovernanceInsights(responseContext); + }); + }); + } +} diff --git a/services/governance_insights/src/v2/index.ts b/services/governance_insights/src/v2/index.ts new file mode 100644 index 000000000000..33ad652515a1 --- /dev/null +++ b/services/governance_insights/src/v2/index.ts @@ -0,0 +1,22 @@ +export { + GovernanceInsightsApiListGovernanceInsightsRequest, + GovernanceInsightsApi, +} from "./GovernanceInsightsApi"; + +export { APIErrorResponse } from "./models/APIErrorResponse"; +export { GovernanceBestPracticeDefinition } from "./models/GovernanceBestPracticeDefinition"; +export { GovernanceInsightAttributes } from "./models/GovernanceInsightAttributes"; +export { GovernanceInsightAuditCompute } from "./models/GovernanceInsightAuditCompute"; +export { GovernanceInsightAuditQuery } from "./models/GovernanceInsightAuditQuery"; +export { GovernanceInsightData } from "./models/GovernanceInsightData"; +export { GovernanceInsightEventCompute } from "./models/GovernanceInsightEventCompute"; +export { GovernanceInsightEventQuery } from "./models/GovernanceInsightEventQuery"; +export { GovernanceInsightMetricQuery } from "./models/GovernanceInsightMetricQuery"; +export { GovernanceInsightPercentageQuery } from "./models/GovernanceInsightPercentageQuery"; +export { GovernanceInsightQueryConfig } from "./models/GovernanceInsightQueryConfig"; +export { GovernanceInsightResourceType } from "./models/GovernanceInsightResourceType"; +export { GovernanceInsightsResponse } from "./models/GovernanceInsightsResponse"; +export { GovernanceInsightUsageQuery } from "./models/GovernanceInsightUsageQuery"; +export { JSONAPIErrorItem } from "./models/JSONAPIErrorItem"; +export { JSONAPIErrorItemSource } from "./models/JSONAPIErrorItemSource"; +export { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; diff --git a/services/governance_insights/src/v2/models/APIErrorResponse.ts b/services/governance_insights/src/v2/models/APIErrorResponse.ts new file mode 100644 index 000000000000..58d6c35b80f0 --- /dev/null +++ b/services/governance_insights/src/v2/models/APIErrorResponse.ts @@ -0,0 +1,45 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * API error response. + */ +export class APIErrorResponse { + /** + * A list of errors. + */ + "errors": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + errors: { + baseName: "errors", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return APIErrorResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceBestPracticeDefinition.ts b/services/governance_insights/src/v2/models/GovernanceBestPracticeDefinition.ts new file mode 100644 index 000000000000..175458575ec3 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceBestPracticeDefinition.ts @@ -0,0 +1,158 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * The best practice associated with an insight. Populated with the first active best practice + * matched to the insight; `null` when no best practice is attached. + */ +export class GovernanceBestPracticeDefinition { + /** + * The value driver the best practice is grouped under, such as `access_governance`, + * `security`, `compliance`, or `operational_hygiene`. + */ + "category": string; + /** + * A relative link to the configuration page where the best practice can be acted upon. + */ + "deepLink": string; + /** + * The full rationale and guidance for the best practice. + */ + "description": string; + /** + * An optional association to a control's detection type. `null` when not associated with a control. + */ + "detectionType"?: string; + /** + * The unique identifier of the best practice. + */ + "id": string; + /** + * The expected impact of following the best practice. + */ + "impact": string; + /** + * A priority hint for ordering best practices by expected impact. Lower values indicate + * higher priority. + */ + "impactHint": number; + /** + * The permissions required for the user to act on the best practice. + */ + "permissions": Array; + /** + * Whether the best practice is currently `active` or `deprecated`. + */ + "status": string; + /** + * A one-line explanation of why this best practice matters. + */ + "summary": string; + /** + * A short, human-readable name for the best practice. + */ + "title": string; + /** + * The condition that surfaces the best practice. For an `insight` trigger, the insight + * slug; for a `static` trigger, a descriptive condition key. + */ + "triggerCondition": string; + /** + * How the best practice is surfaced. `insight` ties it to an insight; `static` surfaces it + * unless its condition is met. + */ + "triggerType": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + category: { + baseName: "category", + type: "string", + required: true, + }, + deepLink: { + baseName: "deep_link", + type: "string", + required: true, + }, + description: { + baseName: "description", + type: "string", + required: true, + }, + detectionType: { + baseName: "detection_type", + type: "string", + }, + id: { + baseName: "id", + type: "string", + required: true, + }, + impact: { + baseName: "impact", + type: "string", + required: true, + }, + impactHint: { + baseName: "impact_hint", + type: "number", + required: true, + format: "int64", + }, + permissions: { + baseName: "permissions", + type: "Array", + required: true, + }, + status: { + baseName: "status", + type: "string", + required: true, + }, + summary: { + baseName: "summary", + type: "string", + required: true, + }, + title: { + baseName: "title", + type: "string", + required: true, + }, + triggerCondition: { + baseName: "trigger_condition", + type: "string", + required: true, + }, + triggerType: { + baseName: "trigger_type", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceBestPracticeDefinition.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightAttributes.ts b/services/governance_insights/src/v2/models/GovernanceInsightAttributes.ts new file mode 100644 index 000000000000..89618b1caebb --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightAttributes.ts @@ -0,0 +1,210 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceBestPracticeDefinition } from "./GovernanceBestPracticeDefinition"; +import { GovernanceInsightAuditQuery } from "./GovernanceInsightAuditQuery"; +import { GovernanceInsightEventQuery } from "./GovernanceInsightEventQuery"; +import { GovernanceInsightMetricQuery } from "./GovernanceInsightMetricQuery"; +import { GovernanceInsightPercentageQuery } from "./GovernanceInsightPercentageQuery"; +import { GovernanceInsightQueryConfig } from "./GovernanceInsightQueryConfig"; +import { GovernanceInsightUsageQuery } from "./GovernanceInsightUsageQuery"; + +/** + * The attributes of a governance insight. + */ +export class GovernanceInsightAttributes { + /** + * An audit log query used to compute an insight value. + */ + "auditQuery": GovernanceInsightAuditQuery; + /** + * The best practice associated with an insight. Populated with the first active best practice + * matched to the insight; `null` when no best practice is attached. + */ + "bestPractice": GovernanceBestPracticeDefinition; + /** + * A relative link to the product surface where the insight can be acted upon. + */ + "deepLink": string; + /** + * A human-readable description of what the insight measures. + */ + "description": string; + /** + * Human-readable name of the insight. + */ + "displayName": string; + /** + * An event query used to compute an insight value. + */ + "eventQuery": GovernanceInsightEventQuery; + /** + * A metric query used to compute an insight value. + */ + "metricQuery": GovernanceInsightMetricQuery; + /** + * The value of the insight over the previous comparison window. `null` when values were + * not requested or could not be computed. + */ + "oldValue": number | null; + /** + * A percentage query that computes an insight value as a ratio of two metric queries. + */ + "percentageQuery": GovernanceInsightPercentageQuery; + /** + * The product the insight belongs to. + */ + "product": string; + /** + * Query execution context that allows the frontend to execute insight queries directly. + */ + "queryConfig"?: GovernanceInsightQueryConfig; + /** + * The relative order in which the insight should be displayed. + */ + "sortOrder"?: number; + /** + * The state of the insight. A `critical` insight receives extra UI treatment to draw + * attention to it. + */ + "state": string; + /** + * The sub-product the insight belongs to, if any. + */ + "subProduct": string; + /** + * The time range the insight value is computed over, if applicable. + */ + "timeRange": string; + /** + * The unit that the insight's value is measured in. + */ + "unitName": string; + /** + * A usage query used to compute an insight value. + */ + "usageQuery": GovernanceInsightUsageQuery; + /** + * The current value of the insight. `null` when values were not requested or could not be computed. + */ + "value": number | null; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + auditQuery: { + baseName: "audit_query", + type: "GovernanceInsightAuditQuery", + required: true, + }, + bestPractice: { + baseName: "best_practice", + type: "GovernanceBestPracticeDefinition", + required: true, + }, + deepLink: { + baseName: "deep_link", + type: "string", + required: true, + }, + description: { + baseName: "description", + type: "string", + required: true, + }, + displayName: { + baseName: "display_name", + type: "string", + required: true, + }, + eventQuery: { + baseName: "event_query", + type: "GovernanceInsightEventQuery", + required: true, + }, + metricQuery: { + baseName: "metric_query", + type: "GovernanceInsightMetricQuery", + required: true, + }, + oldValue: { + baseName: "old_value", + type: "number", + required: true, + format: "double", + }, + percentageQuery: { + baseName: "percentage_query", + type: "GovernanceInsightPercentageQuery", + required: true, + }, + product: { + baseName: "product", + type: "string", + required: true, + }, + queryConfig: { + baseName: "query_config", + type: "GovernanceInsightQueryConfig", + }, + sortOrder: { + baseName: "sort_order", + type: "number", + format: "int64", + }, + state: { + baseName: "state", + type: "string", + required: true, + }, + subProduct: { + baseName: "sub_product", + type: "string", + required: true, + }, + timeRange: { + baseName: "time_range", + type: "string", + required: true, + }, + unitName: { + baseName: "unit_name", + type: "string", + required: true, + }, + usageQuery: { + baseName: "usage_query", + type: "GovernanceInsightUsageQuery", + required: true, + }, + value: { + baseName: "value", + type: "number", + required: true, + format: "double", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightAttributes.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightAuditCompute.ts b/services/governance_insights/src/v2/models/GovernanceInsightAuditCompute.ts new file mode 100644 index 000000000000..483168f26f85 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightAuditCompute.ts @@ -0,0 +1,72 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * The aggregation applied to an audit log query. + */ +export class GovernanceInsightAuditCompute { + /** + * The aggregation function to apply. + */ + "aggregation": string; + /** + * The aggregation time window, in milliseconds. + */ + "interval": number; + /** + * The metric or attribute to aggregate. + */ + "metric": string; + /** + * An optional secondary aggregation applied to the audit query result. + */ + "rollup"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + aggregation: { + baseName: "aggregation", + type: "string", + required: true, + }, + interval: { + baseName: "interval", + type: "number", + required: true, + format: "int64", + }, + metric: { + baseName: "metric", + type: "string", + required: true, + }, + rollup: { + baseName: "rollup", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightAuditCompute.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightAuditQuery.ts b/services/governance_insights/src/v2/models/GovernanceInsightAuditQuery.ts new file mode 100644 index 000000000000..3c6ba7d2c1c4 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightAuditQuery.ts @@ -0,0 +1,74 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceInsightAuditCompute } from "./GovernanceInsightAuditCompute"; + +/** + * An audit log query used to compute an insight value. + */ +export class GovernanceInsightAuditQuery { + /** + * The aggregation applied to an audit log query. + */ + "compute": GovernanceInsightAuditCompute; + /** + * The audit log indexes the query runs against. + */ + "indexes": Array; + /** + * The audit log search query string. + */ + "query": string; + /** + * The data source the query runs against. + */ + "source": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + compute: { + baseName: "compute", + type: "GovernanceInsightAuditCompute", + required: true, + }, + indexes: { + baseName: "indexes", + type: "Array", + required: true, + }, + query: { + baseName: "query", + type: "string", + required: true, + }, + source: { + baseName: "source", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightAuditQuery.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightData.ts b/services/governance_insights/src/v2/models/GovernanceInsightData.ts new file mode 100644 index 000000000000..d7c08ab371b0 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightData.ts @@ -0,0 +1,66 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceInsightAttributes } from "./GovernanceInsightAttributes"; +import { GovernanceInsightResourceType } from "./GovernanceInsightResourceType"; + +/** + * A governance insight resource. + */ +export class GovernanceInsightData { + /** + * The attributes of a governance insight. + */ + "attributes": GovernanceInsightAttributes; + /** + * The unique identifier of the insight. + */ + "id": string; + /** + * JSON:API resource type for a governance insight. + */ + "type": GovernanceInsightResourceType; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "GovernanceInsightAttributes", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + }, + type: { + baseName: "type", + type: "GovernanceInsightResourceType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightEventCompute.ts b/services/governance_insights/src/v2/models/GovernanceInsightEventCompute.ts new file mode 100644 index 000000000000..1a4cef1412d4 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightEventCompute.ts @@ -0,0 +1,55 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * The aggregation applied to an event query. + */ +export class GovernanceInsightEventCompute { + /** + * The aggregation function to apply. + */ + "aggregation": string; + /** + * The aggregation time window, in milliseconds. + */ + "interval": number; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + aggregation: { + baseName: "aggregation", + type: "string", + required: true, + }, + interval: { + baseName: "interval", + type: "number", + required: true, + format: "int64", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightEventCompute.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightEventQuery.ts b/services/governance_insights/src/v2/models/GovernanceInsightEventQuery.ts new file mode 100644 index 000000000000..a3e3e87cddf5 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightEventQuery.ts @@ -0,0 +1,64 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceInsightEventCompute } from "./GovernanceInsightEventCompute"; + +/** + * An event query used to compute an insight value. + */ +export class GovernanceInsightEventQuery { + /** + * The aggregation applied to an event query. + */ + "compute"?: GovernanceInsightEventCompute; + /** + * The event indexes the query runs against. + */ + "indexes": Array; + /** + * The event search query string. + */ + "query": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + compute: { + baseName: "compute", + type: "GovernanceInsightEventCompute", + }, + indexes: { + baseName: "indexes", + type: "Array", + required: true, + }, + query: { + baseName: "query", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightEventQuery.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightMetricQuery.ts b/services/governance_insights/src/v2/models/GovernanceInsightMetricQuery.ts new file mode 100644 index 000000000000..892f6a9d0f53 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightMetricQuery.ts @@ -0,0 +1,63 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * A metric query used to compute an insight value. + */ +export class GovernanceInsightMetricQuery { + /** + * The query string. + */ + "query": string; + /** + * How the query result series is reduced to a single value. + */ + "reducer": string; + /** + * The data source the query runs against. + */ + "source": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + query: { + baseName: "query", + type: "string", + required: true, + }, + reducer: { + baseName: "reducer", + type: "string", + required: true, + }, + source: { + baseName: "source", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightMetricQuery.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightPercentageQuery.ts b/services/governance_insights/src/v2/models/GovernanceInsightPercentageQuery.ts new file mode 100644 index 000000000000..3be10051b37b --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightPercentageQuery.ts @@ -0,0 +1,56 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceInsightMetricQuery } from "./GovernanceInsightMetricQuery"; + +/** + * A percentage query that computes an insight value as a ratio of two metric queries. + */ +export class GovernanceInsightPercentageQuery { + /** + * A metric query used to compute an insight value. + */ + "denominatorQuery": GovernanceInsightMetricQuery; + /** + * A metric query used to compute an insight value. + */ + "numeratorQuery": GovernanceInsightMetricQuery; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + denominatorQuery: { + baseName: "denominator_query", + type: "GovernanceInsightMetricQuery", + required: true, + }, + numeratorQuery: { + baseName: "numerator_query", + type: "GovernanceInsightMetricQuery", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightPercentageQuery.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightQueryConfig.ts b/services/governance_insights/src/v2/models/GovernanceInsightQueryConfig.ts new file mode 100644 index 000000000000..eddee0c0594a --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightQueryConfig.ts @@ -0,0 +1,81 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * Query execution context that allows the frontend to execute insight queries directly. + */ +export class GovernanceInsightQueryConfig { + /** + * The chart type the frontend should use to render the insight. + */ + "chartType"?: string; + /** + * The window used for the previous value comparison, for example `week` or `month`. + */ + "comparisonShift": string; + /** + * The default value to display when no data is available. + */ + "defaultValue"?: number; + /** + * Whether an increase in the value is good, bad, or neutral. One of `neutral`, + * `increase_better`, or `decrease_better`. + */ + "directionality"?: string; + /** + * The number of days the insight value is computed over. + */ + "effectiveTimeWindowDays": number; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + chartType: { + baseName: "chart_type", + type: "string", + }, + comparisonShift: { + baseName: "comparison_shift", + type: "string", + required: true, + }, + defaultValue: { + baseName: "default_value", + type: "number", + format: "int64", + }, + directionality: { + baseName: "directionality", + type: "string", + }, + effectiveTimeWindowDays: { + baseName: "effective_time_window_days", + type: "number", + required: true, + format: "int64", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightQueryConfig.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightResourceType.ts b/services/governance_insights/src/v2/models/GovernanceInsightResourceType.ts new file mode 100644 index 000000000000..064b7c1c300a --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightResourceType.ts @@ -0,0 +1,7 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * JSON:API resource type for a governance insight. + */ +export type GovernanceInsightResourceType = typeof INSIGHT | UnparsedObject; +export const INSIGHT = "insight"; diff --git a/services/governance_insights/src/v2/models/GovernanceInsightUsageQuery.ts b/services/governance_insights/src/v2/models/GovernanceInsightUsageQuery.ts new file mode 100644 index 000000000000..6a63bca94871 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightUsageQuery.ts @@ -0,0 +1,54 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * A usage query used to compute an insight value. + */ +export class GovernanceInsightUsageQuery { + /** + * The usage query string. + */ + "query": string; + /** + * How the query result series is reduced to a single value. + */ + "reducer": string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + query: { + baseName: "query", + type: "string", + required: true, + }, + reducer: { + baseName: "reducer", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightUsageQuery.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/GovernanceInsightsResponse.ts b/services/governance_insights/src/v2/models/GovernanceInsightsResponse.ts new file mode 100644 index 000000000000..5932781e8546 --- /dev/null +++ b/services/governance_insights/src/v2/models/GovernanceInsightsResponse.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { GovernanceInsightData } from "./GovernanceInsightData"; + +/** + * A list of governance insights. + */ +export class GovernanceInsightsResponse { + /** + * An array of governance insight resources. + */ + "data": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return GovernanceInsightsResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/JSONAPIErrorItem.ts b/services/governance_insights/src/v2/models/JSONAPIErrorItem.ts new file mode 100644 index 000000000000..a1ca45cd463c --- /dev/null +++ b/services/governance_insights/src/v2/models/JSONAPIErrorItem.ts @@ -0,0 +1,78 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; + +/** + * API error response body + */ +export class JSONAPIErrorItem { + /** + * A human-readable explanation specific to this occurrence of the error. + */ + "detail"?: string; + /** + * Non-standard meta-information about the error + */ + "meta"?: { [key: string]: any }; + /** + * References to the source of the error. + */ + "source"?: JSONAPIErrorItemSource; + /** + * Status code of the response. + */ + "status"?: string; + /** + * Short human-readable summary of the error. + */ + "title"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + detail: { + baseName: "detail", + type: "string", + }, + meta: { + baseName: "meta", + type: "{ [key: string]: any; }", + }, + source: { + baseName: "source", + type: "JSONAPIErrorItemSource", + }, + status: { + baseName: "status", + type: "string", + }, + title: { + baseName: "title", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItem.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/JSONAPIErrorItemSource.ts b/services/governance_insights/src/v2/models/JSONAPIErrorItemSource.ts new file mode 100644 index 000000000000..5889114315fa --- /dev/null +++ b/services/governance_insights/src/v2/models/JSONAPIErrorItemSource.ts @@ -0,0 +1,60 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * References to the source of the error. + */ +export class JSONAPIErrorItemSource { + /** + * A string indicating the name of a single request header which caused the error. + */ + "header"?: string; + /** + * A string indicating which URI query parameter caused the error. + */ + "parameter"?: string; + /** + * A JSON pointer to the value in the request document that caused the error. + */ + "pointer"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + header: { + baseName: "header", + type: "string", + }, + parameter: { + baseName: "parameter", + type: "string", + }, + pointer: { + baseName: "pointer", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItemSource.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/JSONAPIErrorResponse.ts b/services/governance_insights/src/v2/models/JSONAPIErrorResponse.ts new file mode 100644 index 000000000000..68aa04ffc27b --- /dev/null +++ b/services/governance_insights/src/v2/models/JSONAPIErrorResponse.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; + +/** + * API error response. + */ +export class JSONAPIErrorResponse { + /** + * A list of errors. + */ + "errors": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + errors: { + baseName: "errors", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/governance_insights/src/v2/models/TypingInfo.ts b/services/governance_insights/src/v2/models/TypingInfo.ts new file mode 100644 index 000000000000..2efe4745038a --- /dev/null +++ b/services/governance_insights/src/v2/models/TypingInfo.ts @@ -0,0 +1,43 @@ +import { ModelTypingInfo } from "@datadog/datadog-api-client"; + +import { APIErrorResponse } from "./APIErrorResponse"; +import { GovernanceBestPracticeDefinition } from "./GovernanceBestPracticeDefinition"; +import { GovernanceInsightAttributes } from "./GovernanceInsightAttributes"; +import { GovernanceInsightAuditCompute } from "./GovernanceInsightAuditCompute"; +import { GovernanceInsightAuditQuery } from "./GovernanceInsightAuditQuery"; +import { GovernanceInsightData } from "./GovernanceInsightData"; +import { GovernanceInsightEventCompute } from "./GovernanceInsightEventCompute"; +import { GovernanceInsightEventQuery } from "./GovernanceInsightEventQuery"; +import { GovernanceInsightMetricQuery } from "./GovernanceInsightMetricQuery"; +import { GovernanceInsightPercentageQuery } from "./GovernanceInsightPercentageQuery"; +import { GovernanceInsightQueryConfig } from "./GovernanceInsightQueryConfig"; +import { GovernanceInsightUsageQuery } from "./GovernanceInsightUsageQuery"; +import { GovernanceInsightsResponse } from "./GovernanceInsightsResponse"; +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; +import { JSONAPIErrorResponse } from "./JSONAPIErrorResponse"; + +export const TypingInfo: ModelTypingInfo = { + enumsMap: { + GovernanceInsightResourceType: ["insight"], + }, + oneOfMap: {}, + typeMap: { + APIErrorResponse: APIErrorResponse, + GovernanceBestPracticeDefinition: GovernanceBestPracticeDefinition, + GovernanceInsightAttributes: GovernanceInsightAttributes, + GovernanceInsightAuditCompute: GovernanceInsightAuditCompute, + GovernanceInsightAuditQuery: GovernanceInsightAuditQuery, + GovernanceInsightData: GovernanceInsightData, + GovernanceInsightEventCompute: GovernanceInsightEventCompute, + GovernanceInsightEventQuery: GovernanceInsightEventQuery, + GovernanceInsightMetricQuery: GovernanceInsightMetricQuery, + GovernanceInsightPercentageQuery: GovernanceInsightPercentageQuery, + GovernanceInsightQueryConfig: GovernanceInsightQueryConfig, + GovernanceInsightUsageQuery: GovernanceInsightUsageQuery, + GovernanceInsightsResponse: GovernanceInsightsResponse, + JSONAPIErrorItem: JSONAPIErrorItem, + JSONAPIErrorItemSource: JSONAPIErrorItemSource, + JSONAPIErrorResponse: JSONAPIErrorResponse, + }, +}; diff --git a/services/governance_insights/tsconfig.json b/services/governance_insights/tsconfig.json new file mode 100644 index 000000000000..d6c32bfb893c --- /dev/null +++ b/services/governance_insights/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "strict": true, + /* Basic Options */ + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + + "esModuleInterop": true, + "resolveJsonModule": true, + + "noImplicitAny": true, + "noImplicitThis": true, + + /* Additional Checks */ + "noUnusedLocals": false /* Report errors on unused locals. */, // TODO: reenable (unused imports!) + "noUnusedParameters": false /* Report errors on unused parameters. */, // TODO: set to true again + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + + "sourceMap": true, + "outDir": "./dist", + "lib": ["es6", "es7"] + }, + "exclude": ["dist", "node_modules", "tests"], + "include": ["src"] +} diff --git a/yarn.lock b/yarn.lock index 666c9c05399d..3be50b1152e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -802,6 +802,15 @@ __metadata: languageName: unknown linkType: soft +"@datadog/datadog-api-client-governance-insights@workspace:services/governance_insights": + version: 0.0.0-use.local + resolution: "@datadog/datadog-api-client-governance-insights@workspace:services/governance_insights" + dependencies: + "@datadog/datadog-api-client": "npm:^2.0.0-beta.2" + typescript: "npm:5.8.3" + languageName: unknown + linkType: soft + "@datadog/datadog-api-client-high-availability-multi-region@workspace:services/high_availability_multi_region": version: 0.0.0-use.local resolution: "@datadog/datadog-api-client-high-availability-multi-region@workspace:services/high_availability_multi_region"