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
212 changes: 142 additions & 70 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,21 @@
# Create an environment with full evaluation data true returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

body = DatadogAPIClient::V2::CreateEnvironmentRequest.new({
data: DatadogAPIClient::V2::CreateEnvironmentData.new({
type: DatadogAPIClient::V2::CreateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::CreateEnvironmentAttributes.new({
name: "Evaluation Privacy Example-Feature-Flag",
queries: [
"privacy-example-feature-flag",
],
observe_full_evaluation_data: true,
}),
}),
})
p api_instance.create_feature_flags_environment(body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Create an environment with full evaluation data false returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

body = DatadogAPIClient::V2::CreateEnvironmentRequest.new({
data: DatadogAPIClient::V2::CreateEnvironmentData.new({
type: DatadogAPIClient::V2::CreateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::CreateEnvironmentAttributes.new({
name: "Evaluation Privacy Example-Feature-Flag",
queries: [
"privacy-example-feature-flag",
],
observe_full_evaluation_data: false,
}),
}),
})
p api_instance.create_feature_flags_environment(body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Update an environment to enable full evaluation data returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

# there is a valid "environment" in the system
ENVIRONMENT_DATA_ID = ENV["ENVIRONMENT_DATA_ID"]

body = DatadogAPIClient::V2::UpdateEnvironmentRequest.new({
data: DatadogAPIClient::V2::UpdateEnvironmentData.new({
type: DatadogAPIClient::V2::UpdateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::UpdateEnvironmentAttributes.new({
name: "Updated Privacy Example-Feature-Flag",
queries: [
"updated-privacy-example-feature-flag",
],
observe_full_evaluation_data: true,
}),
}),
})
p api_instance.update_feature_flags_environment(ENVIRONMENT_DATA_ID, body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Update an environment to preserve enabled full evaluation data when omitted returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

# there is a valid "environment_with_full_evaluation_data" in the system
ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID = ENV["ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID"]

body = DatadogAPIClient::V2::UpdateEnvironmentRequest.new({
data: DatadogAPIClient::V2::UpdateEnvironmentData.new({
type: DatadogAPIClient::V2::UpdateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::UpdateEnvironmentAttributes.new({
name: "Updated Privacy Example-Feature-Flag",
queries: [
"updated-privacy-example-feature-flag",
],
}),
}),
})
p api_instance.update_feature_flags_environment(ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID, body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Update an environment to preserve disabled full evaluation data when omitted returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

# there is a valid "environment" in the system
ENVIRONMENT_DATA_ID = ENV["ENVIRONMENT_DATA_ID"]

body = DatadogAPIClient::V2::UpdateEnvironmentRequest.new({
data: DatadogAPIClient::V2::UpdateEnvironmentData.new({
type: DatadogAPIClient::V2::UpdateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::UpdateEnvironmentAttributes.new({
name: "Updated Privacy Example-Feature-Flag",
queries: [
"updated-privacy-example-feature-flag",
],
}),
}),
})
p api_instance.update_feature_flags_environment(ENVIRONMENT_DATA_ID, body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Update an environment to disable full evaluation data returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

# there is a valid "environment_with_full_evaluation_data" in the system
ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID = ENV["ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID"]

body = DatadogAPIClient::V2::UpdateEnvironmentRequest.new({
data: DatadogAPIClient::V2::UpdateEnvironmentData.new({
type: DatadogAPIClient::V2::UpdateEnvironmentDataType::ENVIRONMENTS,
attributes: DatadogAPIClient::V2::UpdateEnvironmentAttributes.new({
name: "Updated Privacy Example-Feature-Flag",
queries: [
"updated-privacy-example-feature-flag",
],
observe_full_evaluation_data: false,
}),
}),
})
p api_instance.update_feature_flags_environment(ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID, body)
110 changes: 97 additions & 13 deletions features/v2/feature_flags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,48 @@ Feature: Feature Flags
When the request is sent
Then the response status is 201 Created

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Create an environment returns "Bad Request" response
Given new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"description": "Staging environment for testing", "key": "staging", "name": "staging"}}}
And body with value {"data": {"type": "environments", "attributes": {"name": "Invalid Query {{ unique }}", "queries": ["staging-*"]}}}
When the request is sent
Then the response status is 400 Bad Request
And the response "errors[0].status" is equal to "400"
And the response "errors[0].title" is equal to "Bad Request"

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Create an environment returns "Conflict" response
Given new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"description": "Staging environment for testing", "key": "staging", "name": "staging"}}}
Given there is a valid "environment" in the system
And new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"name": "Duplicate Query {{ unique }}", "queries": ["{{ environment.data.attributes.queries[0] }}", "{{ environment.data.attributes.queries[1] }}"]}}}
When the request is sent
Then the response status is 409 Conflict
And the response "errors[0].status" is equal to "409"
And the response "errors[0].title" is equal to "Conflict"

