Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,224 changes: 1,224 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2026-04-01T20:36:45.896Z"

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2026-04-01T20:36:50.944Z"

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Create targeting rules for a flag env returns "Created" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiCreateAllocationsForFeatureFlagInEnvironmentRequest =
{
body: {
data: {
attributes: {
experimentId: "550e8400-e29b-41d4-a716-446655440030",
exposureSchedule: {
absoluteStartTime: new Date(2025, 6, 13, 12, 0, 0, 0),
controlVariantId: "550e8400-e29b-41d4-a716-446655440012",
controlVariantKey: "control",
id: "550e8400-e29b-41d4-a716-446655440010",
rolloutOptions: {
autostart: false,
selectionIntervalMs: 3600000,
strategy: "UNIFORM_INTERVALS",
},
rolloutSteps: [
{
exposureRatio: 0.5,
groupedStepIndex: 1,
id: "550e8400-e29b-41d4-a716-446655440040",
intervalMs: 3600000,
isPauseRecord: false,
},
],
},
guardrailMetrics: [
{
metricId: "metric-error-rate",
triggerAction: "PAUSE",
},
],
id: "550e8400-e29b-41d4-a716-446655440020",
key: "prod-rollout",
name: "Production Rollout",
targetingRules: [
{
conditions: [
{
attribute: "user_tier",
operator: "ONE_OF",
value: ["premium", "enterprise"],
},
],
},
],
type: "FEATURE_GATE",
variantWeights: [
{
value: 50,
variantId: "550e8400-e29b-41d4-a716-446655440001",
variantKey: "control",
},
],
},
type: "allocations",
},
},
featureFlagId: "550e8400-e29b-41d4-a716-446655440000",
environmentId: "550e8400-e29b-41d4-a716-446655440001",
};

