diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d16435a94fcd..0ac074923c43 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1526,6 +1526,15 @@ components: example: "550e8400-e29b-41d4-a716-446655440000" format: uuid type: string + suggestion_id: + description: The ID of the flag suggestion. + in: path + name: suggestion_id + required: true + schema: + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string requestBodies: {} responses: BadRequestResponse: @@ -16318,6 +16327,62 @@ components: required: - data type: object + CreateFlagSuggestionAttributes: + description: Attributes for creating a flag suggestion. + properties: + action: + $ref: "#/components/schemas/FlagSuggestionAction" + comment: + description: Optional comment explaining the change. + example: "Archive this deprecated flag" + type: string + environment_id: + description: The environment ID for environment-scoped changes. + example: "550e8400-e29b-41d4-a716-446655440001" + format: uuid + type: string + notification_rule_targets: + description: |- + Notification handles (without @ prefix) to receive approval or rejection notifications. + For example, an email address or Slack channel name. + example: + - "user@example.com" + items: + type: string + minItems: 1 + type: array + property: + $ref: "#/components/schemas/FlagSuggestionProperty" + suggestion: + description: The suggested new value (empty string for flag-level actions like archive, JSON-encoded for complex properties like allocations). + example: "ENABLED" + type: string + suggestion_metadata: + $ref: "#/components/schemas/SuggestionMetadata" + required: + - action + - property + - notification_rule_targets + type: object + CreateFlagSuggestionData: + description: Data for creating a flag suggestion. + properties: + attributes: + $ref: "#/components/schemas/CreateFlagSuggestionAttributes" + type: + $ref: "#/components/schemas/FlagSuggestionDataType" + required: + - type + - attributes + type: object + CreateFlagSuggestionRequest: + description: Request to create a flag suggestion. + properties: + data: + $ref: "#/components/schemas/CreateFlagSuggestionData" + required: + - data + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -27026,6 +27091,194 @@ components: $ref: "#/components/schemas/FindingData" type: array type: object + FlagSuggestion: + description: A flag change suggestion. + properties: + attributes: + $ref: "#/components/schemas/FlagSuggestionAttributes" + id: + description: Unique identifier for the suggestion. + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string + type: + $ref: "#/components/schemas/FlagSuggestionDataType" + required: + - id + - type + - attributes + type: object + FlagSuggestionAction: + description: The type of change action for a suggestion. + enum: + - created + - updated + - deleted + - archived + - unarchived + - started + - stopped + - paused + - unpaused + example: archived + type: string + x-enum-varnames: + - CREATED + - UPDATED + - DELETED + - ARCHIVED + - UNARCHIVED + - STARTED + - STOPPED + - PAUSED + - UNPAUSED + FlagSuggestionAttributes: + description: Attributes of a flag suggestion. + properties: + action: + $ref: "#/components/schemas/FlagSuggestionAction" + base_flag_history_id: + description: The flag history version this suggestion was based on. + example: "550e8400-e29b-41d4-a716-446655440030" + format: uuid + type: string + comment: + description: Optional comment from the requester. + example: "Please archive this deprecated flag" + nullable: true + type: string + created_at: + description: When the suggestion was created. + example: "2024-01-15T10:30:00Z" + format: date-time + type: string + created_by: + description: UUID of the user who created the suggestion. + example: "550e8400-e29b-41d4-a716-446655440099" + format: uuid + type: string + current_status: + $ref: "#/components/schemas/FlagSuggestionStatus" + current_value: + description: The current value before the suggested change (empty string for flag-level actions like archive). + example: "DISABLED" + type: string + deleted_at: + description: When the suggestion was soft-deleted. + format: date-time + nullable: true + type: string + deleted_by: + description: UUID of the user who deleted the suggestion. + nullable: true + type: string + environment_id: + description: The environment ID for environment-scoped suggestions. Null for flag-level changes. + example: "550e8400-e29b-41d4-a716-446655440001" + nullable: true + type: string + feature_flag_id: + description: The ID of the feature flag this suggestion applies to. + example: "550e8400-e29b-41d4-a716-446655440000" + format: uuid + type: string + message: + description: Human-readable message about the suggestion (populated on auto-created suggestions). + example: "This flag requires approval to archive. A suggestion has been created and is pending review." + type: string + property: + $ref: "#/components/schemas/FlagSuggestionProperty" + suggestion: + description: The suggested new value (JSON-encoded for complex properties, empty string for flag-level actions like archive). + example: "ENABLED" + type: string + suggestion_metadata: + $ref: "#/components/schemas/SuggestionMetadata" + updated_at: + description: When the suggestion was last updated. + format: date-time + nullable: true + type: string + updated_by: + description: UUID of the user who last updated the suggestion. + nullable: true + type: string + required: + - feature_flag_id + - current_status + - action + - property + - created_by + - created_at + type: object + FlagSuggestionDataType: + description: Flag suggestions resource type. + enum: + - "flag-suggestions" + example: "flag-suggestions" + type: string + x-enum-varnames: + - FLAG_SUGGESTIONS + FlagSuggestionEventDataType: + description: Flag suggestion events resource type. + enum: + - "flag-suggestion-events" + example: "flag-suggestion-events" + type: string + x-enum-varnames: + - FLAG_SUGGESTION_EVENTS + FlagSuggestionProperty: + description: The flag property being changed. + enum: + - FLAG + - FLAG_NAME + - FLAG_DESCRIPTION + - JSON_SCHEMA + - DISTRIBUTION_CHANNEL + - VARIANT + - VARIANT_NAME + - VARIANT_VALUE + - ALLOCATIONS + - ROLLOUT + - ENVIRONMENT_STATUS + - DEFAULT_VARIANT + - OVERRIDE_VARIANT + example: FLAG + type: string + x-enum-varnames: + - FLAG + - FLAG_NAME + - FLAG_DESCRIPTION + - JSON_SCHEMA + - DISTRIBUTION_CHANNEL + - VARIANT + - VARIANT_NAME + - VARIANT_VALUE + - ALLOCATIONS + - ROLLOUT + - ENVIRONMENT_STATUS + - DEFAULT_VARIANT + - OVERRIDE_VARIANT + FlagSuggestionResponse: + description: Response containing a flag suggestion. + properties: + data: + $ref: "#/components/schemas/FlagSuggestion" + required: + - data + type: object + FlagSuggestionStatus: + description: The status of a flag suggestion. + enum: + - pending + - rejected + - approved + example: pending + type: string + x-enum-varnames: + - PENDING + - REJECTED + - APPROVED FlakyTest: description: A flaky test object. properties: @@ -57825,6 +58078,32 @@ components: description: Target revision ID to revert to type: string type: object + ReviewFlagSuggestionAttributes: + description: Attributes for reviewing a flag suggestion. + properties: + comment: + description: Optional comment from the reviewer. + example: "Looks good, approved!" + type: string + type: object + ReviewFlagSuggestionData: + description: Data for reviewing a flag suggestion. + properties: + attributes: + $ref: "#/components/schemas/ReviewFlagSuggestionAttributes" + type: + $ref: "#/components/schemas/FlagSuggestionEventDataType" + required: + - type + type: object + ReviewFlagSuggestionRequest: + description: Request to approve or reject a flag suggestion. + properties: + data: + $ref: "#/components/schemas/ReviewFlagSuggestionData" + required: + - data + type: object Role: description: Role object returned by the API. properties: @@ -70548,6 +70827,14 @@ components: format: double type: number type: object + SuggestionMetadata: + description: Optional metadata for a suggestion. + properties: + variant_id: + description: Variant ID for variant delete suggestions. + example: "550e8400-e29b-41d4-a716-446655440005" + type: string + type: object SuiteCreateEdit: description: Data object for creating or editing a Synthetic test suite. properties: @@ -91949,6 +92236,194 @@ paths: operator: AND permissions: - feature_flag_config_write + /api/v2/feature-flags/suggestions/{suggestion_id}: + delete: + description: |- + Delete a pending flag change suggestion. Approved suggestions cannot be deleted. + operationId: DeleteFlagSuggestion + parameters: + - $ref: "#/components/parameters/suggestion_id" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete a flag suggestion + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + - feature_flag_environment_config_read + get: + description: |- + Get a flag change suggestion by ID. + operationId: GetFlagSuggestion + parameters: + - $ref: "#/components/parameters/suggestion_id" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FlagSuggestionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get a flag suggestion + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + - feature_flag_environment_config_read + /api/v2/feature-flags/suggestions/{suggestion_id}/approve: + post: + description: |- + Approve a pending flag change suggestion. The change is applied immediately + upon approval. A user cannot approve their own suggestion. + operationId: ApproveFlagSuggestion + parameters: + - $ref: "#/components/parameters/suggestion_id" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ReviewFlagSuggestionRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FlagSuggestionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden - Cannot approve your own suggestion + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Approve a flag suggestion + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + - feature_flag_environment_config_read + /api/v2/feature-flags/suggestions/{suggestion_id}/reject: + post: + description: |- + Reject a pending flag change suggestion. The suggested change is not applied. + operationId: RejectFlagSuggestion + parameters: + - $ref: "#/components/parameters/suggestion_id" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ReviewFlagSuggestionRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FlagSuggestionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Reject a flag suggestion + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + - feature_flag_environment_config_read /api/v2/feature-flags/{feature_flag_id}: get: description: |- @@ -92360,6 +92835,65 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/feature-flags/{feature_flag_id}/suggestions: + post: + description: |- + Create a change suggestion for a feature flag. Suggestions require approval + before the change is applied. The request must include at least one + notification_rule_targets handle to receive approval or rejection notifications. + operationId: CreateFlagSuggestion + parameters: + - $ref: "#/components/parameters/feature_flag_id" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateFlagSuggestionRequest" + required: true + responses: + "201": + content: + application/json: + schema: + $ref: "#/components/schemas/FlagSuggestionResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create a flag suggestion + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + - feature_flag_environment_config_read /api/v2/feature-flags/{feature_flag_id}/unarchive: post: description: |- diff --git a/examples/v2/feature-flags/ApproveFlagSuggestion.rb b/examples/v2/feature-flags/ApproveFlagSuggestion.rb new file mode 100644 index 000000000000..e38cf4423bee --- /dev/null +++ b/examples/v2/feature-flags/ApproveFlagSuggestion.rb @@ -0,0 +1,14 @@ +# Approve a flag suggestion returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::ReviewFlagSuggestionRequest.new({ + data: DatadogAPIClient::V2::ReviewFlagSuggestionData.new({ + attributes: DatadogAPIClient::V2::ReviewFlagSuggestionAttributes.new({ + comment: "Looks good, approved!", + }), + type: DatadogAPIClient::V2::FlagSuggestionEventDataType::FLAG_SUGGESTION_EVENTS, + }), +}) +p api_instance.approve_flag_suggestion("550e8400-e29b-41d4-a716-446655440020", body) diff --git a/examples/v2/feature-flags/CreateFlagSuggestion.rb b/examples/v2/feature-flags/CreateFlagSuggestion.rb new file mode 100644 index 000000000000..d7e497afe98a --- /dev/null +++ b/examples/v2/feature-flags/CreateFlagSuggestion.rb @@ -0,0 +1,24 @@ +# Create a flag suggestion returns "Created" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::CreateFlagSuggestionRequest.new({ + data: DatadogAPIClient::V2::CreateFlagSuggestionData.new({ + attributes: DatadogAPIClient::V2::CreateFlagSuggestionAttributes.new({ + action: DatadogAPIClient::V2::FlagSuggestionAction::ARCHIVED, + comment: "Archive this deprecated flag", + environment_id: "550e8400-e29b-41d4-a716-446655440001", + notification_rule_targets: [ + "user@example.com", + ], + property: DatadogAPIClient::V2::FlagSuggestionProperty::FLAG, + suggestion: "ENABLED", + suggestion_metadata: DatadogAPIClient::V2::SuggestionMetadata.new({ + variant_id: "550e8400-e29b-41d4-a716-446655440005", + }), + }), + type: DatadogAPIClient::V2::FlagSuggestionDataType::FLAG_SUGGESTIONS, + }), +}) +p api_instance.create_flag_suggestion("550e8400-e29b-41d4-a716-446655440000", body) diff --git a/examples/v2/feature-flags/DeleteFlagSuggestion.rb b/examples/v2/feature-flags/DeleteFlagSuggestion.rb new file mode 100644 index 000000000000..3b607b102181 --- /dev/null +++ b/examples/v2/feature-flags/DeleteFlagSuggestion.rb @@ -0,0 +1,5 @@ +# Delete a flag suggestion returns "No Content" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new +api_instance.delete_flag_suggestion("550e8400-e29b-41d4-a716-446655440020") diff --git a/examples/v2/feature-flags/GetFlagSuggestion.rb b/examples/v2/feature-flags/GetFlagSuggestion.rb new file mode 100644 index 000000000000..1a96a25292a5 --- /dev/null +++ b/examples/v2/feature-flags/GetFlagSuggestion.rb @@ -0,0 +1,5 @@ +# Get a flag suggestion returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new +p api_instance.get_flag_suggestion("550e8400-e29b-41d4-a716-446655440020") diff --git a/examples/v2/feature-flags/RejectFlagSuggestion.rb b/examples/v2/feature-flags/RejectFlagSuggestion.rb new file mode 100644 index 000000000000..f074f1a34be9 --- /dev/null +++ b/examples/v2/feature-flags/RejectFlagSuggestion.rb @@ -0,0 +1,14 @@ +# Reject a flag suggestion returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::ReviewFlagSuggestionRequest.new({ + data: DatadogAPIClient::V2::ReviewFlagSuggestionData.new({ + attributes: DatadogAPIClient::V2::ReviewFlagSuggestionAttributes.new({ + comment: "Looks good, approved!", + }), + type: DatadogAPIClient::V2::FlagSuggestionEventDataType::FLAG_SUGGESTION_EVENTS, + }), +}) +p api_instance.reject_flag_suggestion("550e8400-e29b-41d4-a716-446655440020", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 2a4f9d05b0e7..595f6cd0994e 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2334,6 +2334,20 @@ "v2.StopExposureSchedule" => { "exposure_schedule_id" => "UUID", }, + "v2.DeleteFlagSuggestion" => { + "suggestion_id" => "UUID", + }, + "v2.GetFlagSuggestion" => { + "suggestion_id" => "UUID", + }, + "v2.ApproveFlagSuggestion" => { + "suggestion_id" => "UUID", + "body" => "ReviewFlagSuggestionRequest", + }, + "v2.RejectFlagSuggestion" => { + "suggestion_id" => "UUID", + "body" => "ReviewFlagSuggestionRequest", + }, "v2.GetFeatureFlag" => { "feature_flag_id" => "UUID", }, @@ -2362,6 +2376,10 @@ "feature_flag_id" => "UUID", "environment_id" => "UUID", }, + "v2.CreateFlagSuggestion" => { + "feature_flag_id" => "UUID", + "body" => "CreateFlagSuggestionRequest", + }, "v2.UnarchiveFeatureFlag" => { "feature_flag_id" => "UUID", }, diff --git a/features/v2/feature_flags.feature b/features/v2/feature_flags.feature index fd2ff16520c5..b2642c78ca51 100644 --- a/features/v2/feature_flags.feature +++ b/features/v2/feature_flags.feature @@ -7,6 +7,30 @@ Feature: Feature Flags And a valid "appKeyAuth" key in the system And an instance of "FeatureFlags" API + @generated @skip @team:DataDog/feature-flags + Scenario: Approve a flag suggestion returns "Bad Request" response + Given new "ApproveFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Approve a flag suggestion returns "Not Found" response + Given new "ApproveFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Approve a flag suggestion returns "OK" response + Given new "ApproveFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/feature-flags Scenario: Archive a feature flag returns "Bad Request" response Given new "ArchiveFeatureFlag" request @@ -53,6 +77,38 @@ Feature: Feature Flags And the response "data.attributes.name" is equal to "Test Feature Flag {{ unique }}" And the response "data.attributes.value_type" is equal to "BOOLEAN" + @generated @skip @team:DataDog/feature-flags + Scenario: Create a flag suggestion returns "Bad Request" response + Given new "CreateFlagSuggestion" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "archived", "comment": "Archive this deprecated flag", "environment_id": "550e8400-e29b-41d4-a716-446655440001", "notification_rule_targets": ["user@example.com"], "property": "FLAG", "suggestion": "ENABLED", "suggestion_metadata": {"variant_id": "550e8400-e29b-41d4-a716-446655440005"}}, "type": "flag-suggestions"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Create a flag suggestion returns "Conflict" response + Given new "CreateFlagSuggestion" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "archived", "comment": "Archive this deprecated flag", "environment_id": "550e8400-e29b-41d4-a716-446655440001", "notification_rule_targets": ["user@example.com"], "property": "FLAG", "suggestion": "ENABLED", "suggestion_metadata": {"variant_id": "550e8400-e29b-41d4-a716-446655440005"}}, "type": "flag-suggestions"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Create a flag suggestion returns "Created" response + Given new "CreateFlagSuggestion" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "archived", "comment": "Archive this deprecated flag", "environment_id": "550e8400-e29b-41d4-a716-446655440001", "notification_rule_targets": ["user@example.com"], "property": "FLAG", "suggestion": "ENABLED", "suggestion_metadata": {"variant_id": "550e8400-e29b-41d4-a716-446655440005"}}, "type": "flag-suggestions"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/feature-flags + Scenario: Create a flag suggestion returns "Not Found" response + Given new "CreateFlagSuggestion" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "archived", "comment": "Archive this deprecated flag", "environment_id": "550e8400-e29b-41d4-a716-446655440001", "notification_rule_targets": ["user@example.com"], "property": "FLAG", "suggestion": "ENABLED", "suggestion_metadata": {"variant_id": "550e8400-e29b-41d4-a716-446655440005"}}, "type": "flag-suggestions"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/feature-flags Scenario: Create allocation for a flag in an environment returns "Created" response Given there is a valid "feature_flag" in the system @@ -130,6 +186,27 @@ Feature: Feature Flags When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a flag suggestion returns "Bad Request" response + Given new "DeleteFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a flag suggestion returns "No Content" response + Given new "DeleteFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a flag suggestion returns "Not Found" response + Given new "DeleteFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/feature-flags Scenario: Delete an environment returns "No Content" response Given there is a valid "environment" in the system @@ -219,6 +296,27 @@ Feature: Feature Flags And the response "data.attributes.name" has the same value as "feature_flag.data.attributes.name" And the response "data.attributes.value_type" has the same value as "feature_flag.data.attributes.value_type" + @generated @skip @team:DataDog/feature-flags + Scenario: Get a flag suggestion returns "Bad Request" response + Given new "GetFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Get a flag suggestion returns "Not Found" response + Given new "GetFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Get a flag suggestion returns "OK" response + Given new "GetFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/feature-flags Scenario: Get an environment returns "Not Found" response Given new "GetFeatureFlagsEnvironment" request @@ -274,6 +372,30 @@ Feature: Feature Flags When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/feature-flags + Scenario: Reject a flag suggestion returns "Bad Request" response + Given new "RejectFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Reject a flag suggestion returns "Not Found" response + Given new "RejectFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Reject a flag suggestion returns "OK" response + Given new "RejectFlagSuggestion" request + And request contains "suggestion_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Looks good, approved!"}, "type": "flag-suggestion-events"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/feature-flags Scenario: Resume a progressive rollout returns "Bad Request" response Given new "ResumeExposureSchedule" request diff --git a/features/v2/undo.json b/features/v2/undo.json index bbfa27e028c6..eae2df8f1b88 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1954,6 +1954,30 @@ "type": "idempotent" } }, + "DeleteFlagSuggestion": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, + "GetFlagSuggestion": { + "tag": "Feature Flags", + "undo": { + "type": "safe" + } + }, + "ApproveFlagSuggestion": { + "tag": "Feature Flags", + "undo": { + "type": "safe" + } + }, + "RejectFlagSuggestion": { + "tag": "Feature Flags", + "undo": { + "type": "safe" + } + }, "GetFeatureFlag": { "tag": "Feature Flags", "undo": { @@ -2003,6 +2027,19 @@ "type": "idempotent" } }, + "CreateFlagSuggestion": { + "tag": "Feature Flags", + "undo": { + "operationId": "DeleteFlagSuggestion", + "parameters": [ + { + "name": "suggestion_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, "UnarchiveFeatureFlag": { "tag": "Feature Flags", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 3c585124997b..b55c2762feb8 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2026,6 +2026,9 @@ def overrides "v2.create_feature_flag_data" => "CreateFeatureFlagData", "v2.create_feature_flag_data_type" => "CreateFeatureFlagDataType", "v2.create_feature_flag_request" => "CreateFeatureFlagRequest", + "v2.create_flag_suggestion_attributes" => "CreateFlagSuggestionAttributes", + "v2.create_flag_suggestion_data" => "CreateFlagSuggestionData", + "v2.create_flag_suggestion_request" => "CreateFlagSuggestionRequest", "v2.create_incident_notification_rule_request" => "CreateIncidentNotificationRuleRequest", "v2.create_incident_notification_template_request" => "CreateIncidentNotificationTemplateRequest", "v2.create_jira_issue_request_array" => "CreateJiraIssueRequestArray", @@ -2700,6 +2703,14 @@ def overrides "v2.finding_status" => "FindingStatus", "v2.finding_type" => "FindingType", "v2.finding_vulnerability_type" => "FindingVulnerabilityType", + "v2.flag_suggestion" => "FlagSuggestion", + "v2.flag_suggestion_action" => "FlagSuggestionAction", + "v2.flag_suggestion_attributes" => "FlagSuggestionAttributes", + "v2.flag_suggestion_data_type" => "FlagSuggestionDataType", + "v2.flag_suggestion_event_data_type" => "FlagSuggestionEventDataType", + "v2.flag_suggestion_property" => "FlagSuggestionProperty", + "v2.flag_suggestion_response" => "FlagSuggestionResponse", + "v2.flag_suggestion_status" => "FlagSuggestionStatus", "v2.flaky_test" => "FlakyTest", "v2.flaky_test_attributes" => "FlakyTestAttributes", "v2.flaky_test_attributes_flaky_state" => "FlakyTestAttributesFlakyState", @@ -4711,6 +4722,9 @@ def overrides "v2.revert_custom_rule_revision_request" => "RevertCustomRuleRevisionRequest", "v2.revert_custom_rule_revision_request_data" => "RevertCustomRuleRevisionRequestData", "v2.revert_custom_rule_revision_request_data_attributes" => "RevertCustomRuleRevisionRequestDataAttributes", + "v2.review_flag_suggestion_attributes" => "ReviewFlagSuggestionAttributes", + "v2.review_flag_suggestion_data" => "ReviewFlagSuggestionData", + "v2.review_flag_suggestion_request" => "ReviewFlagSuggestionRequest", "v2.role" => "Role", "v2.role_attributes" => "RoleAttributes", "v2.role_clone" => "RoleClone", @@ -5568,6 +5582,7 @@ def overrides "v2.step" => "Step", "v2.step_display" => "StepDisplay", "v2.step_display_bounds" => "StepDisplayBounds", + "v2.suggestion_metadata" => "SuggestionMetadata", "v2.suite_create_edit" => "SuiteCreateEdit", "v2.suite_create_edit_request" => "SuiteCreateEditRequest", "v2.suite_json_patch_request" => "SuiteJsonPatchRequest", diff --git a/lib/datadog_api_client/v2/api/feature_flags_api.rb b/lib/datadog_api_client/v2/api/feature_flags_api.rb index 95979845b986..790b7676d444 100644 --- a/lib/datadog_api_client/v2/api/feature_flags_api.rb +++ b/lib/datadog_api_client/v2/api/feature_flags_api.rb @@ -23,6 +23,79 @@ def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end + # Approve a flag suggestion. + # + # @see #approve_flag_suggestion_with_http_info + def approve_flag_suggestion(suggestion_id, body, opts = {}) + data, _status_code, _headers = approve_flag_suggestion_with_http_info(suggestion_id, body, opts) + data + end + + # Approve a flag suggestion. + # + # Approve a pending flag change suggestion. The change is applied immediately + # upon approval. A user cannot approve their own suggestion. + # + # @param suggestion_id [UUID] The ID of the flag suggestion. + # @param body [ReviewFlagSuggestionRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(FlagSuggestionResponse, Integer, Hash)>] FlagSuggestionResponse data, response status code and response headers + def approve_flag_suggestion_with_http_info(suggestion_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.approve_flag_suggestion ...' + end + # verify the required parameter 'suggestion_id' is set + if @api_client.config.client_side_validation && suggestion_id.nil? + fail ArgumentError, "Missing the required parameter 'suggestion_id' when calling FeatureFlagsAPI.approve_flag_suggestion" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.approve_flag_suggestion" + end + # resource path + local_var_path = '/api/v2/feature-flags/suggestions/{suggestion_id}/approve'.sub('{suggestion_id}', CGI.escape(suggestion_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'FlagSuggestionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :approve_flag_suggestion, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#approve_flag_suggestion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Archive a feature flag. # # @see #archive_feature_flag_with_http_info @@ -300,6 +373,80 @@ def create_feature_flags_environment_with_http_info(body, opts = {}) return data, status_code, headers end + # Create a flag suggestion. + # + # @see #create_flag_suggestion_with_http_info + def create_flag_suggestion(feature_flag_id, body, opts = {}) + data, _status_code, _headers = create_flag_suggestion_with_http_info(feature_flag_id, body, opts) + data + end + + # Create a flag suggestion. + # + # Create a change suggestion for a feature flag. Suggestions require approval + # before the change is applied. The request must include at least one + # notification_rule_targets handle to receive approval or rejection notifications. + # + # @param feature_flag_id [UUID] The ID of the feature flag. + # @param body [CreateFlagSuggestionRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(FlagSuggestionResponse, Integer, Hash)>] FlagSuggestionResponse data, response status code and response headers + def create_flag_suggestion_with_http_info(feature_flag_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.create_flag_suggestion ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.create_flag_suggestion" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.create_flag_suggestion" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/suggestions'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'FlagSuggestionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_flag_suggestion, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#create_flag_suggestion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an environment. # # @see #delete_feature_flags_environment_with_http_info @@ -365,6 +512,71 @@ def delete_feature_flags_environment_with_http_info(environment_id, opts = {}) return data, status_code, headers end + # Delete a flag suggestion. + # + # @see #delete_flag_suggestion_with_http_info + def delete_flag_suggestion(suggestion_id, opts = {}) + delete_flag_suggestion_with_http_info(suggestion_id, opts) + nil + end + + # Delete a flag suggestion. + # + # Delete a pending flag change suggestion. Approved suggestions cannot be deleted. + # + # @param suggestion_id [UUID] The ID of the flag suggestion. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_flag_suggestion_with_http_info(suggestion_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.delete_flag_suggestion ...' + end + # verify the required parameter 'suggestion_id' is set + if @api_client.config.client_side_validation && suggestion_id.nil? + fail ArgumentError, "Missing the required parameter 'suggestion_id' when calling FeatureFlagsAPI.delete_flag_suggestion" + end + # resource path + local_var_path = '/api/v2/feature-flags/suggestions/{suggestion_id}'.sub('{suggestion_id}', CGI.escape(suggestion_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_flag_suggestion, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#delete_flag_suggestion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Disable a feature flag in an environment. # # @see #disable_feature_flag_environment_with_http_info @@ -636,6 +848,71 @@ def get_feature_flags_environment_with_http_info(environment_id, opts = {}) return data, status_code, headers end + # Get a flag suggestion. + # + # @see #get_flag_suggestion_with_http_info + def get_flag_suggestion(suggestion_id, opts = {}) + data, _status_code, _headers = get_flag_suggestion_with_http_info(suggestion_id, opts) + data + end + + # Get a flag suggestion. + # + # Get a flag change suggestion by ID. + # + # @param suggestion_id [UUID] The ID of the flag suggestion. + # @param opts [Hash] the optional parameters + # @return [Array<(FlagSuggestionResponse, Integer, Hash)>] FlagSuggestionResponse data, response status code and response headers + def get_flag_suggestion_with_http_info(suggestion_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.get_flag_suggestion ...' + end + # verify the required parameter 'suggestion_id' is set + if @api_client.config.client_side_validation && suggestion_id.nil? + fail ArgumentError, "Missing the required parameter 'suggestion_id' when calling FeatureFlagsAPI.get_flag_suggestion" + end + # resource path + local_var_path = '/api/v2/feature-flags/suggestions/{suggestion_id}'.sub('{suggestion_id}', CGI.escape(suggestion_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'FlagSuggestionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_flag_suggestion, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#get_flag_suggestion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List feature flags. # # @see #list_feature_flags_with_http_info @@ -857,6 +1134,78 @@ def pause_exposure_schedule_with_http_info(exposure_schedule_id, opts = {}) return data, status_code, headers end + # Reject a flag suggestion. + # + # @see #reject_flag_suggestion_with_http_info + def reject_flag_suggestion(suggestion_id, body, opts = {}) + data, _status_code, _headers = reject_flag_suggestion_with_http_info(suggestion_id, body, opts) + data + end + + # Reject a flag suggestion. + # + # Reject a pending flag change suggestion. The suggested change is not applied. + # + # @param suggestion_id [UUID] The ID of the flag suggestion. + # @param body [ReviewFlagSuggestionRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(FlagSuggestionResponse, Integer, Hash)>] FlagSuggestionResponse data, response status code and response headers + def reject_flag_suggestion_with_http_info(suggestion_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.reject_flag_suggestion ...' + end + # verify the required parameter 'suggestion_id' is set + if @api_client.config.client_side_validation && suggestion_id.nil? + fail ArgumentError, "Missing the required parameter 'suggestion_id' when calling FeatureFlagsAPI.reject_flag_suggestion" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.reject_flag_suggestion" + end + # resource path + local_var_path = '/api/v2/feature-flags/suggestions/{suggestion_id}/reject'.sub('{suggestion_id}', CGI.escape(suggestion_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'FlagSuggestionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :reject_flag_suggestion, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#reject_flag_suggestion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Resume a progressive rollout. # # @see #resume_exposure_schedule_with_http_info diff --git a/lib/datadog_api_client/v2/models/create_flag_suggestion_attributes.rb b/lib/datadog_api_client/v2/models/create_flag_suggestion_attributes.rb new file mode 100644 index 000000000000..38007b5e7cfb --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_flag_suggestion_attributes.rb @@ -0,0 +1,212 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes for creating a flag suggestion. + class CreateFlagSuggestionAttributes + include BaseGenericModel + + # The type of change action for a suggestion. + attr_reader :action + + # Optional comment explaining the change. + attr_accessor :comment + + # The environment ID for environment-scoped changes. + attr_accessor :environment_id + + # Notification handles (without @ prefix) to receive approval or rejection notifications. + # For example, an email address or Slack channel name. + attr_reader :notification_rule_targets + + # The flag property being changed. + attr_reader :property + + # The suggested new value (empty string for flag-level actions like archive, JSON-encoded for complex properties like allocations). + attr_accessor :suggestion + + # Optional metadata for a suggestion. + attr_accessor :suggestion_metadata + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'action' => :'action', + :'comment' => :'comment', + :'environment_id' => :'environment_id', + :'notification_rule_targets' => :'notification_rule_targets', + :'property' => :'property', + :'suggestion' => :'suggestion', + :'suggestion_metadata' => :'suggestion_metadata' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'action' => :'FlagSuggestionAction', + :'comment' => :'String', + :'environment_id' => :'UUID', + :'notification_rule_targets' => :'Array', + :'property' => :'FlagSuggestionProperty', + :'suggestion' => :'String', + :'suggestion_metadata' => :'SuggestionMetadata' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CreateFlagSuggestionAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'comment') + self.comment = attributes[:'comment'] + end + + if attributes.key?(:'environment_id') + self.environment_id = attributes[:'environment_id'] + end + + if attributes.key?(:'notification_rule_targets') + if (value = attributes[:'notification_rule_targets']).is_a?(Array) + self.notification_rule_targets = value + end + end + + if attributes.key?(:'property') + self.property = attributes[:'property'] + end + + if attributes.key?(:'suggestion') + self.suggestion = attributes[:'suggestion'] + end + + if attributes.key?(:'suggestion_metadata') + self.suggestion_metadata = attributes[:'suggestion_metadata'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @action.nil? + return false if @notification_rule_targets.nil? + return false if @notification_rule_targets.length < 1 + return false if @property.nil? + true + end + + # Custom attribute writer method with validation + # @param action [Object] Object to be assigned + # @!visibility private + def action=(action) + if action.nil? + fail ArgumentError, 'invalid value for "action", action cannot be nil.' + end + @action = action + end + + # Custom attribute writer method with validation + # @param notification_rule_targets [Object] Object to be assigned + # @!visibility private + def notification_rule_targets=(notification_rule_targets) + if notification_rule_targets.nil? + fail ArgumentError, 'invalid value for "notification_rule_targets", notification_rule_targets cannot be nil.' + end + if notification_rule_targets.length < 1 + fail ArgumentError, 'invalid value for "notification_rule_targets", number of items must be greater than or equal to 1.' + end + @notification_rule_targets = notification_rule_targets + end + + # Custom attribute writer method with validation + # @param property [Object] Object to be assigned + # @!visibility private + def property=(property) + if property.nil? + fail ArgumentError, 'invalid value for "property", property cannot be nil.' + end + @property = property + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + action == o.action && + comment == o.comment && + environment_id == o.environment_id && + notification_rule_targets == o.notification_rule_targets && + property == o.property && + suggestion == o.suggestion && + suggestion_metadata == o.suggestion_metadata && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [action, comment, environment_id, notification_rule_targets, property, suggestion, suggestion_metadata, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_flag_suggestion_data.rb b/lib/datadog_api_client/v2/models/create_flag_suggestion_data.rb new file mode 100644 index 000000000000..124ecfad9033 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_flag_suggestion_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data for creating a flag suggestion. + class CreateFlagSuggestionData + include BaseGenericModel + + # Attributes for creating a flag suggestion. + attr_reader :attributes + + # Flag suggestions resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'CreateFlagSuggestionAttributes', + :'type' => :'FlagSuggestionDataType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CreateFlagSuggestionData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_flag_suggestion_request.rb b/lib/datadog_api_client/v2/models/create_flag_suggestion_request.rb new file mode 100644 index 000000000000..e5cdc01e6480 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_flag_suggestion_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request to create a flag suggestion. + class CreateFlagSuggestionRequest + include BaseGenericModel + + # Data for creating a flag suggestion. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'CreateFlagSuggestionData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CreateFlagSuggestionRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion.rb b/lib/datadog_api_client/v2/models/flag_suggestion.rb new file mode 100644 index 000000000000..c40b4252dbb9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A flag change suggestion. + class FlagSuggestion + include BaseGenericModel + + # Attributes of a flag suggestion. + attr_reader :attributes + + # Unique identifier for the suggestion. + attr_reader :id + + # Flag suggestions resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'FlagSuggestionAttributes', + :'id' => :'UUID', + :'type' => :'FlagSuggestionDataType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::FlagSuggestion` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_action.rb b/lib/datadog_api_client/v2/models/flag_suggestion_action.rb new file mode 100644 index 000000000000..f1656f13a4e7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_action.rb @@ -0,0 +1,34 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of change action for a suggestion. + class FlagSuggestionAction + include BaseEnumModel + + CREATED = "created".freeze + UPDATED = "updated".freeze + DELETED = "deleted".freeze + ARCHIVED = "archived".freeze + UNARCHIVED = "unarchived".freeze + STARTED = "started".freeze + STOPPED = "stopped".freeze + PAUSED = "paused".freeze + UNPAUSED = "unpaused".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_attributes.rb b/lib/datadog_api_client/v2/models/flag_suggestion_attributes.rb new file mode 100644 index 000000000000..8d09ffc66f66 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_attributes.rb @@ -0,0 +1,351 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes of a flag suggestion. + class FlagSuggestionAttributes + include BaseGenericModel + + # The type of change action for a suggestion. + attr_reader :action + + # The flag history version this suggestion was based on. + attr_accessor :base_flag_history_id + + # Optional comment from the requester. + attr_accessor :comment + + # When the suggestion was created. + attr_reader :created_at + + # UUID of the user who created the suggestion. + attr_reader :created_by + + # The status of a flag suggestion. + attr_reader :current_status + + # The current value before the suggested change (empty string for flag-level actions like archive). + attr_accessor :current_value + + # When the suggestion was soft-deleted. + attr_accessor :deleted_at + + # UUID of the user who deleted the suggestion. + attr_accessor :deleted_by + + # The environment ID for environment-scoped suggestions. Null for flag-level changes. + attr_accessor :environment_id + + # The ID of the feature flag this suggestion applies to. + attr_reader :feature_flag_id + + # Human-readable message about the suggestion (populated on auto-created suggestions). + attr_accessor :message + + # The flag property being changed. + attr_reader :property + + # The suggested new value (JSON-encoded for complex properties, empty string for flag-level actions like archive). + attr_accessor :suggestion + + # Optional metadata for a suggestion. + attr_accessor :suggestion_metadata + + # When the suggestion was last updated. + attr_accessor :updated_at + + # UUID of the user who last updated the suggestion. + attr_accessor :updated_by + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'action' => :'action', + :'base_flag_history_id' => :'base_flag_history_id', + :'comment' => :'comment', + :'created_at' => :'created_at', + :'created_by' => :'created_by', + :'current_status' => :'current_status', + :'current_value' => :'current_value', + :'deleted_at' => :'deleted_at', + :'deleted_by' => :'deleted_by', + :'environment_id' => :'environment_id', + :'feature_flag_id' => :'feature_flag_id', + :'message' => :'message', + :'property' => :'property', + :'suggestion' => :'suggestion', + :'suggestion_metadata' => :'suggestion_metadata', + :'updated_at' => :'updated_at', + :'updated_by' => :'updated_by' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'action' => :'FlagSuggestionAction', + :'base_flag_history_id' => :'UUID', + :'comment' => :'String', + :'created_at' => :'Time', + :'created_by' => :'UUID', + :'current_status' => :'FlagSuggestionStatus', + :'current_value' => :'String', + :'deleted_at' => :'Time', + :'deleted_by' => :'String', + :'environment_id' => :'String', + :'feature_flag_id' => :'UUID', + :'message' => :'String', + :'property' => :'FlagSuggestionProperty', + :'suggestion' => :'String', + :'suggestion_metadata' => :'SuggestionMetadata', + :'updated_at' => :'Time', + :'updated_by' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'comment', + :'deleted_at', + :'deleted_by', + :'environment_id', + :'updated_at', + :'updated_by', + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::FlagSuggestionAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'base_flag_history_id') + self.base_flag_history_id = attributes[:'base_flag_history_id'] + end + + if attributes.key?(:'comment') + self.comment = attributes[:'comment'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'created_by') + self.created_by = attributes[:'created_by'] + end + + if attributes.key?(:'current_status') + self.current_status = attributes[:'current_status'] + end + + if attributes.key?(:'current_value') + self.current_value = attributes[:'current_value'] + end + + if attributes.key?(:'deleted_at') + self.deleted_at = attributes[:'deleted_at'] + end + + if attributes.key?(:'deleted_by') + self.deleted_by = attributes[:'deleted_by'] + end + + if attributes.key?(:'environment_id') + self.environment_id = attributes[:'environment_id'] + end + + if attributes.key?(:'feature_flag_id') + self.feature_flag_id = attributes[:'feature_flag_id'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + + if attributes.key?(:'property') + self.property = attributes[:'property'] + end + + if attributes.key?(:'suggestion') + self.suggestion = attributes[:'suggestion'] + end + + if attributes.key?(:'suggestion_metadata') + self.suggestion_metadata = attributes[:'suggestion_metadata'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'updated_by') + self.updated_by = attributes[:'updated_by'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @action.nil? + return false if @created_at.nil? + return false if @created_by.nil? + return false if @current_status.nil? + return false if @feature_flag_id.nil? + return false if @property.nil? + true + end + + # Custom attribute writer method with validation + # @param action [Object] Object to be assigned + # @!visibility private + def action=(action) + if action.nil? + fail ArgumentError, 'invalid value for "action", action cannot be nil.' + end + @action = action + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param created_by [Object] Object to be assigned + # @!visibility private + def created_by=(created_by) + if created_by.nil? + fail ArgumentError, 'invalid value for "created_by", created_by cannot be nil.' + end + @created_by = created_by + end + + # Custom attribute writer method with validation + # @param current_status [Object] Object to be assigned + # @!visibility private + def current_status=(current_status) + if current_status.nil? + fail ArgumentError, 'invalid value for "current_status", current_status cannot be nil.' + end + @current_status = current_status + end + + # Custom attribute writer method with validation + # @param feature_flag_id [Object] Object to be assigned + # @!visibility private + def feature_flag_id=(feature_flag_id) + if feature_flag_id.nil? + fail ArgumentError, 'invalid value for "feature_flag_id", feature_flag_id cannot be nil.' + end + @feature_flag_id = feature_flag_id + end + + # Custom attribute writer method with validation + # @param property [Object] Object to be assigned + # @!visibility private + def property=(property) + if property.nil? + fail ArgumentError, 'invalid value for "property", property cannot be nil.' + end + @property = property + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + action == o.action && + base_flag_history_id == o.base_flag_history_id && + comment == o.comment && + created_at == o.created_at && + created_by == o.created_by && + current_status == o.current_status && + current_value == o.current_value && + deleted_at == o.deleted_at && + deleted_by == o.deleted_by && + environment_id == o.environment_id && + feature_flag_id == o.feature_flag_id && + message == o.message && + property == o.property && + suggestion == o.suggestion && + suggestion_metadata == o.suggestion_metadata && + updated_at == o.updated_at && + updated_by == o.updated_by && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [action, base_flag_history_id, comment, created_at, created_by, current_status, current_value, deleted_at, deleted_by, environment_id, feature_flag_id, message, property, suggestion, suggestion_metadata, updated_at, updated_by, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_data_type.rb b/lib/datadog_api_client/v2/models/flag_suggestion_data_type.rb new file mode 100644 index 000000000000..69e329c9792e --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_data_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Flag suggestions resource type. + class FlagSuggestionDataType + include BaseEnumModel + + FLAG_SUGGESTIONS = "flag-suggestions".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_event_data_type.rb b/lib/datadog_api_client/v2/models/flag_suggestion_event_data_type.rb new file mode 100644 index 000000000000..25ed0dc252be --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_event_data_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Flag suggestion events resource type. + class FlagSuggestionEventDataType + include BaseEnumModel + + FLAG_SUGGESTION_EVENTS = "flag-suggestion-events".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_property.rb b/lib/datadog_api_client/v2/models/flag_suggestion_property.rb new file mode 100644 index 000000000000..4d30ce4a713c --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_property.rb @@ -0,0 +1,38 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The flag property being changed. + class FlagSuggestionProperty + include BaseEnumModel + + FLAG = "FLAG".freeze + FLAG_NAME = "FLAG_NAME".freeze + FLAG_DESCRIPTION = "FLAG_DESCRIPTION".freeze + JSON_SCHEMA = "JSON_SCHEMA".freeze + DISTRIBUTION_CHANNEL = "DISTRIBUTION_CHANNEL".freeze + VARIANT = "VARIANT".freeze + VARIANT_NAME = "VARIANT_NAME".freeze + VARIANT_VALUE = "VARIANT_VALUE".freeze + ALLOCATIONS = "ALLOCATIONS".freeze + ROLLOUT = "ROLLOUT".freeze + ENVIRONMENT_STATUS = "ENVIRONMENT_STATUS".freeze + DEFAULT_VARIANT = "DEFAULT_VARIANT".freeze + OVERRIDE_VARIANT = "OVERRIDE_VARIANT".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_response.rb b/lib/datadog_api_client/v2/models/flag_suggestion_response.rb new file mode 100644 index 000000000000..47335ef473b4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_response.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response containing a flag suggestion. + class FlagSuggestionResponse + include BaseGenericModel + + # A flag change suggestion. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'FlagSuggestion' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::FlagSuggestionResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flag_suggestion_status.rb b/lib/datadog_api_client/v2/models/flag_suggestion_status.rb new file mode 100644 index 000000000000..6c4d85c32216 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flag_suggestion_status.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The status of a flag suggestion. + class FlagSuggestionStatus + include BaseEnumModel + + PENDING = "pending".freeze + REJECTED = "rejected".freeze + APPROVED = "approved".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/review_flag_suggestion_attributes.rb b/lib/datadog_api_client/v2/models/review_flag_suggestion_attributes.rb new file mode 100644 index 000000000000..936aa85be6c7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/review_flag_suggestion_attributes.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes for reviewing a flag suggestion. + class ReviewFlagSuggestionAttributes + include BaseGenericModel + + # Optional comment from the reviewer. + attr_accessor :comment + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'comment' => :'comment' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'comment' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ReviewFlagSuggestionAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'comment') + self.comment = attributes[:'comment'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + comment == o.comment && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [comment, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/review_flag_suggestion_data.rb b/lib/datadog_api_client/v2/models/review_flag_suggestion_data.rb new file mode 100644 index 000000000000..50d20981153f --- /dev/null +++ b/lib/datadog_api_client/v2/models/review_flag_suggestion_data.rb @@ -0,0 +1,133 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data for reviewing a flag suggestion. + class ReviewFlagSuggestionData + include BaseGenericModel + + # Attributes for reviewing a flag suggestion. + attr_accessor :attributes + + # Flag suggestion events resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ReviewFlagSuggestionAttributes', + :'type' => :'FlagSuggestionEventDataType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ReviewFlagSuggestionData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/review_flag_suggestion_request.rb b/lib/datadog_api_client/v2/models/review_flag_suggestion_request.rb new file mode 100644 index 000000000000..77baff04e946 --- /dev/null +++ b/lib/datadog_api_client/v2/models/review_flag_suggestion_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request to approve or reject a flag suggestion. + class ReviewFlagSuggestionRequest + include BaseGenericModel + + # Data for reviewing a flag suggestion. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'ReviewFlagSuggestionData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ReviewFlagSuggestionRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/suggestion_metadata.rb b/lib/datadog_api_client/v2/models/suggestion_metadata.rb new file mode 100644 index 000000000000..a65f15f680d2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/suggestion_metadata.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Optional metadata for a suggestion. + class SuggestionMetadata + include BaseGenericModel + + # Variant ID for variant delete suggestions. + attr_accessor :variant_id + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'variant_id' => :'variant_id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'variant_id' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::SuggestionMetadata` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'variant_id') + self.variant_id = attributes[:'variant_id'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + variant_id == o.variant_id && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [variant_id, additional_properties].hash + end + end +end