@team:ddoghq/feature-flags
Scenario: Create an environment returns "Created" response
Given new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"name": "Test Environment {{ unique }}", "queries": ["test-{{ unique }}", "env-{{ unique }}"]}}}
When the request is sent
Then the response status is 201 Created
And the response "data.attributes.observe_full_evaluation_data" is equal to false

@team:ddoghq/feature-flags
Scenario: Create an environment with full evaluation data false returns "Created" response
Given new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"name": "Evaluation Privacy {{ unique }}", "queries": ["privacy-{{ unique_lower }}"], "observe_full_evaluation_data": false}}}
When the request is sent
Then the response status is 201 Created
And the response "data.attributes.observe_full_evaluation_data" is equal to false

@team:ddoghq/feature-flags
Scenario: Create an environment with full evaluation data true returns "Created" response
Given new "CreateFeatureFlagsEnvironment" request
And body with value {"data": {"type": "environments", "attributes": {"name": "Evaluation Privacy {{ unique }}", "queries": ["privacy-{{ unique_lower }}"], "observe_full_evaluation_data": true}}}
When the request is sent
Then the response status is 201 Created
And the response "data.attributes.observe_full_evaluation_data" is equal to true

@generated @skip @team:ddoghq/feature-flags
Scenario: Create targeting rules for a flag env returns "Accepted - Approval required for this change" response
Expand Down Expand Up @@ -206,12 +228,14 @@ Feature: Feature Flags
When the request is sent
Then the response status is 204 No Content

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Delete an environment returns "Not Found" response
Given new "DeleteFeatureFlagsEnvironment" request
And request contains "environment_id" parameter with value "00000000-0000-0000-0000-000000000000"
When the request is sent
Then the response status is 404 Not Found
And the response "errors[0].status" is equal to "404"
And the response "errors[0].title" is equal to "Not Found"

@skip @team:ddoghq/feature-flags
Scenario: Disable a feature flag in an environment returns "Accepted - Approval required for this change" response
Expand Down Expand Up @@ -351,12 +375,14 @@ Feature: Feature Flags
And the response "data.attributes.targeting_rules[0].conditions[0].operator" is equal to "ONE_OF"
And the response "data.attributes.targeting_rules[0].conditions[0].value" is equal to ["test-user-1", "test-user-2"]

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Get an environment returns "Not Found" response
Given new "GetFeatureFlagsEnvironment" request
And request contains "environment_id" parameter with value "00000000-0000-0000-0000-000000000000"
When the request is sent
Then the response status is 404 Not Found
And the response "errors[0].status" is equal to "404"
And the response "errors[0].title" is equal to "Not Found"

@skip @team:ddoghq/feature-flags
Scenario: Get an environment returns "OK" response
Expand Down Expand Up @@ -1147,21 +1173,26 @@ Feature: Feature Flags
When the request is sent
Then the response status is 200 OK

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Update an environment returns "Bad Request" response
Given new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter with value "00000000-0000-0000-0000-000000000000"
And body with value {"data": {"type": "environments", "attributes": {"description": "Updated staging environment description", "name": "Updated Staging"}}}
Given there is a valid "environment" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment.data.id"
And body with value {"data": {"type": "environments", "attributes": {"name": "Missing Queries {{ unique }}"}}}
When the request is sent
Then the response status is 400 Bad Request
And the response "errors[0].status" is equal to "400"
And the response "errors[0].title" is equal to "Bad Request"