apiInstance
.createAllocationsForFeatureFlagInEnvironment(params)
.then((data: v2.AllocationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Create allocation for a flag in an environment returns "Created" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

// there is a valid "feature_flag" in the system
const FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID = process.env
.FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID as string;
const FEATURE_FLAG_DATA_ID = process.env.FEATURE_FLAG_DATA_ID as string;

// there is a valid "environment" in the system
const ENVIRONMENT_DATA_ID = process.env.ENVIRONMENT_DATA_ID as string;

const params: v2.FeatureFlagsApiCreateAllocationsForFeatureFlagInEnvironmentRequest =
{
body: {
data: {
type: "allocations",
attributes: {
name: "New targeting rule Example-Feature-Flag",
key: "new-targeting-rule-example-feature-flag",
targetingRules: [],
variantWeights: [
{
variantId: FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID,
value: 100,
},
],
guardrailMetrics: [],
type: "CANARY",
},
},
},
featureFlagId: FEATURE_FLAG_DATA_ID,
environmentId: ENVIRONMENT_DATA_ID,
};

apiInstance
.createAllocationsForFeatureFlagInEnvironment(params)
.then((data: v2.AllocationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
21 changes: 21 additions & 0 deletions examples/v2/feature-flags/PauseExposureSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Pause a progressive rollout returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiPauseExposureScheduleRequest = {
exposureScheduleId: "550e8400-e29b-41d4-a716-446655440010",
};

apiInstance
.pauseExposureSchedule(params)
.then((data: v2.AllocationExposureScheduleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
21 changes: 21 additions & 0 deletions examples/v2/feature-flags/ResumeExposureSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Resume a progressive rollout returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiResumeExposureScheduleRequest = {
exposureScheduleId: "550e8400-e29b-41d4-a716-446655440010",
};

apiInstance
.resumeExposureSchedule(params)
.then((data: v2.AllocationExposureScheduleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
21 changes: 21 additions & 0 deletions examples/v2/feature-flags/StartExposureSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Start a progressive rollout returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiStartExposureScheduleRequest = {
exposureScheduleId: "550e8400-e29b-41d4-a716-446655440010",
};

apiInstance
.startExposureSchedule(params)
.then((data: v2.AllocationExposureScheduleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
21 changes: 21 additions & 0 deletions examples/v2/feature-flags/StopExposureSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Stop a progressive rollout returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiStopExposureScheduleRequest = {
exposureScheduleId: "550e8400-e29b-41d4-a716-446655440010",
};

apiInstance
.stopExposureSchedule(params)
.then((data: v2.AllocationExposureScheduleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Update targeting rules for a flag returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

const params: v2.FeatureFlagsApiUpdateAllocationsForFeatureFlagInEnvironmentRequest =
{
body: {
data: [
{
attributes: {
experimentId: "550e8400-e29b-41d4-a716-446655440030",
exposureSchedule: {
absoluteStartTime: new Date(2025, 6, 13, 12, 0, 0, 0),
controlVariantId: "550e8400-e29b-41d4-a716-446655440012",
controlVariantKey: "control",
id: "550e8400-e29b-41d4-a716-446655440010",
rolloutOptions: {
autostart: false,
selectionIntervalMs: 3600000,
strategy: "UNIFORM_INTERVALS",
},
rolloutSteps: [
{
exposureRatio: 0.5,
groupedStepIndex: 1,
id: "550e8400-e29b-41d4-a716-446655440040",
intervalMs: 3600000,
isPauseRecord: false,
},
],
},
guardrailMetrics: [
{
metricId: "metric-error-rate",
triggerAction: "PAUSE",
},
],
id: "550e8400-e29b-41d4-a716-446655440020",
key: "prod-rollout",
name: "Production Rollout",
targetingRules: [
{
conditions: [
{
attribute: "user_tier",
operator: "ONE_OF",
value: ["premium", "enterprise"],
},
],
},
],
type: "FEATURE_GATE",
variantWeights: [
{
value: 50,
variantId: "550e8400-e29b-41d4-a716-446655440001",
variantKey: "control",
},
],
},
type: "allocations",
},
],
},
featureFlagId: "550e8400-e29b-41d4-a716-446655440000",
environmentId: "550e8400-e29b-41d4-a716-446655440001",
};

apiInstance
.updateAllocationsForFeatureFlagInEnvironment(params)
.then((data: v2.ListAllocationsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Update targeting rules for a flag in an environment returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FeatureFlagsApi(configuration);

// there is a valid "feature_flag" in the system
const FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID = process.env
.FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID as string;
const FEATURE_FLAG_DATA_ID = process.env.FEATURE_FLAG_DATA_ID as string;

// there is a valid "environment" in the system
const ENVIRONMENT_DATA_ID = process.env.ENVIRONMENT_DATA_ID as string;

const params: v2.FeatureFlagsApiUpdateAllocationsForFeatureFlagInEnvironmentRequest =
{
body: {
data: [
{
type: "allocations",
attributes: {
key: "overwrite-allocation-example-feature-flag",
name: "New targeting rule Example-Feature-Flag",
targetingRules: [],
variantWeights: [
{
variantId: FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID,
value: 100,
},
],
exposureSchedule: {
rolloutOptions: {
strategy: "UNIFORM_INTERVALS",
autostart: false,
selectionIntervalMs: 86400000,
},
rolloutSteps: [
{
exposureRatio: 0.05,
intervalMs: undefined,
isPauseRecord: false,
groupedStepIndex: 0,
},
{
exposureRatio: 0.25,
intervalMs: undefined,
isPauseRecord: false,
groupedStepIndex: 1,
},
{
exposureRatio: 1,
intervalMs: undefined,
isPauseRecord: false,
groupedStepIndex: 2,
},
],
},
guardrailMetrics: [],
type: "CANARY",
},
},
],
},
featureFlagId: FEATURE_FLAG_DATA_ID,
environmentId: ENVIRONMENT_DATA_ID,
};

apiInstance
.updateAllocationsForFeatureFlagInEnvironment(params)
.then((data: v2.ListAllocationsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Loading
Loading