@skip @team:ddoghq/feature-flags
@team:ddoghq/feature-flags
Scenario: Update an environment returns "Not Found" response
Given new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter with value "00000000-0000-0000-0000-000000000000"
And body with value {"data": {"type": "environments", "attributes": {"description": "Updated staging environment description", "name": "Updated Staging"}}}
And body with value {"data": {"type": "environments", "attributes": {"name": "Missing Environment {{ unique }}", "queries": ["missing-{{ unique_lower }}"]}}}
When the request is sent
Then the response status is 404 Not Found
And the response "errors[0].status" is equal to "404"
And the response "errors[0].title" is equal to "Not Found"

@skip @team:ddoghq/feature-flags
Scenario: Update an environment returns "OK" response
Expand All @@ -1172,6 +1203,59 @@ Feature: Feature Flags
When the request is sent
Then the response status is 200 OK

@team:ddoghq/feature-flags
Scenario: Update an environment to disable full evaluation data returns "OK" response
Given there is a valid "environment_with_full_evaluation_data" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment_with_full_evaluation_data.data.id"
And body with value {"data": {"type": "environments", "attributes": {"name": "Updated Privacy {{ unique }}", "queries": ["updated-privacy-{{ unique_lower }}"], "observe_full_evaluation_data": false}}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.observe_full_evaluation_data" is equal to false

@team:ddoghq/feature-flags
Scenario: Update an environment to enable full evaluation data returns "OK" response
Given there is a valid "environment" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment.data.id"
And body with value {"data": {"type": "environments", "attributes": {"name": "Updated Privacy {{ unique }}", "queries": ["updated-privacy-{{ unique_lower }}"], "observe_full_evaluation_data": true}}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.observe_full_evaluation_data" is equal to true

@team:ddoghq/feature-flags
Scenario: Update an environment to preserve disabled full evaluation data when omitted returns "OK" response
Given there is a valid "environment" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment.data.id"
And body with value {"data": {"type": "environments", "attributes": {"name": "Updated Privacy {{ unique }}", "queries": ["updated-privacy-{{ unique_lower }}"]}}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.observe_full_evaluation_data" is equal to false

@team:ddoghq/feature-flags
Scenario: Update an environment to preserve enabled full evaluation data when omitted returns "OK" response
Given there is a valid "environment_with_full_evaluation_data" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment_with_full_evaluation_data.data.id"
And body with value {"data": {"type": "environments", "attributes": {"name": "Updated Privacy {{ unique }}", "queries": ["updated-privacy-{{ unique_lower }}"]}}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.observe_full_evaluation_data" is equal to true
And the response "data.attributes.is_production" is equal to false
And the response "data.attributes.require_feature_flag_approval" is equal to false

@team:ddoghq/feature-flags
Scenario: Update an environment without a name returns "Bad Request" response
Given there is a valid "environment" in the system
And new "UpdateFeatureFlagsEnvironment" request
And request contains "environment_id" parameter from "environment.data.id"
And body with value {"data": {"type": "environments", "attributes": {"queries": ["missing-name-{{ unique_lower }}"], "observe_full_evaluation_data": true}}}
When the request is sent
Then the response status is 400 Bad Request
And the response "errors[0].status" is equal to "400"
And the response "errors[0].title" is equal to "Bad Request"

@team:ddoghq/feature-flags
Scenario: Update targeting rules for a flag in an environment returns "OK" response
Given there is a valid "feature_flag" in the system
Expand Down
12 changes: 12 additions & 0 deletions features/v2/given.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,18 @@
"tag": "Feature Flags",
"operationId": "CreateFeatureFlagsEnvironment"
},
{
"parameters": [
{
"name": "body",
"value": "{\"data\": {\"type\": \"environments\", \"attributes\": {\"name\": \"Full Evaluation Data {{ unique }}\", \"queries\": [\"full-evaluation-data-{{ unique_lower }}\"], \"is_production\": true, \"require_feature_flag_approval\": true, \"observe_full_evaluation_data\": true}}}"
}
],
"step": "there is a valid \"environment_with_full_evaluation_data\" in the system",
"key": "environment_with_full_evaluation_data",
"tag": "Feature Flags",
"operationId": "CreateFeatureFlagsEnvironment"
},
{
"parameters": [
{
Expand Down
Loading
Loading