diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 45672b441bd..e83df8269e5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1277,6 +1277,15 @@ components: example: "550e8400-e29b-41d4-a716-446655440001" format: uuid type: string + exposure_schedule_id: + description: The ID of the exposure schedule. + in: path + name: exposure_schedule_id + required: true + schema: + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string feature_flag_id: description: The ID of the feature flag. in: path @@ -3348,6 +3357,334 @@ components: - WARN - ERROR - OK + Allocation: + description: Targeting rule (allocation) details for a feature flag environment. + properties: + created_at: + description: The timestamp when the targeting rule allocation was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + environment_ids: + description: Environment IDs associated with this targeting rule allocation. + example: + - "550e8400-e29b-41d4-a716-446655440001" + items: + description: Environment ID linked to this targeting rule allocation. + format: uuid + type: string + type: array + experiment_id: + description: The experiment ID linked to this targeting rule allocation. + example: "550e8400-e29b-41d4-a716-446655440030" + nullable: true + type: string + exposure_schedule: + $ref: "#/components/schemas/AllocationExposureSchedule" + guardrail_metrics: + description: Guardrail metrics associated with this targeting rule allocation. + items: + $ref: "#/components/schemas/GuardrailMetric" + type: array + id: + description: The unique identifier of the targeting rule allocation. + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string + key: + description: The unique key of the targeting rule allocation. + example: "prod-rollout" + type: string + name: + description: The display name of the targeting rule. + example: "Production Rollout" + type: string + order_position: + description: Sort order position within the environment. + example: 0 + format: int64 + type: integer + targeting_rules: + description: Conditions associated with this targeting rule allocation. + items: + $ref: "#/components/schemas/TargetingRule" + type: array + type: + $ref: "#/components/schemas/AllocationType" + updated_at: + description: The timestamp when the targeting rule allocation was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + variant_weights: + description: Weighted variant assignments for this targeting rule allocation. + items: + $ref: "#/components/schemas/VariantWeight" + type: array + required: + - name + - key + - targeting_rules + - variant_weights + - order_position + - environment_ids + - type + - guardrail_metrics + - created_at + - updated_at + type: object + AllocationDataRequest: + description: Data wrapper for allocation request payloads. + properties: + attributes: + $ref: "#/components/schemas/UpsertAllocationRequest" + type: + $ref: "#/components/schemas/AllocationDataType" + required: + - type + - attributes + type: object + AllocationDataResponse: + description: Data wrapper for targeting rule allocation responses. + properties: + attributes: + $ref: "#/components/schemas/Allocation" + id: + description: The unique identifier of the targeting rule allocation. + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string + type: + $ref: "#/components/schemas/AllocationDataType" + required: + - id + - type + - attributes + type: object + AllocationDataType: + description: The resource type. + enum: + - "allocations" + example: "allocations" + type: string + x-enum-varnames: + - ALLOCATIONS + AllocationExposureGuardrailTrigger: + description: Guardrail trigger details for a progressive rollout. + properties: + allocation_exposure_schedule_id: + description: The progressive rollout ID this trigger belongs to. + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string + created_at: + description: The timestamp when this trigger was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + flagging_variant_id: + description: The variant ID that triggered this event. + example: "550e8400-e29b-41d4-a716-446655440001" + format: uuid + type: string + id: + description: The unique identifier of the guardrail trigger. + example: "550e8400-e29b-41d4-a716-446655440080" + format: uuid + type: string + metric_id: + description: The metric ID associated with the trigger. + example: "metric-error-rate" + type: string + triggered_action: + description: The action that was triggered. + example: "PAUSE" + type: string + updated_at: + description: The timestamp when this trigger was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + required: + - id + - allocation_exposure_schedule_id + - flagging_variant_id + - metric_id + - triggered_action + - created_at + - updated_at + type: object + AllocationExposureRolloutStep: + description: Exposure progression step details. + properties: + allocation_exposure_schedule_id: + description: The progressive rollout ID this step belongs to. + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string + created_at: + description: The timestamp when the progression step was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + exposure_ratio: + description: The exposure ratio for this step. + example: 0.1 + format: double + maximum: 1 + minimum: 0 + type: number + grouped_step_index: + description: Logical index grouping related steps. + example: 0 + format: int64 + minimum: 0 + type: integer + id: + description: The unique identifier of the progression step. + example: "550e8400-e29b-41d4-a716-446655440040" + format: uuid + type: string + interval_ms: + description: Step duration in milliseconds. + example: 3600000 + format: int64 + nullable: true + type: integer + is_pause_record: + description: Whether this step represents a pause record. + example: false + type: boolean + order_position: + description: Sort order for the progression step. + example: 0 + format: int64 + type: integer + updated_at: + description: The timestamp when the progression step was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + required: + - id + - allocation_exposure_schedule_id + - order_position + - exposure_ratio + - is_pause_record + - grouped_step_index + - created_at + - updated_at + type: object + AllocationExposureSchedule: + description: Progressive release details for a targeting rule allocation. + properties: + absolute_start_time: + description: The absolute UTC start time for this schedule. + example: "2025-06-13T12:00:00Z" + format: date-time + nullable: true + type: string + allocation_id: + description: The targeting rule allocation ID this progressive rollout belongs to. + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string + control_variant_id: + description: The control variant ID used for experiment comparisons. + example: "550e8400-e29b-41d4-a716-446655440012" + nullable: true + type: string + created_at: + description: The timestamp when the schedule was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + guardrail_triggered_action: + description: Last guardrail action triggered for this schedule. + example: "PAUSE" + nullable: true + type: string + guardrail_triggers: + description: Guardrail trigger records for this schedule. + items: + $ref: "#/components/schemas/AllocationExposureGuardrailTrigger" + type: array + id: + description: The unique identifier of the progressive rollout. + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string + rollout_options: + $ref: "#/components/schemas/RolloutOptions" + rollout_steps: + description: Ordered progression steps for exposure. + items: + $ref: "#/components/schemas/AllocationExposureRolloutStep" + type: array + updated_at: + description: The timestamp when the schedule was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + required: + - allocation_id + - rollout_options + - rollout_steps + - guardrail_triggers + - created_at + - updated_at + type: object + AllocationExposureScheduleData: + description: Data wrapper for progressive rollout schedule responses. + properties: + attributes: + $ref: "#/components/schemas/AllocationExposureSchedule" + id: + description: The unique identifier of the progressive rollout. + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string + type: + $ref: "#/components/schemas/AllocationExposureScheduleDataType" + required: + - id + - type + - attributes + type: object + AllocationExposureScheduleDataType: + description: The resource type for progressive rollout schedules. + enum: + - "allocation_exposure_schedules" + example: "allocation_exposure_schedules" + type: string + x-enum-varnames: + - ALLOCATION_EXPOSURE_SCHEDULES + AllocationExposureScheduleResponse: + description: Response containing a progressive rollout schedule. + properties: + data: + $ref: "#/components/schemas/AllocationExposureScheduleData" + required: + - data + type: object + AllocationResponse: + description: Response containing a single targeting rule (allocation). + properties: + data: + $ref: "#/components/schemas/AllocationDataResponse" + required: + - data + type: object + AllocationType: + description: The type of targeting rule (called allocation in the API model). + enum: + - FEATURE_GATE + - CANARY + example: "FEATURE_GATE" + type: string + x-enum-varnames: + - FEATURE_GATE + - CANARY Annotation: description: "A list of annotations used in the workflow. These are like sticky notes for your workflow!" properties: @@ -12764,6 +13101,92 @@ components: - SEARCH - CONTAINER - CALLOUTVALUE + Condition: + description: Targeting condition details. + properties: + attribute: + description: The user or request attribute to evaluate. + example: "country" + type: string + created_at: + description: The timestamp when the condition was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + id: + description: The unique identifier of the condition. + example: "550e8400-e29b-41d4-a716-446655440070" + format: uuid + type: string + operator: + $ref: "#/components/schemas/ConditionOperator" + updated_at: + description: The timestamp when the condition was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + value: + description: Values used by the selected operator. + example: ["US", "CA"] + items: + description: Target value for the selected operator. + type: string + type: array + required: + - id + - operator + - attribute + - value + - created_at + - updated_at + type: object + ConditionOperator: + description: The operator used in a targeting condition. + enum: + - LT + - LTE + - GT + - GTE + - MATCHES + - NOT_MATCHES + - ONE_OF + - NOT_ONE_OF + - IS_NULL + - EQUALS + example: "ONE_OF" + type: string + x-enum-varnames: + - LT + - LTE + - GT + - GTE + - MATCHES + - NOT_MATCHES + - ONE_OF + - NOT_ONE_OF + - IS_NULL + - EQUALS + ConditionRequest: + description: Condition request payload for targeting rules. + properties: + attribute: + description: The user or request attribute to evaluate. + example: "user_tier" + type: string + operator: + $ref: "#/components/schemas/ConditionOperator" + value: + description: Values used by the selected operator. + example: ["premium", "enterprise"] + items: + description: Target value for the selected operator. + type: string + type: array + required: + - operator + - attribute + - value + type: object ConfigCatCredentials: description: The definition of the `ConfigCatCredentials` object. oneOf: @@ -14190,6 +14613,14 @@ components: data: $ref: "#/components/schemas/ActionConnectionData" type: object + CreateAllocationsRequest: + description: Request to create targeting rules (allocations) for a feature flag in an environment. + properties: + data: + $ref: "#/components/schemas/AllocationDataRequest" + required: + - data + type: object CreateAppRequest: description: A request object for creating a new app. example: @@ -24613,6 +25044,78 @@ components: example: "One or several indexes are missing or invalid. Results hold data from the other indexes." type: string type: object + ExposureRolloutStepRequest: + description: Rollout step request payload. + properties: + exposure_ratio: + description: The exposure ratio for this step. + example: 0.5 + format: double + maximum: 1 + minimum: 0 + type: number + grouped_step_index: + description: Logical index grouping related steps. + example: 1 + format: int64 + minimum: 0 + type: integer + id: + description: The unique identifier of the progression step. + example: "550e8400-e29b-41d4-a716-446655440040" + format: uuid + type: string + interval_ms: + description: Step duration in milliseconds. + example: 3600000 + format: int64 + nullable: true + type: integer + is_pause_record: + description: Whether this step represents a pause record. + example: false + type: boolean + required: + - exposure_ratio + - is_pause_record + - grouped_step_index + type: object + ExposureScheduleRequest: + description: Progressive release request payload. + properties: + absolute_start_time: + description: The absolute UTC start time for this schedule. + example: "2025-06-13T12:00:00Z" + format: date-time + nullable: true + type: string + control_variant_id: + description: The control variant ID used for experiment comparisons. + example: "550e8400-e29b-41d4-a716-446655440012" + nullable: true + type: string + control_variant_key: + description: The control variant key used during creation workflows. + example: "control" + nullable: true + type: string + id: + description: The unique identifier of the progressive rollout. + example: "550e8400-e29b-41d4-a716-446655440010" + format: uuid + type: string + rollout_options: + $ref: "#/components/schemas/RolloutOptionsRequest" + rollout_steps: + description: Ordered progression steps for exposure. + items: + $ref: "#/components/schemas/ExposureRolloutStepRequest" + minItems: 1 + type: array + required: + - rollout_options + - rollout_steps + type: object FacetInfoRequest: description: Request body for retrieving facet value information for a specified attribute with optional filtering. example: @@ -25109,6 +25612,12 @@ components: description: Indicates whether this feature flag requires approval for changes. example: false type: boolean + tags: + description: Tags associated with the feature flag. + example: [] + items: + type: string + type: array updated_at: description: The timestamp when the feature flag was last updated. example: "2023-01-01T00:00:00Z" @@ -25154,6 +25663,14 @@ components: description: The name of the environment. example: "env-search-term" type: string + environment_queries: + description: Queries that target this environment. + example: + - "test-feature-flag" + - "env-search-term" + items: + type: string + type: array is_production: description: Indicates whether the environment is production. example: false @@ -29346,6 +29863,47 @@ components: example: "env:production" type: string type: array + GuardrailMetric: + description: Guardrail metric details. + properties: + metric_id: + description: The metric ID to monitor. + example: "metric-error-rate" + type: string + trigger_action: + $ref: "#/components/schemas/GuardrailTriggerAction" + triggered_by: + description: The signal or system that triggered the action. + example: "guardrail_monitor" + nullable: true + type: string + required: + - metric_id + - trigger_action + type: object + GuardrailMetricRequest: + description: Guardrail metric request payload. + properties: + metric_id: + description: The metric ID to monitor. + example: "metric-error-rate" + type: string + trigger_action: + $ref: "#/components/schemas/GuardrailTriggerAction" + required: + - metric_id + - trigger_action + type: object + GuardrailTriggerAction: + description: Action to perform when a guardrail threshold is triggered. + enum: + - PAUSE + - ABORT + example: "PAUSE" + type: string + x-enum-varnames: + - PAUSE + - ABORT HTTPBody: description: The definition of `HTTPBody` object. properties: @@ -36653,6 +37211,18 @@ components: format: int64 type: integer type: object + ListAllocationsResponse: + description: Response containing a list of targeting rules (allocations). + properties: + data: + description: List of targeting rules (allocations). + items: + $ref: "#/components/schemas/AllocationDataResponse" + description: Allocation item. + type: array + required: + - data + type: object ListAppKeyRegistrationsResponse: description: A paginated list of app key registrations. properties: @@ -47881,6 +48451,17 @@ components: - ARRAY_NUMBER - ARRAY_BOOLEAN - ARRAY_OBJECT + OverwriteAllocationsRequest: + description: Request to overwrite targeting rules (allocations) for a feature flag in an environment. + properties: + data: + description: Targeting rules (allocations) to replace existing ones with. + items: + $ref: "#/components/schemas/AllocationDataRequest" + type: array + required: + - data + type: object PageUrgency: default: high description: On-Call Page urgency level. @@ -53648,6 +54229,53 @@ components: type: string x-enum-varnames: - ROLES + RolloutOptions: + description: Applied progression options for a progressive rollout. + properties: + autostart: + description: Whether the schedule starts automatically. + example: false + type: boolean + selection_interval_ms: + description: Interval in milliseconds for uniform interval strategies. + example: 3600000 + format: int64 + type: integer + strategy: + $ref: "#/components/schemas/RolloutStrategy" + required: + - strategy + - autostart + - selection_interval_ms + type: object + RolloutOptionsRequest: + description: Rollout options request payload. + properties: + autostart: + description: Whether the schedule should begin automatically. + example: false + nullable: true + type: boolean + selection_interval_ms: + description: Interval in milliseconds for uniform interval strategies. + example: 3600000 + format: int64 + type: integer + strategy: + $ref: "#/components/schemas/RolloutStrategy" + required: + - strategy + type: object + RolloutStrategy: + description: The progression strategy used by a progressive rollout. + enum: + - UNIFORM_INTERVALS + - NO_ROLLOUT + example: "UNIFORM_INTERVALS" + type: string + x-enum-varnames: + - UNIFORM_INTERVALS + - NO_ROLLOUT RoutingRule: description: Represents a routing rule, including its attributes, relationships, and unique identifier. properties: @@ -67088,6 +67716,47 @@ components: description: Tag associated with your event. type: string type: array + TargetingRule: + description: Targeting rule details. + properties: + conditions: + description: Conditions evaluated by this targeting rule. + items: + $ref: "#/components/schemas/Condition" + type: array + created_at: + description: The timestamp when the targeting rule was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + id: + description: The unique identifier of the targeting rule. + example: "550e8400-e29b-41d4-a716-446655440060" + format: uuid + type: string + updated_at: + description: The timestamp when the targeting rule was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + required: + - id + - conditions + - created_at + - updated_at + type: object + TargetingRuleRequest: + description: Targeting rule request payload. + properties: + conditions: + description: Conditions that must match for this rule. + items: + $ref: "#/components/schemas/ConditionRequest" + minItems: 1 + type: array + required: + - conditions + type: object Targets: description: |- List of recipients to notify when a notification rule is triggered. Many different target types are supported, @@ -71274,6 +71943,51 @@ components: data: $ref: "#/components/schemas/WorkflowDataUpdate" type: object + UpsertAllocationRequest: + description: Request to create or update a targeting rule (allocation) for a feature flag environment. + properties: + experiment_id: + description: The experiment ID for experiment-linked allocations. + example: "550e8400-e29b-41d4-a716-446655440030" + nullable: true + type: string + exposure_schedule: + $ref: "#/components/schemas/ExposureScheduleRequest" + guardrail_metrics: + description: Guardrail metrics used to monitor and auto-pause or abort. + items: + $ref: "#/components/schemas/GuardrailMetricRequest" + type: array + id: + description: The unique identifier of the targeting rule allocation. + example: "550e8400-e29b-41d4-a716-446655440020" + format: uuid + type: string + key: + description: The unique key of the targeting rule allocation. + example: "prod-rollout" + type: string + name: + description: The display name of the targeting rule. + example: "Production Rollout" + type: string + targeting_rules: + description: Targeting rules that determine audience eligibility. + items: + $ref: "#/components/schemas/TargetingRuleRequest" + type: array + type: + $ref: "#/components/schemas/AllocationType" + variant_weights: + description: Variant distribution weights. + items: + $ref: "#/components/schemas/VariantWeightRequest" + type: array + required: + - name + - key + - type + type: object UpsertCatalogEntityRequest: description: Create or update entity request. oneOf: @@ -72168,6 +72882,60 @@ components: - name - value type: object + VariantWeight: + description: Variant weight details. + properties: + created_at: + description: The timestamp when the variant weight was created. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + id: + description: Unique identifier of the variant weight assignment. + example: "59061199-e2ff-46e9-8b40-2193e3b21687" + format: uuid + type: string + updated_at: + description: The timestamp when the variant weight was last updated. + example: "2024-01-01T12:00:00Z" + format: date-time + type: string + value: + description: The percentage weight for the variant. + example: 50 + format: double + type: number + variant: + $ref: "#/components/schemas/Variant" + variant_id: + description: The variant ID. + example: "550e8400-e29b-41d4-a716-446655440001" + format: uuid + type: string + required: + - variant_id + - value + type: object + VariantWeightRequest: + description: Variant weight request payload. + properties: + value: + description: The percentage weight for this variant. + example: 50 + format: double + type: number + variant_id: + description: The variant ID to assign weight to. + example: "550e8400-e29b-41d4-a716-446655440001" + format: uuid + type: string + variant_key: + description: The variant key to assign weight to. + example: "control" + type: string + required: + - value + type: object Version: description: Version of the notification rule. It is updated when the rule is modified. example: 1 @@ -84899,6 +85667,270 @@ paths: operator: AND permissions: - feature_flag_environment_config_write + /api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/pause: + post: + description: |- + Pauses a progressive rollout while preserving rollout state. + operationId: PauseExposureSchedule + parameters: + - $ref: "#/components/parameters/exposure_schedule_id" + responses: + "200": + content: + application/json: + examples: + default: + value: + absolute_start_time: "2025-06-13T12:00:00Z" + allocation_id: "550e8400-e29b-41d4-a716-446655440020" + control_variant_id: "550e8400-e29b-41d4-a716-446655440012" + created_at: "2024-01-01T12:00:00Z" + guardrail_triggered_action: + guardrail_triggers: [] + id: "550e8400-e29b-41d4-a716-446655440010" + rollout_options: + autostart: false + selection_interval_ms: 3600000 + strategy: "UNIFORM_INTERVALS" + rollout_steps: [] + updated_at: "2024-01-01T12:00:00Z" + schema: + $ref: "#/components/schemas/AllocationExposureScheduleResponse" + 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 + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Pause a progressive rollout + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + /api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/resume: + post: + description: |- + Resumes progression for a previously paused progressive rollout. + operationId: ResumeExposureSchedule + parameters: + - $ref: "#/components/parameters/exposure_schedule_id" + responses: + "200": + content: + application/json: + examples: + default: + value: + absolute_start_time: "2025-06-13T12:00:00Z" + allocation_id: "550e8400-e29b-41d4-a716-446655440020" + control_variant_id: "550e8400-e29b-41d4-a716-446655440012" + created_at: "2024-01-01T12:00:00Z" + guardrail_triggered_action: + guardrail_triggers: [] + id: "550e8400-e29b-41d4-a716-446655440010" + rollout_options: + autostart: false + selection_interval_ms: 3600000 + strategy: "UNIFORM_INTERVALS" + rollout_steps: [] + updated_at: "2024-01-01T12:00:00Z" + schema: + $ref: "#/components/schemas/AllocationExposureScheduleResponse" + 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 + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Resume a progressive rollout + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + /api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/start: + post: + description: |- + Starts a progressive rollout and begins progression. + operationId: StartExposureSchedule + parameters: + - $ref: "#/components/parameters/exposure_schedule_id" + responses: + "200": + content: + application/json: + examples: + default: + value: + absolute_start_time: "2025-06-13T12:00:00Z" + allocation_id: "550e8400-e29b-41d4-a716-446655440020" + control_variant_id: "550e8400-e29b-41d4-a716-446655440012" + created_at: "2024-01-01T12:00:00Z" + guardrail_triggered_action: + guardrail_triggers: [] + id: "550e8400-e29b-41d4-a716-446655440010" + rollout_options: + autostart: false + selection_interval_ms: 3600000 + strategy: "UNIFORM_INTERVALS" + rollout_steps: [] + updated_at: "2024-01-01T12:00:00Z" + schema: + $ref: "#/components/schemas/AllocationExposureScheduleResponse" + 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 + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Start a progressive rollout + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + /api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/stop: + post: + description: |- + Stops a progressive rollout and marks it as aborted. + operationId: StopExposureSchedule + parameters: + - $ref: "#/components/parameters/exposure_schedule_id" + responses: + "200": + content: + application/json: + examples: + default: + value: + absolute_start_time: "2025-06-13T12:00:00Z" + allocation_id: "550e8400-e29b-41d4-a716-446655440020" + control_variant_id: "550e8400-e29b-41d4-a716-446655440012" + created_at: "2024-01-01T12:00:00Z" + guardrail_triggered_action: + guardrail_triggers: [] + id: "550e8400-e29b-41d4-a716-446655440010" + rollout_options: + autostart: false + selection_interval_ms: 3600000 + strategy: "UNIFORM_INTERVALS" + rollout_steps: [] + updated_at: "2024-01-01T12:00:00Z" + schema: + $ref: "#/components/schemas/AllocationExposureScheduleResponse" + 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 + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Stop a progressive rollout + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write /api/v2/feature-flags/{feature_flag_id}: get: description: |- @@ -85042,6 +86074,198 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/feature-flags/{feature_flag_id}/environments/{environment_id}/allocations: + post: + description: |- + Creates a new targeting rule (allocation) for a specific feature flag in a specific environment. + operationId: CreateAllocationsForFeatureFlagInEnvironment + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/environment_id" + requestBody: + content: + application/json: + example: + data: + attributes: + key: "prod-rollout" + name: "Production Rollout" + type: "FEATURE_GATE" + variant_weights: + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440001" + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440002" + type: "allocations" + schema: + $ref: "#/components/schemas/CreateAllocationsRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-01T12:00:00Z" + environment_ids: + - "550e8400-e29b-41d4-a716-446655440001" + guardrail_metrics: [] + id: "550e8400-e29b-41d4-a716-446655440020" + key: "prod-rollout" + name: "Production Rollout" + order_position: 0 + targeting_rules: [] + type: "FEATURE_GATE" + updated_at: "2024-01-01T12:00:00Z" + variant_weights: + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440001" + id: "550e8400-e29b-41d4-a716-446655440020" + type: "allocations" + schema: + $ref: "#/components/schemas/AllocationResponse" + description: Created + "202": + content: + application/json: + schema: + $ref: "#/components/schemas/AllocationResponse" + description: Accepted - Approval required for this change + "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 targeting rules for a flag env + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + put: + description: |- + Updates targeting rules (allocations) for a specific feature flag in a specific environment. + This operation replaces the existing allocation set with the request payload. + operationId: UpdateAllocationsForFeatureFlagInEnvironment + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/environment_id" + requestBody: + content: + application/json: + example: + data: + - attributes: + key: "prod-rollout" + name: "Production Rollout" + type: "FEATURE_GATE" + variant_weights: + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440001" + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440002" + type: "allocations" + schema: + $ref: "#/components/schemas/OverwriteAllocationsRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + created_at: "2024-01-01T12:00:00Z" + environment_ids: + - "550e8400-e29b-41d4-a716-446655440001" + guardrail_metrics: [] + id: "550e8400-e29b-41d4-a716-446655440020" + key: "prod-rollout" + name: "Production Rollout" + order_position: 0 + targeting_rules: [] + type: "FEATURE_GATE" + updated_at: "2024-01-01T12:00:00Z" + variant_weights: + - value: 50 + variant_id: "550e8400-e29b-41d4-a716-446655440001" + id: "550e8400-e29b-41d4-a716-446655440020" + type: "allocations" + schema: + $ref: "#/components/schemas/ListAllocationsResponse" + description: OK + "202": + content: + application/json: + schema: + $ref: "#/components/schemas/ListAllocationsResponse" + description: Accepted - Approval required for this change + "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: Update targeting rules for a flag + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write /api/v2/feature-flags/{feature_flag_id}/environments/{environment_id}/disable: post: description: |- diff --git a/api/datadogV2/api_feature_flags.go b/api/datadogV2/api_feature_flags.go index 06a6c5f0c31..eb359bddf3b 100644 --- a/api/datadogV2/api_feature_flags.go +++ b/api/datadogV2/api_feature_flags.go @@ -95,6 +95,88 @@ func (a *FeatureFlagsApi) ArchiveFeatureFlag(ctx _context.Context, featureFlagId return localVarReturnValue, localVarHTTPResponse, nil } +// CreateAllocationsForFeatureFlagInEnvironment Create targeting rules for a flag env. +// Creates a new targeting rule (allocation) for a specific feature flag in a specific environment. +func (a *FeatureFlagsApi) CreateAllocationsForFeatureFlagInEnvironment(ctx _context.Context, featureFlagId uuid.UUID, environmentId uuid.UUID, body CreateAllocationsRequest) (AllocationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AllocationResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/{feature_flag_id}/environments/{environment_id}/allocations" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{feature_flag_id}", _neturl.PathEscape(datadog.ParameterToString(featureFlagId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{environment_id}", _neturl.PathEscape(datadog.ParameterToString(environmentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateFeatureFlag Create a feature flag. // Creates a new feature flag with variants. func (a *FeatureFlagsApi) CreateFeatureFlag(ctx _context.Context, body CreateFeatureFlagRequest) (FeatureFlagResponse, *_nethttp.Response, error) { @@ -890,6 +972,318 @@ func (a *FeatureFlagsApi) ListFeatureFlagsEnvironments(ctx _context.Context, o . return localVarReturnValue, localVarHTTPResponse, nil } +// PauseExposureSchedule Pause a progressive rollout. +// Pauses a progressive rollout while preserving rollout state. +func (a *FeatureFlagsApi) PauseExposureSchedule(ctx _context.Context, exposureScheduleId uuid.UUID) (AllocationExposureScheduleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AllocationExposureScheduleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.PauseExposureSchedule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/pause" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exposure_schedule_id}", _neturl.PathEscape(datadog.ParameterToString(exposureScheduleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ResumeExposureSchedule Resume a progressive rollout. +// Resumes progression for a previously paused progressive rollout. +func (a *FeatureFlagsApi) ResumeExposureSchedule(ctx _context.Context, exposureScheduleId uuid.UUID) (AllocationExposureScheduleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AllocationExposureScheduleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.ResumeExposureSchedule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/resume" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exposure_schedule_id}", _neturl.PathEscape(datadog.ParameterToString(exposureScheduleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// StartExposureSchedule Start a progressive rollout. +// Starts a progressive rollout and begins progression. +func (a *FeatureFlagsApi) StartExposureSchedule(ctx _context.Context, exposureScheduleId uuid.UUID) (AllocationExposureScheduleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AllocationExposureScheduleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.StartExposureSchedule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/start" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exposure_schedule_id}", _neturl.PathEscape(datadog.ParameterToString(exposureScheduleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// StopExposureSchedule Stop a progressive rollout. +// Stops a progressive rollout and marks it as aborted. +func (a *FeatureFlagsApi) StopExposureSchedule(ctx _context.Context, exposureScheduleId uuid.UUID) (AllocationExposureScheduleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AllocationExposureScheduleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.StopExposureSchedule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/exposure-schedules/{exposure_schedule_id}/stop" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exposure_schedule_id}", _neturl.PathEscape(datadog.ParameterToString(exposureScheduleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UnarchiveFeatureFlag Unarchive a feature flag. // Unarchives a previously archived feature flag, // making it visible in the main list again. @@ -969,6 +1363,89 @@ func (a *FeatureFlagsApi) UnarchiveFeatureFlag(ctx _context.Context, featureFlag return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateAllocationsForFeatureFlagInEnvironment Update targeting rules for a flag. +// Updates targeting rules (allocations) for a specific feature flag in a specific environment. +// This operation replaces the existing allocation set with the request payload. +func (a *FeatureFlagsApi) UpdateAllocationsForFeatureFlagInEnvironment(ctx _context.Context, featureFlagId uuid.UUID, environmentId uuid.UUID, body OverwriteAllocationsRequest) (ListAllocationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue ListAllocationsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/feature-flags/{feature_flag_id}/environments/{environment_id}/allocations" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{feature_flag_id}", _neturl.PathEscape(datadog.ParameterToString(featureFlagId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{environment_id}", _neturl.PathEscape(datadog.ParameterToString(environmentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateFeatureFlag Update a feature flag. // Updates an existing feature flag's metadata such as // diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 4e7527137fd..824455a0c79 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -294,6 +294,7 @@ // - [FastlyIntegrationApi.UpdateFastlyAccount] // - [FastlyIntegrationApi.UpdateFastlyService] // - [FeatureFlagsApi.ArchiveFeatureFlag] +// - [FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment] // - [FeatureFlagsApi.CreateFeatureFlag] // - [FeatureFlagsApi.CreateFeatureFlagsEnvironment] // - [FeatureFlagsApi.DeleteFeatureFlagsEnvironment] @@ -303,7 +304,12 @@ // - [FeatureFlagsApi.GetFeatureFlagsEnvironment] // - [FeatureFlagsApi.ListFeatureFlags] // - [FeatureFlagsApi.ListFeatureFlagsEnvironments] +// - [FeatureFlagsApi.PauseExposureSchedule] +// - [FeatureFlagsApi.ResumeExposureSchedule] +// - [FeatureFlagsApi.StartExposureSchedule] +// - [FeatureFlagsApi.StopExposureSchedule] // - [FeatureFlagsApi.UnarchiveFeatureFlag] +// - [FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment] // - [FeatureFlagsApi.UpdateFeatureFlag] // - [FeatureFlagsApi.UpdateFeatureFlagsEnvironment] // - [FleetAutomationApi.CancelFleetDeployment] diff --git a/api/datadogV2/model_allocation.go b/api/datadogV2/model_allocation.go new file mode 100644 index 00000000000..8948856892e --- /dev/null +++ b/api/datadogV2/model_allocation.go @@ -0,0 +1,529 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Allocation Targeting rule (allocation) details for a feature flag environment. +type Allocation struct { + // The timestamp when the targeting rule allocation was created. + CreatedAt time.Time `json:"created_at"` + // Environment IDs associated with this targeting rule allocation. + EnvironmentIds []uuid.UUID `json:"environment_ids"` + // The experiment ID linked to this targeting rule allocation. + ExperimentId datadog.NullableString `json:"experiment_id,omitempty"` + // Progressive release details for a targeting rule allocation. + ExposureSchedule *AllocationExposureSchedule `json:"exposure_schedule,omitempty"` + // Guardrail metrics associated with this targeting rule allocation. + GuardrailMetrics []GuardrailMetric `json:"guardrail_metrics"` + // The unique identifier of the targeting rule allocation. + Id *uuid.UUID `json:"id,omitempty"` + // The unique key of the targeting rule allocation. + Key string `json:"key"` + // The display name of the targeting rule. + Name string `json:"name"` + // Sort order position within the environment. + OrderPosition int64 `json:"order_position"` + // Conditions associated with this targeting rule allocation. + TargetingRules []TargetingRule `json:"targeting_rules"` + // The type of targeting rule (called allocation in the API model). + Type AllocationType `json:"type"` + // The timestamp when the targeting rule allocation was last updated. + UpdatedAt time.Time `json:"updated_at"` + // Weighted variant assignments for this targeting rule allocation. + VariantWeights []VariantWeight `json:"variant_weights"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocation instantiates a new Allocation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocation(createdAt time.Time, environmentIds []uuid.UUID, guardrailMetrics []GuardrailMetric, key string, name string, orderPosition int64, targetingRules []TargetingRule, typeVar AllocationType, updatedAt time.Time, variantWeights []VariantWeight) *Allocation { + this := Allocation{} + this.CreatedAt = createdAt + this.EnvironmentIds = environmentIds + this.GuardrailMetrics = guardrailMetrics + this.Key = key + this.Name = name + this.OrderPosition = orderPosition + this.TargetingRules = targetingRules + this.Type = typeVar + this.UpdatedAt = updatedAt + this.VariantWeights = variantWeights + return &this +} + +// NewAllocationWithDefaults instantiates a new Allocation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationWithDefaults() *Allocation { + this := Allocation{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *Allocation) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *Allocation) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetEnvironmentIds returns the EnvironmentIds field value. +func (o *Allocation) GetEnvironmentIds() []uuid.UUID { + if o == nil { + var ret []uuid.UUID + return ret + } + return o.EnvironmentIds +} + +// GetEnvironmentIdsOk returns a tuple with the EnvironmentIds field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetEnvironmentIdsOk() (*[]uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.EnvironmentIds, true +} + +// SetEnvironmentIds sets field value. +func (o *Allocation) SetEnvironmentIds(v []uuid.UUID) { + o.EnvironmentIds = v +} + +// GetExperimentId returns the ExperimentId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Allocation) GetExperimentId() string { + if o == nil || o.ExperimentId.Get() == nil { + var ret string + return ret + } + return *o.ExperimentId.Get() +} + +// GetExperimentIdOk returns a tuple with the ExperimentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *Allocation) GetExperimentIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.ExperimentId.Get(), o.ExperimentId.IsSet() +} + +// HasExperimentId returns a boolean if a field has been set. +func (o *Allocation) HasExperimentId() bool { + return o != nil && o.ExperimentId.IsSet() +} + +// SetExperimentId gets a reference to the given datadog.NullableString and assigns it to the ExperimentId field. +func (o *Allocation) SetExperimentId(v string) { + o.ExperimentId.Set(&v) +} + +// SetExperimentIdNil sets the value for ExperimentId to be an explicit nil. +func (o *Allocation) SetExperimentIdNil() { + o.ExperimentId.Set(nil) +} + +// UnsetExperimentId ensures that no value is present for ExperimentId, not even an explicit nil. +func (o *Allocation) UnsetExperimentId() { + o.ExperimentId.Unset() +} + +// GetExposureSchedule returns the ExposureSchedule field value if set, zero value otherwise. +func (o *Allocation) GetExposureSchedule() AllocationExposureSchedule { + if o == nil || o.ExposureSchedule == nil { + var ret AllocationExposureSchedule + return ret + } + return *o.ExposureSchedule +} + +// GetExposureScheduleOk returns a tuple with the ExposureSchedule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Allocation) GetExposureScheduleOk() (*AllocationExposureSchedule, bool) { + if o == nil || o.ExposureSchedule == nil { + return nil, false + } + return o.ExposureSchedule, true +} + +// HasExposureSchedule returns a boolean if a field has been set. +func (o *Allocation) HasExposureSchedule() bool { + return o != nil && o.ExposureSchedule != nil +} + +// SetExposureSchedule gets a reference to the given AllocationExposureSchedule and assigns it to the ExposureSchedule field. +func (o *Allocation) SetExposureSchedule(v AllocationExposureSchedule) { + o.ExposureSchedule = &v +} + +// GetGuardrailMetrics returns the GuardrailMetrics field value. +func (o *Allocation) GetGuardrailMetrics() []GuardrailMetric { + if o == nil { + var ret []GuardrailMetric + return ret + } + return o.GuardrailMetrics +} + +// GetGuardrailMetricsOk returns a tuple with the GuardrailMetrics field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetGuardrailMetricsOk() (*[]GuardrailMetric, bool) { + if o == nil { + return nil, false + } + return &o.GuardrailMetrics, true +} + +// SetGuardrailMetrics sets field value. +func (o *Allocation) SetGuardrailMetrics(v []GuardrailMetric) { + o.GuardrailMetrics = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *Allocation) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Allocation) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *Allocation) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *Allocation) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetKey returns the Key field value. +func (o *Allocation) GetKey() string { + if o == nil { + var ret string + return ret + } + return o.Key +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Key, true +} + +// SetKey sets field value. +func (o *Allocation) SetKey(v string) { + o.Key = v +} + +// GetName returns the Name field value. +func (o *Allocation) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *Allocation) SetName(v string) { + o.Name = v +} + +// GetOrderPosition returns the OrderPosition field value. +func (o *Allocation) GetOrderPosition() int64 { + if o == nil { + var ret int64 + return ret + } + return o.OrderPosition +} + +// GetOrderPositionOk returns a tuple with the OrderPosition field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetOrderPositionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.OrderPosition, true +} + +// SetOrderPosition sets field value. +func (o *Allocation) SetOrderPosition(v int64) { + o.OrderPosition = v +} + +// GetTargetingRules returns the TargetingRules field value. +func (o *Allocation) GetTargetingRules() []TargetingRule { + if o == nil { + var ret []TargetingRule + return ret + } + return o.TargetingRules +} + +// GetTargetingRulesOk returns a tuple with the TargetingRules field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetTargetingRulesOk() (*[]TargetingRule, bool) { + if o == nil { + return nil, false + } + return &o.TargetingRules, true +} + +// SetTargetingRules sets field value. +func (o *Allocation) SetTargetingRules(v []TargetingRule) { + o.TargetingRules = v +} + +// GetType returns the Type field value. +func (o *Allocation) GetType() AllocationType { + if o == nil { + var ret AllocationType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetTypeOk() (*AllocationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *Allocation) SetType(v AllocationType) { + o.Type = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *Allocation) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *Allocation) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetVariantWeights returns the VariantWeights field value. +func (o *Allocation) GetVariantWeights() []VariantWeight { + if o == nil { + var ret []VariantWeight + return ret + } + return o.VariantWeights +} + +// GetVariantWeightsOk returns a tuple with the VariantWeights field value +// and a boolean to check if the value has been set. +func (o *Allocation) GetVariantWeightsOk() (*[]VariantWeight, bool) { + if o == nil { + return nil, false + } + return &o.VariantWeights, true +} + +// SetVariantWeights sets field value. +func (o *Allocation) SetVariantWeights(v []VariantWeight) { + o.VariantWeights = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Allocation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["environment_ids"] = o.EnvironmentIds + if o.ExperimentId.IsSet() { + toSerialize["experiment_id"] = o.ExperimentId.Get() + } + if o.ExposureSchedule != nil { + toSerialize["exposure_schedule"] = o.ExposureSchedule + } + toSerialize["guardrail_metrics"] = o.GuardrailMetrics + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["key"] = o.Key + toSerialize["name"] = o.Name + toSerialize["order_position"] = o.OrderPosition + toSerialize["targeting_rules"] = o.TargetingRules + toSerialize["type"] = o.Type + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["variant_weights"] = o.VariantWeights + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Allocation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at"` + EnvironmentIds *[]uuid.UUID `json:"environment_ids"` + ExperimentId datadog.NullableString `json:"experiment_id,omitempty"` + ExposureSchedule *AllocationExposureSchedule `json:"exposure_schedule,omitempty"` + GuardrailMetrics *[]GuardrailMetric `json:"guardrail_metrics"` + Id *uuid.UUID `json:"id,omitempty"` + Key *string `json:"key"` + Name *string `json:"name"` + OrderPosition *int64 `json:"order_position"` + TargetingRules *[]TargetingRule `json:"targeting_rules"` + Type *AllocationType `json:"type"` + UpdatedAt *time.Time `json:"updated_at"` + VariantWeights *[]VariantWeight `json:"variant_weights"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.EnvironmentIds == nil { + return fmt.Errorf("required field environment_ids missing") + } + if all.GuardrailMetrics == nil { + return fmt.Errorf("required field guardrail_metrics missing") + } + if all.Key == nil { + return fmt.Errorf("required field key missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.OrderPosition == nil { + return fmt.Errorf("required field order_position missing") + } + if all.TargetingRules == nil { + return fmt.Errorf("required field targeting_rules missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + if all.VariantWeights == nil { + return fmt.Errorf("required field variant_weights missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "environment_ids", "experiment_id", "exposure_schedule", "guardrail_metrics", "id", "key", "name", "order_position", "targeting_rules", "type", "updated_at", "variant_weights"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = *all.CreatedAt + o.EnvironmentIds = *all.EnvironmentIds + o.ExperimentId = all.ExperimentId + if all.ExposureSchedule != nil && all.ExposureSchedule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ExposureSchedule = all.ExposureSchedule + o.GuardrailMetrics = *all.GuardrailMetrics + o.Id = all.Id + o.Key = *all.Key + o.Name = *all.Name + o.OrderPosition = *all.OrderPosition + o.TargetingRules = *all.TargetingRules + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.UpdatedAt = *all.UpdatedAt + o.VariantWeights = *all.VariantWeights + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_data_request.go b/api/datadogV2/model_allocation_data_request.go new file mode 100644 index 00000000000..5a06539a4ac --- /dev/null +++ b/api/datadogV2/model_allocation_data_request.go @@ -0,0 +1,146 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationDataRequest Data wrapper for allocation request payloads. +type AllocationDataRequest struct { + // Request to create or update a targeting rule (allocation) for a feature flag environment. + Attributes UpsertAllocationRequest `json:"attributes"` + // The resource type. + Type AllocationDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationDataRequest instantiates a new AllocationDataRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationDataRequest(attributes UpsertAllocationRequest, typeVar AllocationDataType) *AllocationDataRequest { + this := AllocationDataRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewAllocationDataRequestWithDefaults instantiates a new AllocationDataRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationDataRequestWithDefaults() *AllocationDataRequest { + this := AllocationDataRequest{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AllocationDataRequest) GetAttributes() UpsertAllocationRequest { + if o == nil { + var ret UpsertAllocationRequest + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *AllocationDataRequest) GetAttributesOk() (*UpsertAllocationRequest, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AllocationDataRequest) SetAttributes(v UpsertAllocationRequest) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *AllocationDataRequest) GetType() AllocationDataType { + if o == nil { + var ret AllocationDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *AllocationDataRequest) GetTypeOk() (*AllocationDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AllocationDataRequest) SetType(v AllocationDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationDataRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationDataRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *UpsertAllocationRequest `json:"attributes"` + Type *AllocationDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_data_response.go b/api/datadogV2/model_allocation_data_response.go new file mode 100644 index 00000000000..02ad2fbb4be --- /dev/null +++ b/api/datadogV2/model_allocation_data_response.go @@ -0,0 +1,180 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationDataResponse Data wrapper for targeting rule allocation responses. +type AllocationDataResponse struct { + // Targeting rule (allocation) details for a feature flag environment. + Attributes Allocation `json:"attributes"` + // The unique identifier of the targeting rule allocation. + Id uuid.UUID `json:"id"` + // The resource type. + Type AllocationDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationDataResponse instantiates a new AllocationDataResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationDataResponse(attributes Allocation, id uuid.UUID, typeVar AllocationDataType) *AllocationDataResponse { + this := AllocationDataResponse{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAllocationDataResponseWithDefaults instantiates a new AllocationDataResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationDataResponseWithDefaults() *AllocationDataResponse { + this := AllocationDataResponse{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AllocationDataResponse) GetAttributes() Allocation { + if o == nil { + var ret Allocation + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *AllocationDataResponse) GetAttributesOk() (*Allocation, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AllocationDataResponse) SetAttributes(v Allocation) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *AllocationDataResponse) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AllocationDataResponse) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AllocationDataResponse) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *AllocationDataResponse) GetType() AllocationDataType { + if o == nil { + var ret AllocationDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *AllocationDataResponse) GetTypeOk() (*AllocationDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AllocationDataResponse) SetType(v AllocationDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationDataResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationDataResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *Allocation `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *AllocationDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_data_type.go b/api/datadogV2/model_allocation_data_type.go new file mode 100644 index 00000000000..ab3853da11a --- /dev/null +++ b/api/datadogV2/model_allocation_data_type.go @@ -0,0 +1,64 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationDataType The resource type. +type AllocationDataType string + +// List of AllocationDataType. +const ( + ALLOCATIONDATATYPE_ALLOCATIONS AllocationDataType = "allocations" +) + +var allowedAllocationDataTypeEnumValues = []AllocationDataType{ + ALLOCATIONDATATYPE_ALLOCATIONS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AllocationDataType) GetAllowedValues() []AllocationDataType { + return allowedAllocationDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AllocationDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AllocationDataType(value) + return nil +} + +// NewAllocationDataTypeFromValue returns a pointer to a valid AllocationDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAllocationDataTypeFromValue(v string) (*AllocationDataType, error) { + ev := AllocationDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AllocationDataType: valid values are %v", v, allowedAllocationDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AllocationDataType) IsValid() bool { + for _, existing := range allowedAllocationDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AllocationDataType value. +func (v AllocationDataType) Ptr() *AllocationDataType { + return &v +} diff --git a/api/datadogV2/model_allocation_exposure_guardrail_trigger.go b/api/datadogV2/model_allocation_exposure_guardrail_trigger.go new file mode 100644 index 00000000000..78a94c7583e --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_guardrail_trigger.go @@ -0,0 +1,304 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureGuardrailTrigger Guardrail trigger details for a progressive rollout. +type AllocationExposureGuardrailTrigger struct { + // The progressive rollout ID this trigger belongs to. + AllocationExposureScheduleId uuid.UUID `json:"allocation_exposure_schedule_id"` + // The timestamp when this trigger was created. + CreatedAt time.Time `json:"created_at"` + // The variant ID that triggered this event. + FlaggingVariantId uuid.UUID `json:"flagging_variant_id"` + // The unique identifier of the guardrail trigger. + Id uuid.UUID `json:"id"` + // The metric ID associated with the trigger. + MetricId string `json:"metric_id"` + // The action that was triggered. + TriggeredAction string `json:"triggered_action"` + // The timestamp when this trigger was last updated. + UpdatedAt time.Time `json:"updated_at"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationExposureGuardrailTrigger instantiates a new AllocationExposureGuardrailTrigger object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationExposureGuardrailTrigger(allocationExposureScheduleId uuid.UUID, createdAt time.Time, flaggingVariantId uuid.UUID, id uuid.UUID, metricId string, triggeredAction string, updatedAt time.Time) *AllocationExposureGuardrailTrigger { + this := AllocationExposureGuardrailTrigger{} + this.AllocationExposureScheduleId = allocationExposureScheduleId + this.CreatedAt = createdAt + this.FlaggingVariantId = flaggingVariantId + this.Id = id + this.MetricId = metricId + this.TriggeredAction = triggeredAction + this.UpdatedAt = updatedAt + return &this +} + +// NewAllocationExposureGuardrailTriggerWithDefaults instantiates a new AllocationExposureGuardrailTrigger object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationExposureGuardrailTriggerWithDefaults() *AllocationExposureGuardrailTrigger { + this := AllocationExposureGuardrailTrigger{} + return &this +} + +// GetAllocationExposureScheduleId returns the AllocationExposureScheduleId field value. +func (o *AllocationExposureGuardrailTrigger) GetAllocationExposureScheduleId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.AllocationExposureScheduleId +} + +// GetAllocationExposureScheduleIdOk returns a tuple with the AllocationExposureScheduleId field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetAllocationExposureScheduleIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.AllocationExposureScheduleId, true +} + +// SetAllocationExposureScheduleId sets field value. +func (o *AllocationExposureGuardrailTrigger) SetAllocationExposureScheduleId(v uuid.UUID) { + o.AllocationExposureScheduleId = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *AllocationExposureGuardrailTrigger) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *AllocationExposureGuardrailTrigger) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetFlaggingVariantId returns the FlaggingVariantId field value. +func (o *AllocationExposureGuardrailTrigger) GetFlaggingVariantId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.FlaggingVariantId +} + +// GetFlaggingVariantIdOk returns a tuple with the FlaggingVariantId field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetFlaggingVariantIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.FlaggingVariantId, true +} + +// SetFlaggingVariantId sets field value. +func (o *AllocationExposureGuardrailTrigger) SetFlaggingVariantId(v uuid.UUID) { + o.FlaggingVariantId = v +} + +// GetId returns the Id field value. +func (o *AllocationExposureGuardrailTrigger) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AllocationExposureGuardrailTrigger) SetId(v uuid.UUID) { + o.Id = v +} + +// GetMetricId returns the MetricId field value. +func (o *AllocationExposureGuardrailTrigger) GetMetricId() string { + if o == nil { + var ret string + return ret + } + return o.MetricId +} + +// GetMetricIdOk returns a tuple with the MetricId field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetMetricIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetricId, true +} + +// SetMetricId sets field value. +func (o *AllocationExposureGuardrailTrigger) SetMetricId(v string) { + o.MetricId = v +} + +// GetTriggeredAction returns the TriggeredAction field value. +func (o *AllocationExposureGuardrailTrigger) GetTriggeredAction() string { + if o == nil { + var ret string + return ret + } + return o.TriggeredAction +} + +// GetTriggeredActionOk returns a tuple with the TriggeredAction field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetTriggeredActionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.TriggeredAction, true +} + +// SetTriggeredAction sets field value. +func (o *AllocationExposureGuardrailTrigger) SetTriggeredAction(v string) { + o.TriggeredAction = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *AllocationExposureGuardrailTrigger) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureGuardrailTrigger) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *AllocationExposureGuardrailTrigger) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationExposureGuardrailTrigger) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["allocation_exposure_schedule_id"] = o.AllocationExposureScheduleId + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["flagging_variant_id"] = o.FlaggingVariantId + toSerialize["id"] = o.Id + toSerialize["metric_id"] = o.MetricId + toSerialize["triggered_action"] = o.TriggeredAction + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationExposureGuardrailTrigger) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AllocationExposureScheduleId *uuid.UUID `json:"allocation_exposure_schedule_id"` + CreatedAt *time.Time `json:"created_at"` + FlaggingVariantId *uuid.UUID `json:"flagging_variant_id"` + Id *uuid.UUID `json:"id"` + MetricId *string `json:"metric_id"` + TriggeredAction *string `json:"triggered_action"` + UpdatedAt *time.Time `json:"updated_at"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AllocationExposureScheduleId == nil { + return fmt.Errorf("required field allocation_exposure_schedule_id missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.FlaggingVariantId == nil { + return fmt.Errorf("required field flagging_variant_id missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.MetricId == nil { + return fmt.Errorf("required field metric_id missing") + } + if all.TriggeredAction == nil { + return fmt.Errorf("required field triggered_action missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"allocation_exposure_schedule_id", "created_at", "flagging_variant_id", "id", "metric_id", "triggered_action", "updated_at"}) + } else { + return err + } + o.AllocationExposureScheduleId = *all.AllocationExposureScheduleId + o.CreatedAt = *all.CreatedAt + o.FlaggingVariantId = *all.FlaggingVariantId + o.Id = *all.Id + o.MetricId = *all.MetricId + o.TriggeredAction = *all.TriggeredAction + o.UpdatedAt = *all.UpdatedAt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_allocation_exposure_rollout_step.go b/api/datadogV2/model_allocation_exposure_rollout_step.go new file mode 100644 index 00000000000..2002a62d3e0 --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_rollout_step.go @@ -0,0 +1,382 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureRolloutStep Exposure progression step details. +type AllocationExposureRolloutStep struct { + // The progressive rollout ID this step belongs to. + AllocationExposureScheduleId uuid.UUID `json:"allocation_exposure_schedule_id"` + // The timestamp when the progression step was created. + CreatedAt time.Time `json:"created_at"` + // The exposure ratio for this step. + ExposureRatio float64 `json:"exposure_ratio"` + // Logical index grouping related steps. + GroupedStepIndex int64 `json:"grouped_step_index"` + // The unique identifier of the progression step. + Id uuid.UUID `json:"id"` + // Step duration in milliseconds. + IntervalMs datadog.NullableInt64 `json:"interval_ms,omitempty"` + // Whether this step represents a pause record. + IsPauseRecord bool `json:"is_pause_record"` + // Sort order for the progression step. + OrderPosition int64 `json:"order_position"` + // The timestamp when the progression step was last updated. + UpdatedAt time.Time `json:"updated_at"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationExposureRolloutStep instantiates a new AllocationExposureRolloutStep object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationExposureRolloutStep(allocationExposureScheduleId uuid.UUID, createdAt time.Time, exposureRatio float64, groupedStepIndex int64, id uuid.UUID, isPauseRecord bool, orderPosition int64, updatedAt time.Time) *AllocationExposureRolloutStep { + this := AllocationExposureRolloutStep{} + this.AllocationExposureScheduleId = allocationExposureScheduleId + this.CreatedAt = createdAt + this.ExposureRatio = exposureRatio + this.GroupedStepIndex = groupedStepIndex + this.Id = id + this.IsPauseRecord = isPauseRecord + this.OrderPosition = orderPosition + this.UpdatedAt = updatedAt + return &this +} + +// NewAllocationExposureRolloutStepWithDefaults instantiates a new AllocationExposureRolloutStep object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationExposureRolloutStepWithDefaults() *AllocationExposureRolloutStep { + this := AllocationExposureRolloutStep{} + return &this +} + +// GetAllocationExposureScheduleId returns the AllocationExposureScheduleId field value. +func (o *AllocationExposureRolloutStep) GetAllocationExposureScheduleId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.AllocationExposureScheduleId +} + +// GetAllocationExposureScheduleIdOk returns a tuple with the AllocationExposureScheduleId field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetAllocationExposureScheduleIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.AllocationExposureScheduleId, true +} + +// SetAllocationExposureScheduleId sets field value. +func (o *AllocationExposureRolloutStep) SetAllocationExposureScheduleId(v uuid.UUID) { + o.AllocationExposureScheduleId = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *AllocationExposureRolloutStep) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *AllocationExposureRolloutStep) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetExposureRatio returns the ExposureRatio field value. +func (o *AllocationExposureRolloutStep) GetExposureRatio() float64 { + if o == nil { + var ret float64 + return ret + } + return o.ExposureRatio +} + +// GetExposureRatioOk returns a tuple with the ExposureRatio field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetExposureRatioOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.ExposureRatio, true +} + +// SetExposureRatio sets field value. +func (o *AllocationExposureRolloutStep) SetExposureRatio(v float64) { + o.ExposureRatio = v +} + +// GetGroupedStepIndex returns the GroupedStepIndex field value. +func (o *AllocationExposureRolloutStep) GetGroupedStepIndex() int64 { + if o == nil { + var ret int64 + return ret + } + return o.GroupedStepIndex +} + +// GetGroupedStepIndexOk returns a tuple with the GroupedStepIndex field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetGroupedStepIndexOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.GroupedStepIndex, true +} + +// SetGroupedStepIndex sets field value. +func (o *AllocationExposureRolloutStep) SetGroupedStepIndex(v int64) { + o.GroupedStepIndex = v +} + +// GetId returns the Id field value. +func (o *AllocationExposureRolloutStep) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AllocationExposureRolloutStep) SetId(v uuid.UUID) { + o.Id = v +} + +// GetIntervalMs returns the IntervalMs field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *AllocationExposureRolloutStep) GetIntervalMs() int64 { + if o == nil || o.IntervalMs.Get() == nil { + var ret int64 + return ret + } + return *o.IntervalMs.Get() +} + +// GetIntervalMsOk returns a tuple with the IntervalMs field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AllocationExposureRolloutStep) GetIntervalMsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.IntervalMs.Get(), o.IntervalMs.IsSet() +} + +// HasIntervalMs returns a boolean if a field has been set. +func (o *AllocationExposureRolloutStep) HasIntervalMs() bool { + return o != nil && o.IntervalMs.IsSet() +} + +// SetIntervalMs gets a reference to the given datadog.NullableInt64 and assigns it to the IntervalMs field. +func (o *AllocationExposureRolloutStep) SetIntervalMs(v int64) { + o.IntervalMs.Set(&v) +} + +// SetIntervalMsNil sets the value for IntervalMs to be an explicit nil. +func (o *AllocationExposureRolloutStep) SetIntervalMsNil() { + o.IntervalMs.Set(nil) +} + +// UnsetIntervalMs ensures that no value is present for IntervalMs, not even an explicit nil. +func (o *AllocationExposureRolloutStep) UnsetIntervalMs() { + o.IntervalMs.Unset() +} + +// GetIsPauseRecord returns the IsPauseRecord field value. +func (o *AllocationExposureRolloutStep) GetIsPauseRecord() bool { + if o == nil { + var ret bool + return ret + } + return o.IsPauseRecord +} + +// GetIsPauseRecordOk returns a tuple with the IsPauseRecord field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetIsPauseRecordOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsPauseRecord, true +} + +// SetIsPauseRecord sets field value. +func (o *AllocationExposureRolloutStep) SetIsPauseRecord(v bool) { + o.IsPauseRecord = v +} + +// GetOrderPosition returns the OrderPosition field value. +func (o *AllocationExposureRolloutStep) GetOrderPosition() int64 { + if o == nil { + var ret int64 + return ret + } + return o.OrderPosition +} + +// GetOrderPositionOk returns a tuple with the OrderPosition field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetOrderPositionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.OrderPosition, true +} + +// SetOrderPosition sets field value. +func (o *AllocationExposureRolloutStep) SetOrderPosition(v int64) { + o.OrderPosition = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *AllocationExposureRolloutStep) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureRolloutStep) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *AllocationExposureRolloutStep) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationExposureRolloutStep) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["allocation_exposure_schedule_id"] = o.AllocationExposureScheduleId + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["exposure_ratio"] = o.ExposureRatio + toSerialize["grouped_step_index"] = o.GroupedStepIndex + toSerialize["id"] = o.Id + if o.IntervalMs.IsSet() { + toSerialize["interval_ms"] = o.IntervalMs.Get() + } + toSerialize["is_pause_record"] = o.IsPauseRecord + toSerialize["order_position"] = o.OrderPosition + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationExposureRolloutStep) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AllocationExposureScheduleId *uuid.UUID `json:"allocation_exposure_schedule_id"` + CreatedAt *time.Time `json:"created_at"` + ExposureRatio *float64 `json:"exposure_ratio"` + GroupedStepIndex *int64 `json:"grouped_step_index"` + Id *uuid.UUID `json:"id"` + IntervalMs datadog.NullableInt64 `json:"interval_ms,omitempty"` + IsPauseRecord *bool `json:"is_pause_record"` + OrderPosition *int64 `json:"order_position"` + UpdatedAt *time.Time `json:"updated_at"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AllocationExposureScheduleId == nil { + return fmt.Errorf("required field allocation_exposure_schedule_id missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.ExposureRatio == nil { + return fmt.Errorf("required field exposure_ratio missing") + } + if all.GroupedStepIndex == nil { + return fmt.Errorf("required field grouped_step_index missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.IsPauseRecord == nil { + return fmt.Errorf("required field is_pause_record missing") + } + if all.OrderPosition == nil { + return fmt.Errorf("required field order_position missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"allocation_exposure_schedule_id", "created_at", "exposure_ratio", "grouped_step_index", "id", "interval_ms", "is_pause_record", "order_position", "updated_at"}) + } else { + return err + } + o.AllocationExposureScheduleId = *all.AllocationExposureScheduleId + o.CreatedAt = *all.CreatedAt + o.ExposureRatio = *all.ExposureRatio + o.GroupedStepIndex = *all.GroupedStepIndex + o.Id = *all.Id + o.IntervalMs = all.IntervalMs + o.IsPauseRecord = *all.IsPauseRecord + o.OrderPosition = *all.OrderPosition + o.UpdatedAt = *all.UpdatedAt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_allocation_exposure_schedule.go b/api/datadogV2/model_allocation_exposure_schedule.go new file mode 100644 index 00000000000..83ac8baf6de --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_schedule.go @@ -0,0 +1,454 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureSchedule Progressive release details for a targeting rule allocation. +type AllocationExposureSchedule struct { + // The absolute UTC start time for this schedule. + AbsoluteStartTime datadog.NullableTime `json:"absolute_start_time,omitempty"` + // The targeting rule allocation ID this progressive rollout belongs to. + AllocationId uuid.UUID `json:"allocation_id"` + // The control variant ID used for experiment comparisons. + ControlVariantId datadog.NullableString `json:"control_variant_id,omitempty"` + // The timestamp when the schedule was created. + CreatedAt time.Time `json:"created_at"` + // Last guardrail action triggered for this schedule. + GuardrailTriggeredAction datadog.NullableString `json:"guardrail_triggered_action,omitempty"` + // Guardrail trigger records for this schedule. + GuardrailTriggers []AllocationExposureGuardrailTrigger `json:"guardrail_triggers"` + // The unique identifier of the progressive rollout. + Id *uuid.UUID `json:"id,omitempty"` + // Applied progression options for a progressive rollout. + RolloutOptions RolloutOptions `json:"rollout_options"` + // Ordered progression steps for exposure. + RolloutSteps []AllocationExposureRolloutStep `json:"rollout_steps"` + // The timestamp when the schedule was last updated. + UpdatedAt time.Time `json:"updated_at"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationExposureSchedule instantiates a new AllocationExposureSchedule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationExposureSchedule(allocationId uuid.UUID, createdAt time.Time, guardrailTriggers []AllocationExposureGuardrailTrigger, rolloutOptions RolloutOptions, rolloutSteps []AllocationExposureRolloutStep, updatedAt time.Time) *AllocationExposureSchedule { + this := AllocationExposureSchedule{} + this.AllocationId = allocationId + this.CreatedAt = createdAt + this.GuardrailTriggers = guardrailTriggers + this.RolloutOptions = rolloutOptions + this.RolloutSteps = rolloutSteps + this.UpdatedAt = updatedAt + return &this +} + +// NewAllocationExposureScheduleWithDefaults instantiates a new AllocationExposureSchedule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationExposureScheduleWithDefaults() *AllocationExposureSchedule { + this := AllocationExposureSchedule{} + return &this +} + +// GetAbsoluteStartTime returns the AbsoluteStartTime field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *AllocationExposureSchedule) GetAbsoluteStartTime() time.Time { + if o == nil || o.AbsoluteStartTime.Get() == nil { + var ret time.Time + return ret + } + return *o.AbsoluteStartTime.Get() +} + +// GetAbsoluteStartTimeOk returns a tuple with the AbsoluteStartTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AllocationExposureSchedule) GetAbsoluteStartTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.AbsoluteStartTime.Get(), o.AbsoluteStartTime.IsSet() +} + +// HasAbsoluteStartTime returns a boolean if a field has been set. +func (o *AllocationExposureSchedule) HasAbsoluteStartTime() bool { + return o != nil && o.AbsoluteStartTime.IsSet() +} + +// SetAbsoluteStartTime gets a reference to the given datadog.NullableTime and assigns it to the AbsoluteStartTime field. +func (o *AllocationExposureSchedule) SetAbsoluteStartTime(v time.Time) { + o.AbsoluteStartTime.Set(&v) +} + +// SetAbsoluteStartTimeNil sets the value for AbsoluteStartTime to be an explicit nil. +func (o *AllocationExposureSchedule) SetAbsoluteStartTimeNil() { + o.AbsoluteStartTime.Set(nil) +} + +// UnsetAbsoluteStartTime ensures that no value is present for AbsoluteStartTime, not even an explicit nil. +func (o *AllocationExposureSchedule) UnsetAbsoluteStartTime() { + o.AbsoluteStartTime.Unset() +} + +// GetAllocationId returns the AllocationId field value. +func (o *AllocationExposureSchedule) GetAllocationId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.AllocationId +} + +// GetAllocationIdOk returns a tuple with the AllocationId field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetAllocationIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.AllocationId, true +} + +// SetAllocationId sets field value. +func (o *AllocationExposureSchedule) SetAllocationId(v uuid.UUID) { + o.AllocationId = v +} + +// GetControlVariantId returns the ControlVariantId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *AllocationExposureSchedule) GetControlVariantId() string { + if o == nil || o.ControlVariantId.Get() == nil { + var ret string + return ret + } + return *o.ControlVariantId.Get() +} + +// GetControlVariantIdOk returns a tuple with the ControlVariantId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AllocationExposureSchedule) GetControlVariantIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.ControlVariantId.Get(), o.ControlVariantId.IsSet() +} + +// HasControlVariantId returns a boolean if a field has been set. +func (o *AllocationExposureSchedule) HasControlVariantId() bool { + return o != nil && o.ControlVariantId.IsSet() +} + +// SetControlVariantId gets a reference to the given datadog.NullableString and assigns it to the ControlVariantId field. +func (o *AllocationExposureSchedule) SetControlVariantId(v string) { + o.ControlVariantId.Set(&v) +} + +// SetControlVariantIdNil sets the value for ControlVariantId to be an explicit nil. +func (o *AllocationExposureSchedule) SetControlVariantIdNil() { + o.ControlVariantId.Set(nil) +} + +// UnsetControlVariantId ensures that no value is present for ControlVariantId, not even an explicit nil. +func (o *AllocationExposureSchedule) UnsetControlVariantId() { + o.ControlVariantId.Unset() +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *AllocationExposureSchedule) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *AllocationExposureSchedule) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetGuardrailTriggeredAction returns the GuardrailTriggeredAction field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *AllocationExposureSchedule) GetGuardrailTriggeredAction() string { + if o == nil || o.GuardrailTriggeredAction.Get() == nil { + var ret string + return ret + } + return *o.GuardrailTriggeredAction.Get() +} + +// GetGuardrailTriggeredActionOk returns a tuple with the GuardrailTriggeredAction field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AllocationExposureSchedule) GetGuardrailTriggeredActionOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.GuardrailTriggeredAction.Get(), o.GuardrailTriggeredAction.IsSet() +} + +// HasGuardrailTriggeredAction returns a boolean if a field has been set. +func (o *AllocationExposureSchedule) HasGuardrailTriggeredAction() bool { + return o != nil && o.GuardrailTriggeredAction.IsSet() +} + +// SetGuardrailTriggeredAction gets a reference to the given datadog.NullableString and assigns it to the GuardrailTriggeredAction field. +func (o *AllocationExposureSchedule) SetGuardrailTriggeredAction(v string) { + o.GuardrailTriggeredAction.Set(&v) +} + +// SetGuardrailTriggeredActionNil sets the value for GuardrailTriggeredAction to be an explicit nil. +func (o *AllocationExposureSchedule) SetGuardrailTriggeredActionNil() { + o.GuardrailTriggeredAction.Set(nil) +} + +// UnsetGuardrailTriggeredAction ensures that no value is present for GuardrailTriggeredAction, not even an explicit nil. +func (o *AllocationExposureSchedule) UnsetGuardrailTriggeredAction() { + o.GuardrailTriggeredAction.Unset() +} + +// GetGuardrailTriggers returns the GuardrailTriggers field value. +func (o *AllocationExposureSchedule) GetGuardrailTriggers() []AllocationExposureGuardrailTrigger { + if o == nil { + var ret []AllocationExposureGuardrailTrigger + return ret + } + return o.GuardrailTriggers +} + +// GetGuardrailTriggersOk returns a tuple with the GuardrailTriggers field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetGuardrailTriggersOk() (*[]AllocationExposureGuardrailTrigger, bool) { + if o == nil { + return nil, false + } + return &o.GuardrailTriggers, true +} + +// SetGuardrailTriggers sets field value. +func (o *AllocationExposureSchedule) SetGuardrailTriggers(v []AllocationExposureGuardrailTrigger) { + o.GuardrailTriggers = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *AllocationExposureSchedule) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *AllocationExposureSchedule) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *AllocationExposureSchedule) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetRolloutOptions returns the RolloutOptions field value. +func (o *AllocationExposureSchedule) GetRolloutOptions() RolloutOptions { + if o == nil { + var ret RolloutOptions + return ret + } + return o.RolloutOptions +} + +// GetRolloutOptionsOk returns a tuple with the RolloutOptions field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetRolloutOptionsOk() (*RolloutOptions, bool) { + if o == nil { + return nil, false + } + return &o.RolloutOptions, true +} + +// SetRolloutOptions sets field value. +func (o *AllocationExposureSchedule) SetRolloutOptions(v RolloutOptions) { + o.RolloutOptions = v +} + +// GetRolloutSteps returns the RolloutSteps field value. +func (o *AllocationExposureSchedule) GetRolloutSteps() []AllocationExposureRolloutStep { + if o == nil { + var ret []AllocationExposureRolloutStep + return ret + } + return o.RolloutSteps +} + +// GetRolloutStepsOk returns a tuple with the RolloutSteps field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetRolloutStepsOk() (*[]AllocationExposureRolloutStep, bool) { + if o == nil { + return nil, false + } + return &o.RolloutSteps, true +} + +// SetRolloutSteps sets field value. +func (o *AllocationExposureSchedule) SetRolloutSteps(v []AllocationExposureRolloutStep) { + o.RolloutSteps = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *AllocationExposureSchedule) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureSchedule) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *AllocationExposureSchedule) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationExposureSchedule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AbsoluteStartTime.IsSet() { + toSerialize["absolute_start_time"] = o.AbsoluteStartTime.Get() + } + toSerialize["allocation_id"] = o.AllocationId + if o.ControlVariantId.IsSet() { + toSerialize["control_variant_id"] = o.ControlVariantId.Get() + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + if o.GuardrailTriggeredAction.IsSet() { + toSerialize["guardrail_triggered_action"] = o.GuardrailTriggeredAction.Get() + } + toSerialize["guardrail_triggers"] = o.GuardrailTriggers + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["rollout_options"] = o.RolloutOptions + toSerialize["rollout_steps"] = o.RolloutSteps + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationExposureSchedule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AbsoluteStartTime datadog.NullableTime `json:"absolute_start_time,omitempty"` + AllocationId *uuid.UUID `json:"allocation_id"` + ControlVariantId datadog.NullableString `json:"control_variant_id,omitempty"` + CreatedAt *time.Time `json:"created_at"` + GuardrailTriggeredAction datadog.NullableString `json:"guardrail_triggered_action,omitempty"` + GuardrailTriggers *[]AllocationExposureGuardrailTrigger `json:"guardrail_triggers"` + Id *uuid.UUID `json:"id,omitempty"` + RolloutOptions *RolloutOptions `json:"rollout_options"` + RolloutSteps *[]AllocationExposureRolloutStep `json:"rollout_steps"` + UpdatedAt *time.Time `json:"updated_at"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AllocationId == nil { + return fmt.Errorf("required field allocation_id missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.GuardrailTriggers == nil { + return fmt.Errorf("required field guardrail_triggers missing") + } + if all.RolloutOptions == nil { + return fmt.Errorf("required field rollout_options missing") + } + if all.RolloutSteps == nil { + return fmt.Errorf("required field rollout_steps missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"absolute_start_time", "allocation_id", "control_variant_id", "created_at", "guardrail_triggered_action", "guardrail_triggers", "id", "rollout_options", "rollout_steps", "updated_at"}) + } else { + return err + } + + hasInvalidField := false + o.AbsoluteStartTime = all.AbsoluteStartTime + o.AllocationId = *all.AllocationId + o.ControlVariantId = all.ControlVariantId + o.CreatedAt = *all.CreatedAt + o.GuardrailTriggeredAction = all.GuardrailTriggeredAction + o.GuardrailTriggers = *all.GuardrailTriggers + o.Id = all.Id + if all.RolloutOptions.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.RolloutOptions = *all.RolloutOptions + o.RolloutSteps = *all.RolloutSteps + o.UpdatedAt = *all.UpdatedAt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_exposure_schedule_data.go b/api/datadogV2/model_allocation_exposure_schedule_data.go new file mode 100644 index 00000000000..67c3d3751e0 --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_schedule_data.go @@ -0,0 +1,180 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureScheduleData Data wrapper for progressive rollout schedule responses. +type AllocationExposureScheduleData struct { + // Progressive release details for a targeting rule allocation. + Attributes AllocationExposureSchedule `json:"attributes"` + // The unique identifier of the progressive rollout. + Id uuid.UUID `json:"id"` + // The resource type for progressive rollout schedules. + Type AllocationExposureScheduleDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationExposureScheduleData instantiates a new AllocationExposureScheduleData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationExposureScheduleData(attributes AllocationExposureSchedule, id uuid.UUID, typeVar AllocationExposureScheduleDataType) *AllocationExposureScheduleData { + this := AllocationExposureScheduleData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAllocationExposureScheduleDataWithDefaults instantiates a new AllocationExposureScheduleData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationExposureScheduleDataWithDefaults() *AllocationExposureScheduleData { + this := AllocationExposureScheduleData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AllocationExposureScheduleData) GetAttributes() AllocationExposureSchedule { + if o == nil { + var ret AllocationExposureSchedule + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureScheduleData) GetAttributesOk() (*AllocationExposureSchedule, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AllocationExposureScheduleData) SetAttributes(v AllocationExposureSchedule) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *AllocationExposureScheduleData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureScheduleData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AllocationExposureScheduleData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *AllocationExposureScheduleData) GetType() AllocationExposureScheduleDataType { + if o == nil { + var ret AllocationExposureScheduleDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureScheduleData) GetTypeOk() (*AllocationExposureScheduleDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AllocationExposureScheduleData) SetType(v AllocationExposureScheduleDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationExposureScheduleData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationExposureScheduleData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AllocationExposureSchedule `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *AllocationExposureScheduleDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_exposure_schedule_data_type.go b/api/datadogV2/model_allocation_exposure_schedule_data_type.go new file mode 100644 index 00000000000..c8ba7666735 --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_schedule_data_type.go @@ -0,0 +1,64 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureScheduleDataType The resource type for progressive rollout schedules. +type AllocationExposureScheduleDataType string + +// List of AllocationExposureScheduleDataType. +const ( + ALLOCATIONEXPOSURESCHEDULEDATATYPE_ALLOCATION_EXPOSURE_SCHEDULES AllocationExposureScheduleDataType = "allocation_exposure_schedules" +) + +var allowedAllocationExposureScheduleDataTypeEnumValues = []AllocationExposureScheduleDataType{ + ALLOCATIONEXPOSURESCHEDULEDATATYPE_ALLOCATION_EXPOSURE_SCHEDULES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AllocationExposureScheduleDataType) GetAllowedValues() []AllocationExposureScheduleDataType { + return allowedAllocationExposureScheduleDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AllocationExposureScheduleDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AllocationExposureScheduleDataType(value) + return nil +} + +// NewAllocationExposureScheduleDataTypeFromValue returns a pointer to a valid AllocationExposureScheduleDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAllocationExposureScheduleDataTypeFromValue(v string) (*AllocationExposureScheduleDataType, error) { + ev := AllocationExposureScheduleDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AllocationExposureScheduleDataType: valid values are %v", v, allowedAllocationExposureScheduleDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AllocationExposureScheduleDataType) IsValid() bool { + for _, existing := range allowedAllocationExposureScheduleDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AllocationExposureScheduleDataType value. +func (v AllocationExposureScheduleDataType) Ptr() *AllocationExposureScheduleDataType { + return &v +} diff --git a/api/datadogV2/model_allocation_exposure_schedule_response.go b/api/datadogV2/model_allocation_exposure_schedule_response.go new file mode 100644 index 00000000000..833a2d5d3f0 --- /dev/null +++ b/api/datadogV2/model_allocation_exposure_schedule_response.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationExposureScheduleResponse Response containing a progressive rollout schedule. +type AllocationExposureScheduleResponse struct { + // Data wrapper for progressive rollout schedule responses. + Data AllocationExposureScheduleData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationExposureScheduleResponse instantiates a new AllocationExposureScheduleResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationExposureScheduleResponse(data AllocationExposureScheduleData) *AllocationExposureScheduleResponse { + this := AllocationExposureScheduleResponse{} + this.Data = data + return &this +} + +// NewAllocationExposureScheduleResponseWithDefaults instantiates a new AllocationExposureScheduleResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationExposureScheduleResponseWithDefaults() *AllocationExposureScheduleResponse { + this := AllocationExposureScheduleResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *AllocationExposureScheduleResponse) GetData() AllocationExposureScheduleData { + if o == nil { + var ret AllocationExposureScheduleData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *AllocationExposureScheduleResponse) GetDataOk() (*AllocationExposureScheduleData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AllocationExposureScheduleResponse) SetData(v AllocationExposureScheduleData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationExposureScheduleResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationExposureScheduleResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AllocationExposureScheduleData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_response.go b/api/datadogV2/model_allocation_response.go new file mode 100644 index 00000000000..b2042bb29bf --- /dev/null +++ b/api/datadogV2/model_allocation_response.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationResponse Response containing a single targeting rule (allocation). +type AllocationResponse struct { + // Data wrapper for targeting rule allocation responses. + Data AllocationDataResponse `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAllocationResponse instantiates a new AllocationResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAllocationResponse(data AllocationDataResponse) *AllocationResponse { + this := AllocationResponse{} + this.Data = data + return &this +} + +// NewAllocationResponseWithDefaults instantiates a new AllocationResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAllocationResponseWithDefaults() *AllocationResponse { + this := AllocationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *AllocationResponse) GetData() AllocationDataResponse { + if o == nil { + var ret AllocationDataResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *AllocationResponse) GetDataOk() (*AllocationDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AllocationResponse) SetData(v AllocationDataResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AllocationResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AllocationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AllocationDataResponse `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_allocation_type.go b/api/datadogV2/model_allocation_type.go new file mode 100644 index 00000000000..20dc4ce389b --- /dev/null +++ b/api/datadogV2/model_allocation_type.go @@ -0,0 +1,66 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AllocationType The type of targeting rule (called allocation in the API model). +type AllocationType string + +// List of AllocationType. +const ( + ALLOCATIONTYPE_FEATURE_GATE AllocationType = "FEATURE_GATE" + ALLOCATIONTYPE_CANARY AllocationType = "CANARY" +) + +var allowedAllocationTypeEnumValues = []AllocationType{ + ALLOCATIONTYPE_FEATURE_GATE, + ALLOCATIONTYPE_CANARY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AllocationType) GetAllowedValues() []AllocationType { + return allowedAllocationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AllocationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AllocationType(value) + return nil +} + +// NewAllocationTypeFromValue returns a pointer to a valid AllocationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAllocationTypeFromValue(v string) (*AllocationType, error) { + ev := AllocationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AllocationType: valid values are %v", v, allowedAllocationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AllocationType) IsValid() bool { + for _, existing := range allowedAllocationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AllocationType value. +func (v AllocationType) Ptr() *AllocationType { + return &v +} diff --git a/api/datadogV2/model_condition.go b/api/datadogV2/model_condition.go new file mode 100644 index 00000000000..86d4ae047f9 --- /dev/null +++ b/api/datadogV2/model_condition.go @@ -0,0 +1,282 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Condition Targeting condition details. +type Condition struct { + // The user or request attribute to evaluate. + Attribute string `json:"attribute"` + // The timestamp when the condition was created. + CreatedAt time.Time `json:"created_at"` + // The unique identifier of the condition. + Id uuid.UUID `json:"id"` + // The operator used in a targeting condition. + Operator ConditionOperator `json:"operator"` + // The timestamp when the condition was last updated. + UpdatedAt time.Time `json:"updated_at"` + // Values used by the selected operator. + Value []string `json:"value"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCondition instantiates a new Condition object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCondition(attribute string, createdAt time.Time, id uuid.UUID, operator ConditionOperator, updatedAt time.Time, value []string) *Condition { + this := Condition{} + this.Attribute = attribute + this.CreatedAt = createdAt + this.Id = id + this.Operator = operator + this.UpdatedAt = updatedAt + this.Value = value + return &this +} + +// NewConditionWithDefaults instantiates a new Condition object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewConditionWithDefaults() *Condition { + this := Condition{} + return &this +} + +// GetAttribute returns the Attribute field value. +func (o *Condition) GetAttribute() string { + if o == nil { + var ret string + return ret + } + return o.Attribute +} + +// GetAttributeOk returns a tuple with the Attribute field value +// and a boolean to check if the value has been set. +func (o *Condition) GetAttributeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Attribute, true +} + +// SetAttribute sets field value. +func (o *Condition) SetAttribute(v string) { + o.Attribute = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *Condition) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *Condition) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *Condition) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetId returns the Id field value. +func (o *Condition) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Condition) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *Condition) SetId(v uuid.UUID) { + o.Id = v +} + +// GetOperator returns the Operator field value. +func (o *Condition) GetOperator() ConditionOperator { + if o == nil { + var ret ConditionOperator + return ret + } + return o.Operator +} + +// GetOperatorOk returns a tuple with the Operator field value +// and a boolean to check if the value has been set. +func (o *Condition) GetOperatorOk() (*ConditionOperator, bool) { + if o == nil { + return nil, false + } + return &o.Operator, true +} + +// SetOperator sets field value. +func (o *Condition) SetOperator(v ConditionOperator) { + o.Operator = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *Condition) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *Condition) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *Condition) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetValue returns the Value field value. +func (o *Condition) GetValue() []string { + if o == nil { + var ret []string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *Condition) GetValueOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *Condition) SetValue(v []string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Condition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attribute"] = o.Attribute + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["id"] = o.Id + toSerialize["operator"] = o.Operator + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Condition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attribute *string `json:"attribute"` + CreatedAt *time.Time `json:"created_at"` + Id *uuid.UUID `json:"id"` + Operator *ConditionOperator `json:"operator"` + UpdatedAt *time.Time `json:"updated_at"` + Value *[]string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attribute == nil { + return fmt.Errorf("required field attribute missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Operator == nil { + return fmt.Errorf("required field operator missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attribute", "created_at", "id", "operator", "updated_at", "value"}) + } else { + return err + } + + hasInvalidField := false + o.Attribute = *all.Attribute + o.CreatedAt = *all.CreatedAt + o.Id = *all.Id + if !all.Operator.IsValid() { + hasInvalidField = true + } else { + o.Operator = *all.Operator + } + o.UpdatedAt = *all.UpdatedAt + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_condition_operator.go b/api/datadogV2/model_condition_operator.go new file mode 100644 index 00000000000..ed5eeb7aa85 --- /dev/null +++ b/api/datadogV2/model_condition_operator.go @@ -0,0 +1,82 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ConditionOperator The operator used in a targeting condition. +type ConditionOperator string + +// List of ConditionOperator. +const ( + CONDITIONOPERATOR_LT ConditionOperator = "LT" + CONDITIONOPERATOR_LTE ConditionOperator = "LTE" + CONDITIONOPERATOR_GT ConditionOperator = "GT" + CONDITIONOPERATOR_GTE ConditionOperator = "GTE" + CONDITIONOPERATOR_MATCHES ConditionOperator = "MATCHES" + CONDITIONOPERATOR_NOT_MATCHES ConditionOperator = "NOT_MATCHES" + CONDITIONOPERATOR_ONE_OF ConditionOperator = "ONE_OF" + CONDITIONOPERATOR_NOT_ONE_OF ConditionOperator = "NOT_ONE_OF" + CONDITIONOPERATOR_IS_NULL ConditionOperator = "IS_NULL" + CONDITIONOPERATOR_EQUALS ConditionOperator = "EQUALS" +) + +var allowedConditionOperatorEnumValues = []ConditionOperator{ + CONDITIONOPERATOR_LT, + CONDITIONOPERATOR_LTE, + CONDITIONOPERATOR_GT, + CONDITIONOPERATOR_GTE, + CONDITIONOPERATOR_MATCHES, + CONDITIONOPERATOR_NOT_MATCHES, + CONDITIONOPERATOR_ONE_OF, + CONDITIONOPERATOR_NOT_ONE_OF, + CONDITIONOPERATOR_IS_NULL, + CONDITIONOPERATOR_EQUALS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ConditionOperator) GetAllowedValues() []ConditionOperator { + return allowedConditionOperatorEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ConditionOperator) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ConditionOperator(value) + return nil +} + +// NewConditionOperatorFromValue returns a pointer to a valid ConditionOperator +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewConditionOperatorFromValue(v string) (*ConditionOperator, error) { + ev := ConditionOperator(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ConditionOperator: valid values are %v", v, allowedConditionOperatorEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ConditionOperator) IsValid() bool { + for _, existing := range allowedConditionOperatorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ConditionOperator value. +func (v ConditionOperator) Ptr() *ConditionOperator { + return &v +} diff --git a/api/datadogV2/model_condition_request.go b/api/datadogV2/model_condition_request.go new file mode 100644 index 00000000000..568986eecfb --- /dev/null +++ b/api/datadogV2/model_condition_request.go @@ -0,0 +1,175 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ConditionRequest Condition request payload for targeting rules. +type ConditionRequest struct { + // The user or request attribute to evaluate. + Attribute string `json:"attribute"` + // The operator used in a targeting condition. + Operator ConditionOperator `json:"operator"` + // Values used by the selected operator. + Value []string `json:"value"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewConditionRequest instantiates a new ConditionRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewConditionRequest(attribute string, operator ConditionOperator, value []string) *ConditionRequest { + this := ConditionRequest{} + this.Attribute = attribute + this.Operator = operator + this.Value = value + return &this +} + +// NewConditionRequestWithDefaults instantiates a new ConditionRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewConditionRequestWithDefaults() *ConditionRequest { + this := ConditionRequest{} + return &this +} + +// GetAttribute returns the Attribute field value. +func (o *ConditionRequest) GetAttribute() string { + if o == nil { + var ret string + return ret + } + return o.Attribute +} + +// GetAttributeOk returns a tuple with the Attribute field value +// and a boolean to check if the value has been set. +func (o *ConditionRequest) GetAttributeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Attribute, true +} + +// SetAttribute sets field value. +func (o *ConditionRequest) SetAttribute(v string) { + o.Attribute = v +} + +// GetOperator returns the Operator field value. +func (o *ConditionRequest) GetOperator() ConditionOperator { + if o == nil { + var ret ConditionOperator + return ret + } + return o.Operator +} + +// GetOperatorOk returns a tuple with the Operator field value +// and a boolean to check if the value has been set. +func (o *ConditionRequest) GetOperatorOk() (*ConditionOperator, bool) { + if o == nil { + return nil, false + } + return &o.Operator, true +} + +// SetOperator sets field value. +func (o *ConditionRequest) SetOperator(v ConditionOperator) { + o.Operator = v +} + +// GetValue returns the Value field value. +func (o *ConditionRequest) GetValue() []string { + if o == nil { + var ret []string + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *ConditionRequest) GetValueOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *ConditionRequest) SetValue(v []string) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ConditionRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attribute"] = o.Attribute + toSerialize["operator"] = o.Operator + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ConditionRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attribute *string `json:"attribute"` + Operator *ConditionOperator `json:"operator"` + Value *[]string `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attribute == nil { + return fmt.Errorf("required field attribute missing") + } + if all.Operator == nil { + return fmt.Errorf("required field operator missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attribute", "operator", "value"}) + } else { + return err + } + + hasInvalidField := false + o.Attribute = *all.Attribute + if !all.Operator.IsValid() { + hasInvalidField = true + } else { + o.Operator = *all.Operator + } + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_allocations_request.go b/api/datadogV2/model_create_allocations_request.go new file mode 100644 index 00000000000..1510ad1c308 --- /dev/null +++ b/api/datadogV2/model_create_allocations_request.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateAllocationsRequest Request to create targeting rules (allocations) for a feature flag in an environment. +type CreateAllocationsRequest struct { + // Data wrapper for allocation request payloads. + Data AllocationDataRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateAllocationsRequest instantiates a new CreateAllocationsRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateAllocationsRequest(data AllocationDataRequest) *CreateAllocationsRequest { + this := CreateAllocationsRequest{} + this.Data = data + return &this +} + +// NewCreateAllocationsRequestWithDefaults instantiates a new CreateAllocationsRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateAllocationsRequestWithDefaults() *CreateAllocationsRequest { + this := CreateAllocationsRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateAllocationsRequest) GetData() AllocationDataRequest { + if o == nil { + var ret AllocationDataRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *CreateAllocationsRequest) GetDataOk() (*AllocationDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateAllocationsRequest) SetData(v AllocationDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateAllocationsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateAllocationsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AllocationDataRequest `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_exposure_rollout_step_request.go b/api/datadogV2/model_exposure_rollout_step_request.go new file mode 100644 index 00000000000..b25e2194b7d --- /dev/null +++ b/api/datadogV2/model_exposure_rollout_step_request.go @@ -0,0 +1,248 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ExposureRolloutStepRequest Rollout step request payload. +type ExposureRolloutStepRequest struct { + // The exposure ratio for this step. + ExposureRatio float64 `json:"exposure_ratio"` + // Logical index grouping related steps. + GroupedStepIndex int64 `json:"grouped_step_index"` + // The unique identifier of the progression step. + Id *uuid.UUID `json:"id,omitempty"` + // Step duration in milliseconds. + IntervalMs datadog.NullableInt64 `json:"interval_ms,omitempty"` + // Whether this step represents a pause record. + IsPauseRecord bool `json:"is_pause_record"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewExposureRolloutStepRequest instantiates a new ExposureRolloutStepRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewExposureRolloutStepRequest(exposureRatio float64, groupedStepIndex int64, isPauseRecord bool) *ExposureRolloutStepRequest { + this := ExposureRolloutStepRequest{} + this.ExposureRatio = exposureRatio + this.GroupedStepIndex = groupedStepIndex + this.IsPauseRecord = isPauseRecord + return &this +} + +// NewExposureRolloutStepRequestWithDefaults instantiates a new ExposureRolloutStepRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewExposureRolloutStepRequestWithDefaults() *ExposureRolloutStepRequest { + this := ExposureRolloutStepRequest{} + return &this +} + +// GetExposureRatio returns the ExposureRatio field value. +func (o *ExposureRolloutStepRequest) GetExposureRatio() float64 { + if o == nil { + var ret float64 + return ret + } + return o.ExposureRatio +} + +// GetExposureRatioOk returns a tuple with the ExposureRatio field value +// and a boolean to check if the value has been set. +func (o *ExposureRolloutStepRequest) GetExposureRatioOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.ExposureRatio, true +} + +// SetExposureRatio sets field value. +func (o *ExposureRolloutStepRequest) SetExposureRatio(v float64) { + o.ExposureRatio = v +} + +// GetGroupedStepIndex returns the GroupedStepIndex field value. +func (o *ExposureRolloutStepRequest) GetGroupedStepIndex() int64 { + if o == nil { + var ret int64 + return ret + } + return o.GroupedStepIndex +} + +// GetGroupedStepIndexOk returns a tuple with the GroupedStepIndex field value +// and a boolean to check if the value has been set. +func (o *ExposureRolloutStepRequest) GetGroupedStepIndexOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.GroupedStepIndex, true +} + +// SetGroupedStepIndex sets field value. +func (o *ExposureRolloutStepRequest) SetGroupedStepIndex(v int64) { + o.GroupedStepIndex = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ExposureRolloutStepRequest) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ExposureRolloutStepRequest) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ExposureRolloutStepRequest) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *ExposureRolloutStepRequest) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetIntervalMs returns the IntervalMs field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ExposureRolloutStepRequest) GetIntervalMs() int64 { + if o == nil || o.IntervalMs.Get() == nil { + var ret int64 + return ret + } + return *o.IntervalMs.Get() +} + +// GetIntervalMsOk returns a tuple with the IntervalMs field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ExposureRolloutStepRequest) GetIntervalMsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.IntervalMs.Get(), o.IntervalMs.IsSet() +} + +// HasIntervalMs returns a boolean if a field has been set. +func (o *ExposureRolloutStepRequest) HasIntervalMs() bool { + return o != nil && o.IntervalMs.IsSet() +} + +// SetIntervalMs gets a reference to the given datadog.NullableInt64 and assigns it to the IntervalMs field. +func (o *ExposureRolloutStepRequest) SetIntervalMs(v int64) { + o.IntervalMs.Set(&v) +} + +// SetIntervalMsNil sets the value for IntervalMs to be an explicit nil. +func (o *ExposureRolloutStepRequest) SetIntervalMsNil() { + o.IntervalMs.Set(nil) +} + +// UnsetIntervalMs ensures that no value is present for IntervalMs, not even an explicit nil. +func (o *ExposureRolloutStepRequest) UnsetIntervalMs() { + o.IntervalMs.Unset() +} + +// GetIsPauseRecord returns the IsPauseRecord field value. +func (o *ExposureRolloutStepRequest) GetIsPauseRecord() bool { + if o == nil { + var ret bool + return ret + } + return o.IsPauseRecord +} + +// GetIsPauseRecordOk returns a tuple with the IsPauseRecord field value +// and a boolean to check if the value has been set. +func (o *ExposureRolloutStepRequest) GetIsPauseRecordOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsPauseRecord, true +} + +// SetIsPauseRecord sets field value. +func (o *ExposureRolloutStepRequest) SetIsPauseRecord(v bool) { + o.IsPauseRecord = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ExposureRolloutStepRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["exposure_ratio"] = o.ExposureRatio + toSerialize["grouped_step_index"] = o.GroupedStepIndex + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.IntervalMs.IsSet() { + toSerialize["interval_ms"] = o.IntervalMs.Get() + } + toSerialize["is_pause_record"] = o.IsPauseRecord + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ExposureRolloutStepRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ExposureRatio *float64 `json:"exposure_ratio"` + GroupedStepIndex *int64 `json:"grouped_step_index"` + Id *uuid.UUID `json:"id,omitempty"` + IntervalMs datadog.NullableInt64 `json:"interval_ms,omitempty"` + IsPauseRecord *bool `json:"is_pause_record"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ExposureRatio == nil { + return fmt.Errorf("required field exposure_ratio missing") + } + if all.GroupedStepIndex == nil { + return fmt.Errorf("required field grouped_step_index missing") + } + if all.IsPauseRecord == nil { + return fmt.Errorf("required field is_pause_record missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"exposure_ratio", "grouped_step_index", "id", "interval_ms", "is_pause_record"}) + } else { + return err + } + o.ExposureRatio = *all.ExposureRatio + o.GroupedStepIndex = *all.GroupedStepIndex + o.Id = all.Id + o.IntervalMs = all.IntervalMs + o.IsPauseRecord = *all.IsPauseRecord + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_exposure_schedule_request.go b/api/datadogV2/model_exposure_schedule_request.go new file mode 100644 index 00000000000..0db73faee77 --- /dev/null +++ b/api/datadogV2/model_exposure_schedule_request.go @@ -0,0 +1,318 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ExposureScheduleRequest Progressive release request payload. +type ExposureScheduleRequest struct { + // The absolute UTC start time for this schedule. + AbsoluteStartTime datadog.NullableTime `json:"absolute_start_time,omitempty"` + // The control variant ID used for experiment comparisons. + ControlVariantId datadog.NullableString `json:"control_variant_id,omitempty"` + // The control variant key used during creation workflows. + ControlVariantKey datadog.NullableString `json:"control_variant_key,omitempty"` + // The unique identifier of the progressive rollout. + Id *uuid.UUID `json:"id,omitempty"` + // Rollout options request payload. + RolloutOptions RolloutOptionsRequest `json:"rollout_options"` + // Ordered progression steps for exposure. + RolloutSteps []ExposureRolloutStepRequest `json:"rollout_steps"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewExposureScheduleRequest instantiates a new ExposureScheduleRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewExposureScheduleRequest(rolloutOptions RolloutOptionsRequest, rolloutSteps []ExposureRolloutStepRequest) *ExposureScheduleRequest { + this := ExposureScheduleRequest{} + this.RolloutOptions = rolloutOptions + this.RolloutSteps = rolloutSteps + return &this +} + +// NewExposureScheduleRequestWithDefaults instantiates a new ExposureScheduleRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewExposureScheduleRequestWithDefaults() *ExposureScheduleRequest { + this := ExposureScheduleRequest{} + return &this +} + +// GetAbsoluteStartTime returns the AbsoluteStartTime field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ExposureScheduleRequest) GetAbsoluteStartTime() time.Time { + if o == nil || o.AbsoluteStartTime.Get() == nil { + var ret time.Time + return ret + } + return *o.AbsoluteStartTime.Get() +} + +// GetAbsoluteStartTimeOk returns a tuple with the AbsoluteStartTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ExposureScheduleRequest) GetAbsoluteStartTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.AbsoluteStartTime.Get(), o.AbsoluteStartTime.IsSet() +} + +// HasAbsoluteStartTime returns a boolean if a field has been set. +func (o *ExposureScheduleRequest) HasAbsoluteStartTime() bool { + return o != nil && o.AbsoluteStartTime.IsSet() +} + +// SetAbsoluteStartTime gets a reference to the given datadog.NullableTime and assigns it to the AbsoluteStartTime field. +func (o *ExposureScheduleRequest) SetAbsoluteStartTime(v time.Time) { + o.AbsoluteStartTime.Set(&v) +} + +// SetAbsoluteStartTimeNil sets the value for AbsoluteStartTime to be an explicit nil. +func (o *ExposureScheduleRequest) SetAbsoluteStartTimeNil() { + o.AbsoluteStartTime.Set(nil) +} + +// UnsetAbsoluteStartTime ensures that no value is present for AbsoluteStartTime, not even an explicit nil. +func (o *ExposureScheduleRequest) UnsetAbsoluteStartTime() { + o.AbsoluteStartTime.Unset() +} + +// GetControlVariantId returns the ControlVariantId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ExposureScheduleRequest) GetControlVariantId() string { + if o == nil || o.ControlVariantId.Get() == nil { + var ret string + return ret + } + return *o.ControlVariantId.Get() +} + +// GetControlVariantIdOk returns a tuple with the ControlVariantId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ExposureScheduleRequest) GetControlVariantIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.ControlVariantId.Get(), o.ControlVariantId.IsSet() +} + +// HasControlVariantId returns a boolean if a field has been set. +func (o *ExposureScheduleRequest) HasControlVariantId() bool { + return o != nil && o.ControlVariantId.IsSet() +} + +// SetControlVariantId gets a reference to the given datadog.NullableString and assigns it to the ControlVariantId field. +func (o *ExposureScheduleRequest) SetControlVariantId(v string) { + o.ControlVariantId.Set(&v) +} + +// SetControlVariantIdNil sets the value for ControlVariantId to be an explicit nil. +func (o *ExposureScheduleRequest) SetControlVariantIdNil() { + o.ControlVariantId.Set(nil) +} + +// UnsetControlVariantId ensures that no value is present for ControlVariantId, not even an explicit nil. +func (o *ExposureScheduleRequest) UnsetControlVariantId() { + o.ControlVariantId.Unset() +} + +// GetControlVariantKey returns the ControlVariantKey field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ExposureScheduleRequest) GetControlVariantKey() string { + if o == nil || o.ControlVariantKey.Get() == nil { + var ret string + return ret + } + return *o.ControlVariantKey.Get() +} + +// GetControlVariantKeyOk returns a tuple with the ControlVariantKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ExposureScheduleRequest) GetControlVariantKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.ControlVariantKey.Get(), o.ControlVariantKey.IsSet() +} + +// HasControlVariantKey returns a boolean if a field has been set. +func (o *ExposureScheduleRequest) HasControlVariantKey() bool { + return o != nil && o.ControlVariantKey.IsSet() +} + +// SetControlVariantKey gets a reference to the given datadog.NullableString and assigns it to the ControlVariantKey field. +func (o *ExposureScheduleRequest) SetControlVariantKey(v string) { + o.ControlVariantKey.Set(&v) +} + +// SetControlVariantKeyNil sets the value for ControlVariantKey to be an explicit nil. +func (o *ExposureScheduleRequest) SetControlVariantKeyNil() { + o.ControlVariantKey.Set(nil) +} + +// UnsetControlVariantKey ensures that no value is present for ControlVariantKey, not even an explicit nil. +func (o *ExposureScheduleRequest) UnsetControlVariantKey() { + o.ControlVariantKey.Unset() +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ExposureScheduleRequest) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ExposureScheduleRequest) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ExposureScheduleRequest) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *ExposureScheduleRequest) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetRolloutOptions returns the RolloutOptions field value. +func (o *ExposureScheduleRequest) GetRolloutOptions() RolloutOptionsRequest { + if o == nil { + var ret RolloutOptionsRequest + return ret + } + return o.RolloutOptions +} + +// GetRolloutOptionsOk returns a tuple with the RolloutOptions field value +// and a boolean to check if the value has been set. +func (o *ExposureScheduleRequest) GetRolloutOptionsOk() (*RolloutOptionsRequest, bool) { + if o == nil { + return nil, false + } + return &o.RolloutOptions, true +} + +// SetRolloutOptions sets field value. +func (o *ExposureScheduleRequest) SetRolloutOptions(v RolloutOptionsRequest) { + o.RolloutOptions = v +} + +// GetRolloutSteps returns the RolloutSteps field value. +func (o *ExposureScheduleRequest) GetRolloutSteps() []ExposureRolloutStepRequest { + if o == nil { + var ret []ExposureRolloutStepRequest + return ret + } + return o.RolloutSteps +} + +// GetRolloutStepsOk returns a tuple with the RolloutSteps field value +// and a boolean to check if the value has been set. +func (o *ExposureScheduleRequest) GetRolloutStepsOk() (*[]ExposureRolloutStepRequest, bool) { + if o == nil { + return nil, false + } + return &o.RolloutSteps, true +} + +// SetRolloutSteps sets field value. +func (o *ExposureScheduleRequest) SetRolloutSteps(v []ExposureRolloutStepRequest) { + o.RolloutSteps = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ExposureScheduleRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AbsoluteStartTime.IsSet() { + toSerialize["absolute_start_time"] = o.AbsoluteStartTime.Get() + } + if o.ControlVariantId.IsSet() { + toSerialize["control_variant_id"] = o.ControlVariantId.Get() + } + if o.ControlVariantKey.IsSet() { + toSerialize["control_variant_key"] = o.ControlVariantKey.Get() + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["rollout_options"] = o.RolloutOptions + toSerialize["rollout_steps"] = o.RolloutSteps + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ExposureScheduleRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AbsoluteStartTime datadog.NullableTime `json:"absolute_start_time,omitempty"` + ControlVariantId datadog.NullableString `json:"control_variant_id,omitempty"` + ControlVariantKey datadog.NullableString `json:"control_variant_key,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + RolloutOptions *RolloutOptionsRequest `json:"rollout_options"` + RolloutSteps *[]ExposureRolloutStepRequest `json:"rollout_steps"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.RolloutOptions == nil { + return fmt.Errorf("required field rollout_options missing") + } + if all.RolloutSteps == nil { + return fmt.Errorf("required field rollout_steps missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"absolute_start_time", "control_variant_id", "control_variant_key", "id", "rollout_options", "rollout_steps"}) + } else { + return err + } + + hasInvalidField := false + o.AbsoluteStartTime = all.AbsoluteStartTime + o.ControlVariantId = all.ControlVariantId + o.ControlVariantKey = all.ControlVariantKey + o.Id = all.Id + if all.RolloutOptions.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.RolloutOptions = *all.RolloutOptions + o.RolloutSteps = *all.RolloutSteps + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_feature_flag_attributes.go b/api/datadogV2/model_feature_flag_attributes.go index 5927917ac11..abb5e4b56f7 100644 --- a/api/datadogV2/model_feature_flag_attributes.go +++ b/api/datadogV2/model_feature_flag_attributes.go @@ -37,6 +37,8 @@ type FeatureFlagAttributes struct { Name string `json:"name"` // Indicates whether this feature flag requires approval for changes. RequireApproval *bool `json:"require_approval,omitempty"` + // Tags associated with the feature flag. + Tags []string `json:"tags,omitempty"` // The timestamp when the feature flag was last updated. UpdatedAt *time.Time `json:"updated_at,omitempty"` // The type of values for the feature flag variants. @@ -385,6 +387,34 @@ func (o *FeatureFlagAttributes) SetRequireApproval(v bool) { o.RequireApproval = &v } +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *FeatureFlagAttributes) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FeatureFlagAttributes) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *FeatureFlagAttributes) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *FeatureFlagAttributes) SetTags(v []string) { + o.Tags = v +} + // GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. func (o *FeatureFlagAttributes) GetUpdatedAt() time.Time { if o == nil || o.UpdatedAt == nil { @@ -496,6 +526,9 @@ func (o FeatureFlagAttributes) MarshalJSON() ([]byte, error) { if o.RequireApproval != nil { toSerialize["require_approval"] = o.RequireApproval } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } if o.UpdatedAt != nil { if o.UpdatedAt.Nanosecond() == 0 { toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") @@ -526,6 +559,7 @@ func (o *FeatureFlagAttributes) UnmarshalJSON(bytes []byte) (err error) { LastUpdatedBy *uuid.UUID `json:"last_updated_by,omitempty"` Name *string `json:"name"` RequireApproval *bool `json:"require_approval,omitempty"` + Tags []string `json:"tags,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` ValueType *ValueType `json:"value_type"` Variants *[]Variant `json:"variants"` @@ -550,7 +584,7 @@ func (o *FeatureFlagAttributes) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"archived_at", "created_at", "created_by", "description", "distribution_channel", "feature_flag_environments", "json_schema", "key", "last_updated_by", "name", "require_approval", "updated_at", "value_type", "variants"}) + datadog.DeleteKeys(additionalProperties, &[]string{"archived_at", "created_at", "created_by", "description", "distribution_channel", "feature_flag_environments", "json_schema", "key", "last_updated_by", "name", "require_approval", "tags", "updated_at", "value_type", "variants"}) } else { return err } @@ -567,6 +601,7 @@ func (o *FeatureFlagAttributes) UnmarshalJSON(bytes []byte) (err error) { o.LastUpdatedBy = all.LastUpdatedBy o.Name = *all.Name o.RequireApproval = all.RequireApproval + o.Tags = all.Tags o.UpdatedAt = all.UpdatedAt if !all.ValueType.IsValid() { hasInvalidField = true diff --git a/api/datadogV2/model_feature_flag_environment.go b/api/datadogV2/model_feature_flag_environment.go index 54d63405a20..71fde2f107e 100644 --- a/api/datadogV2/model_feature_flag_environment.go +++ b/api/datadogV2/model_feature_flag_environment.go @@ -24,6 +24,8 @@ type FeatureFlagEnvironment struct { EnvironmentId uuid.UUID `json:"environment_id"` // The name of the environment. EnvironmentName *string `json:"environment_name,omitempty"` + // Queries that target this environment. + EnvironmentQueries []string `json:"environment_queries,omitempty"` // Indicates whether the environment is production. IsProduction *bool `json:"is_production,omitempty"` // The allocation key used for the override variant. @@ -211,6 +213,34 @@ func (o *FeatureFlagEnvironment) SetEnvironmentName(v string) { o.EnvironmentName = &v } +// GetEnvironmentQueries returns the EnvironmentQueries field value if set, zero value otherwise. +func (o *FeatureFlagEnvironment) GetEnvironmentQueries() []string { + if o == nil || o.EnvironmentQueries == nil { + var ret []string + return ret + } + return o.EnvironmentQueries +} + +// GetEnvironmentQueriesOk returns a tuple with the EnvironmentQueries field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FeatureFlagEnvironment) GetEnvironmentQueriesOk() (*[]string, bool) { + if o == nil || o.EnvironmentQueries == nil { + return nil, false + } + return &o.EnvironmentQueries, true +} + +// HasEnvironmentQueries returns a boolean if a field has been set. +func (o *FeatureFlagEnvironment) HasEnvironmentQueries() bool { + return o != nil && o.EnvironmentQueries != nil +} + +// SetEnvironmentQueries gets a reference to the given []string and assigns it to the EnvironmentQueries field. +func (o *FeatureFlagEnvironment) SetEnvironmentQueries(v []string) { + o.EnvironmentQueries = v +} + // GetIsProduction returns the IsProduction field value if set, zero value otherwise. func (o *FeatureFlagEnvironment) GetIsProduction() bool { if o == nil || o.IsProduction == nil { @@ -471,6 +501,9 @@ func (o FeatureFlagEnvironment) MarshalJSON() ([]byte, error) { if o.EnvironmentName != nil { toSerialize["environment_name"] = o.EnvironmentName } + if o.EnvironmentQueries != nil { + toSerialize["environment_queries"] = o.EnvironmentQueries + } if o.IsProduction != nil { toSerialize["is_production"] = o.IsProduction } @@ -508,6 +541,7 @@ func (o *FeatureFlagEnvironment) UnmarshalJSON(bytes []byte) (err error) { DefaultVariantId datadog.NullableString `json:"default_variant_id,omitempty"` EnvironmentId *uuid.UUID `json:"environment_id"` EnvironmentName *string `json:"environment_name,omitempty"` + EnvironmentQueries []string `json:"environment_queries,omitempty"` IsProduction *bool `json:"is_production,omitempty"` OverrideAllocationKey *string `json:"override_allocation_key,omitempty"` OverrideVariantId datadog.NullableString `json:"override_variant_id,omitempty"` @@ -528,7 +562,7 @@ func (o *FeatureFlagEnvironment) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"allocations", "default_allocation_key", "default_variant_id", "environment_id", "environment_name", "is_production", "override_allocation_key", "override_variant_id", "pending_suggestion_id", "require_feature_flag_approval", "rollout_percentage", "rules", "status"}) + datadog.DeleteKeys(additionalProperties, &[]string{"allocations", "default_allocation_key", "default_variant_id", "environment_id", "environment_name", "environment_queries", "is_production", "override_allocation_key", "override_variant_id", "pending_suggestion_id", "require_feature_flag_approval", "rollout_percentage", "rules", "status"}) } else { return err } @@ -539,6 +573,7 @@ func (o *FeatureFlagEnvironment) UnmarshalJSON(bytes []byte) (err error) { o.DefaultVariantId = all.DefaultVariantId o.EnvironmentId = *all.EnvironmentId o.EnvironmentName = all.EnvironmentName + o.EnvironmentQueries = all.EnvironmentQueries o.IsProduction = all.IsProduction o.OverrideAllocationKey = all.OverrideAllocationKey o.OverrideVariantId = all.OverrideVariantId diff --git a/api/datadogV2/model_guardrail_metric.go b/api/datadogV2/model_guardrail_metric.go new file mode 100644 index 00000000000..9596074e2ed --- /dev/null +++ b/api/datadogV2/model_guardrail_metric.go @@ -0,0 +1,189 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GuardrailMetric Guardrail metric details. +type GuardrailMetric struct { + // The metric ID to monitor. + MetricId string `json:"metric_id"` + // Action to perform when a guardrail threshold is triggered. + TriggerAction GuardrailTriggerAction `json:"trigger_action"` + // The signal or system that triggered the action. + TriggeredBy datadog.NullableString `json:"triggered_by,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGuardrailMetric instantiates a new GuardrailMetric object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGuardrailMetric(metricId string, triggerAction GuardrailTriggerAction) *GuardrailMetric { + this := GuardrailMetric{} + this.MetricId = metricId + this.TriggerAction = triggerAction + return &this +} + +// NewGuardrailMetricWithDefaults instantiates a new GuardrailMetric object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGuardrailMetricWithDefaults() *GuardrailMetric { + this := GuardrailMetric{} + return &this +} + +// GetMetricId returns the MetricId field value. +func (o *GuardrailMetric) GetMetricId() string { + if o == nil { + var ret string + return ret + } + return o.MetricId +} + +// GetMetricIdOk returns a tuple with the MetricId field value +// and a boolean to check if the value has been set. +func (o *GuardrailMetric) GetMetricIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetricId, true +} + +// SetMetricId sets field value. +func (o *GuardrailMetric) SetMetricId(v string) { + o.MetricId = v +} + +// GetTriggerAction returns the TriggerAction field value. +func (o *GuardrailMetric) GetTriggerAction() GuardrailTriggerAction { + if o == nil { + var ret GuardrailTriggerAction + return ret + } + return o.TriggerAction +} + +// GetTriggerActionOk returns a tuple with the TriggerAction field value +// and a boolean to check if the value has been set. +func (o *GuardrailMetric) GetTriggerActionOk() (*GuardrailTriggerAction, bool) { + if o == nil { + return nil, false + } + return &o.TriggerAction, true +} + +// SetTriggerAction sets field value. +func (o *GuardrailMetric) SetTriggerAction(v GuardrailTriggerAction) { + o.TriggerAction = v +} + +// GetTriggeredBy returns the TriggeredBy field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *GuardrailMetric) GetTriggeredBy() string { + if o == nil || o.TriggeredBy.Get() == nil { + var ret string + return ret + } + return *o.TriggeredBy.Get() +} + +// GetTriggeredByOk returns a tuple with the TriggeredBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *GuardrailMetric) GetTriggeredByOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.TriggeredBy.Get(), o.TriggeredBy.IsSet() +} + +// HasTriggeredBy returns a boolean if a field has been set. +func (o *GuardrailMetric) HasTriggeredBy() bool { + return o != nil && o.TriggeredBy.IsSet() +} + +// SetTriggeredBy gets a reference to the given datadog.NullableString and assigns it to the TriggeredBy field. +func (o *GuardrailMetric) SetTriggeredBy(v string) { + o.TriggeredBy.Set(&v) +} + +// SetTriggeredByNil sets the value for TriggeredBy to be an explicit nil. +func (o *GuardrailMetric) SetTriggeredByNil() { + o.TriggeredBy.Set(nil) +} + +// UnsetTriggeredBy ensures that no value is present for TriggeredBy, not even an explicit nil. +func (o *GuardrailMetric) UnsetTriggeredBy() { + o.TriggeredBy.Unset() +} + +// MarshalJSON serializes the struct using spec logic. +func (o GuardrailMetric) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["metric_id"] = o.MetricId + toSerialize["trigger_action"] = o.TriggerAction + if o.TriggeredBy.IsSet() { + toSerialize["triggered_by"] = o.TriggeredBy.Get() + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GuardrailMetric) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + MetricId *string `json:"metric_id"` + TriggerAction *GuardrailTriggerAction `json:"trigger_action"` + TriggeredBy datadog.NullableString `json:"triggered_by,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.MetricId == nil { + return fmt.Errorf("required field metric_id missing") + } + if all.TriggerAction == nil { + return fmt.Errorf("required field trigger_action missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"metric_id", "trigger_action", "triggered_by"}) + } else { + return err + } + + hasInvalidField := false + o.MetricId = *all.MetricId + if !all.TriggerAction.IsValid() { + hasInvalidField = true + } else { + o.TriggerAction = *all.TriggerAction + } + o.TriggeredBy = all.TriggeredBy + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_guardrail_metric_request.go b/api/datadogV2/model_guardrail_metric_request.go new file mode 100644 index 00000000000..06b598f95c4 --- /dev/null +++ b/api/datadogV2/model_guardrail_metric_request.go @@ -0,0 +1,143 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GuardrailMetricRequest Guardrail metric request payload. +type GuardrailMetricRequest struct { + // The metric ID to monitor. + MetricId string `json:"metric_id"` + // Action to perform when a guardrail threshold is triggered. + TriggerAction GuardrailTriggerAction `json:"trigger_action"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGuardrailMetricRequest instantiates a new GuardrailMetricRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGuardrailMetricRequest(metricId string, triggerAction GuardrailTriggerAction) *GuardrailMetricRequest { + this := GuardrailMetricRequest{} + this.MetricId = metricId + this.TriggerAction = triggerAction + return &this +} + +// NewGuardrailMetricRequestWithDefaults instantiates a new GuardrailMetricRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGuardrailMetricRequestWithDefaults() *GuardrailMetricRequest { + this := GuardrailMetricRequest{} + return &this +} + +// GetMetricId returns the MetricId field value. +func (o *GuardrailMetricRequest) GetMetricId() string { + if o == nil { + var ret string + return ret + } + return o.MetricId +} + +// GetMetricIdOk returns a tuple with the MetricId field value +// and a boolean to check if the value has been set. +func (o *GuardrailMetricRequest) GetMetricIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetricId, true +} + +// SetMetricId sets field value. +func (o *GuardrailMetricRequest) SetMetricId(v string) { + o.MetricId = v +} + +// GetTriggerAction returns the TriggerAction field value. +func (o *GuardrailMetricRequest) GetTriggerAction() GuardrailTriggerAction { + if o == nil { + var ret GuardrailTriggerAction + return ret + } + return o.TriggerAction +} + +// GetTriggerActionOk returns a tuple with the TriggerAction field value +// and a boolean to check if the value has been set. +func (o *GuardrailMetricRequest) GetTriggerActionOk() (*GuardrailTriggerAction, bool) { + if o == nil { + return nil, false + } + return &o.TriggerAction, true +} + +// SetTriggerAction sets field value. +func (o *GuardrailMetricRequest) SetTriggerAction(v GuardrailTriggerAction) { + o.TriggerAction = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GuardrailMetricRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["metric_id"] = o.MetricId + toSerialize["trigger_action"] = o.TriggerAction + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GuardrailMetricRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + MetricId *string `json:"metric_id"` + TriggerAction *GuardrailTriggerAction `json:"trigger_action"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.MetricId == nil { + return fmt.Errorf("required field metric_id missing") + } + if all.TriggerAction == nil { + return fmt.Errorf("required field trigger_action missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"metric_id", "trigger_action"}) + } else { + return err + } + + hasInvalidField := false + o.MetricId = *all.MetricId + if !all.TriggerAction.IsValid() { + hasInvalidField = true + } else { + o.TriggerAction = *all.TriggerAction + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_guardrail_trigger_action.go b/api/datadogV2/model_guardrail_trigger_action.go new file mode 100644 index 00000000000..c0e74b29cf1 --- /dev/null +++ b/api/datadogV2/model_guardrail_trigger_action.go @@ -0,0 +1,66 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GuardrailTriggerAction Action to perform when a guardrail threshold is triggered. +type GuardrailTriggerAction string + +// List of GuardrailTriggerAction. +const ( + GUARDRAILTRIGGERACTION_PAUSE GuardrailTriggerAction = "PAUSE" + GUARDRAILTRIGGERACTION_ABORT GuardrailTriggerAction = "ABORT" +) + +var allowedGuardrailTriggerActionEnumValues = []GuardrailTriggerAction{ + GUARDRAILTRIGGERACTION_PAUSE, + GUARDRAILTRIGGERACTION_ABORT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GuardrailTriggerAction) GetAllowedValues() []GuardrailTriggerAction { + return allowedGuardrailTriggerActionEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GuardrailTriggerAction) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GuardrailTriggerAction(value) + return nil +} + +// NewGuardrailTriggerActionFromValue returns a pointer to a valid GuardrailTriggerAction +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGuardrailTriggerActionFromValue(v string) (*GuardrailTriggerAction, error) { + ev := GuardrailTriggerAction(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GuardrailTriggerAction: valid values are %v", v, allowedGuardrailTriggerActionEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GuardrailTriggerAction) IsValid() bool { + for _, existing := range allowedGuardrailTriggerActionEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GuardrailTriggerAction value. +func (v GuardrailTriggerAction) Ptr() *GuardrailTriggerAction { + return &v +} diff --git a/api/datadogV2/model_list_allocations_response.go b/api/datadogV2/model_list_allocations_response.go new file mode 100644 index 00000000000..45809cf8d2c --- /dev/null +++ b/api/datadogV2/model_list_allocations_response.go @@ -0,0 +1,101 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListAllocationsResponse Response containing a list of targeting rules (allocations). +type ListAllocationsResponse struct { + // List of targeting rules (allocations). + Data []AllocationDataResponse `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListAllocationsResponse instantiates a new ListAllocationsResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListAllocationsResponse(data []AllocationDataResponse) *ListAllocationsResponse { + this := ListAllocationsResponse{} + this.Data = data + return &this +} + +// NewListAllocationsResponseWithDefaults instantiates a new ListAllocationsResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListAllocationsResponseWithDefaults() *ListAllocationsResponse { + this := ListAllocationsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ListAllocationsResponse) GetData() []AllocationDataResponse { + if o == nil { + var ret []AllocationDataResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ListAllocationsResponse) GetDataOk() (*[]AllocationDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ListAllocationsResponse) SetData(v []AllocationDataResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListAllocationsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListAllocationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]AllocationDataResponse `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_overwrite_allocations_request.go b/api/datadogV2/model_overwrite_allocations_request.go new file mode 100644 index 00000000000..3f0b1862757 --- /dev/null +++ b/api/datadogV2/model_overwrite_allocations_request.go @@ -0,0 +1,101 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OverwriteAllocationsRequest Request to overwrite targeting rules (allocations) for a feature flag in an environment. +type OverwriteAllocationsRequest struct { + // Targeting rules (allocations) to replace existing ones with. + Data []AllocationDataRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewOverwriteAllocationsRequest instantiates a new OverwriteAllocationsRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOverwriteAllocationsRequest(data []AllocationDataRequest) *OverwriteAllocationsRequest { + this := OverwriteAllocationsRequest{} + this.Data = data + return &this +} + +// NewOverwriteAllocationsRequestWithDefaults instantiates a new OverwriteAllocationsRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOverwriteAllocationsRequestWithDefaults() *OverwriteAllocationsRequest { + this := OverwriteAllocationsRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *OverwriteAllocationsRequest) GetData() []AllocationDataRequest { + if o == nil { + var ret []AllocationDataRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OverwriteAllocationsRequest) GetDataOk() (*[]AllocationDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OverwriteAllocationsRequest) SetData(v []AllocationDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OverwriteAllocationsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OverwriteAllocationsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]AllocationDataRequest `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_rollout_options.go b/api/datadogV2/model_rollout_options.go new file mode 100644 index 00000000000..14ceb725869 --- /dev/null +++ b/api/datadogV2/model_rollout_options.go @@ -0,0 +1,175 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RolloutOptions Applied progression options for a progressive rollout. +type RolloutOptions struct { + // Whether the schedule starts automatically. + Autostart bool `json:"autostart"` + // Interval in milliseconds for uniform interval strategies. + SelectionIntervalMs int64 `json:"selection_interval_ms"` + // The progression strategy used by a progressive rollout. + Strategy RolloutStrategy `json:"strategy"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewRolloutOptions instantiates a new RolloutOptions object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRolloutOptions(autostart bool, selectionIntervalMs int64, strategy RolloutStrategy) *RolloutOptions { + this := RolloutOptions{} + this.Autostart = autostart + this.SelectionIntervalMs = selectionIntervalMs + this.Strategy = strategy + return &this +} + +// NewRolloutOptionsWithDefaults instantiates a new RolloutOptions object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewRolloutOptionsWithDefaults() *RolloutOptions { + this := RolloutOptions{} + return &this +} + +// GetAutostart returns the Autostart field value. +func (o *RolloutOptions) GetAutostart() bool { + if o == nil { + var ret bool + return ret + } + return o.Autostart +} + +// GetAutostartOk returns a tuple with the Autostart field value +// and a boolean to check if the value has been set. +func (o *RolloutOptions) GetAutostartOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Autostart, true +} + +// SetAutostart sets field value. +func (o *RolloutOptions) SetAutostart(v bool) { + o.Autostart = v +} + +// GetSelectionIntervalMs returns the SelectionIntervalMs field value. +func (o *RolloutOptions) GetSelectionIntervalMs() int64 { + if o == nil { + var ret int64 + return ret + } + return o.SelectionIntervalMs +} + +// GetSelectionIntervalMsOk returns a tuple with the SelectionIntervalMs field value +// and a boolean to check if the value has been set. +func (o *RolloutOptions) GetSelectionIntervalMsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.SelectionIntervalMs, true +} + +// SetSelectionIntervalMs sets field value. +func (o *RolloutOptions) SetSelectionIntervalMs(v int64) { + o.SelectionIntervalMs = v +} + +// GetStrategy returns the Strategy field value. +func (o *RolloutOptions) GetStrategy() RolloutStrategy { + if o == nil { + var ret RolloutStrategy + return ret + } + return o.Strategy +} + +// GetStrategyOk returns a tuple with the Strategy field value +// and a boolean to check if the value has been set. +func (o *RolloutOptions) GetStrategyOk() (*RolloutStrategy, bool) { + if o == nil { + return nil, false + } + return &o.Strategy, true +} + +// SetStrategy sets field value. +func (o *RolloutOptions) SetStrategy(v RolloutStrategy) { + o.Strategy = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RolloutOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["autostart"] = o.Autostart + toSerialize["selection_interval_ms"] = o.SelectionIntervalMs + toSerialize["strategy"] = o.Strategy + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RolloutOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Autostart *bool `json:"autostart"` + SelectionIntervalMs *int64 `json:"selection_interval_ms"` + Strategy *RolloutStrategy `json:"strategy"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Autostart == nil { + return fmt.Errorf("required field autostart missing") + } + if all.SelectionIntervalMs == nil { + return fmt.Errorf("required field selection_interval_ms missing") + } + if all.Strategy == nil { + return fmt.Errorf("required field strategy missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"autostart", "selection_interval_ms", "strategy"}) + } else { + return err + } + + hasInvalidField := false + o.Autostart = *all.Autostart + o.SelectionIntervalMs = *all.SelectionIntervalMs + if !all.Strategy.IsValid() { + hasInvalidField = true + } else { + o.Strategy = *all.Strategy + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rollout_options_request.go b/api/datadogV2/model_rollout_options_request.go new file mode 100644 index 00000000000..3e4125f80e0 --- /dev/null +++ b/api/datadogV2/model_rollout_options_request.go @@ -0,0 +1,192 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RolloutOptionsRequest Rollout options request payload. +type RolloutOptionsRequest struct { + // Whether the schedule should begin automatically. + Autostart datadog.NullableBool `json:"autostart,omitempty"` + // Interval in milliseconds for uniform interval strategies. + SelectionIntervalMs *int64 `json:"selection_interval_ms,omitempty"` + // The progression strategy used by a progressive rollout. + Strategy RolloutStrategy `json:"strategy"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewRolloutOptionsRequest instantiates a new RolloutOptionsRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRolloutOptionsRequest(strategy RolloutStrategy) *RolloutOptionsRequest { + this := RolloutOptionsRequest{} + this.Strategy = strategy + return &this +} + +// NewRolloutOptionsRequestWithDefaults instantiates a new RolloutOptionsRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewRolloutOptionsRequestWithDefaults() *RolloutOptionsRequest { + this := RolloutOptionsRequest{} + return &this +} + +// GetAutostart returns the Autostart field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *RolloutOptionsRequest) GetAutostart() bool { + if o == nil || o.Autostart.Get() == nil { + var ret bool + return ret + } + return *o.Autostart.Get() +} + +// GetAutostartOk returns a tuple with the Autostart field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *RolloutOptionsRequest) GetAutostartOk() (*bool, bool) { + if o == nil { + return nil, false + } + return o.Autostart.Get(), o.Autostart.IsSet() +} + +// HasAutostart returns a boolean if a field has been set. +func (o *RolloutOptionsRequest) HasAutostart() bool { + return o != nil && o.Autostart.IsSet() +} + +// SetAutostart gets a reference to the given datadog.NullableBool and assigns it to the Autostart field. +func (o *RolloutOptionsRequest) SetAutostart(v bool) { + o.Autostart.Set(&v) +} + +// SetAutostartNil sets the value for Autostart to be an explicit nil. +func (o *RolloutOptionsRequest) SetAutostartNil() { + o.Autostart.Set(nil) +} + +// UnsetAutostart ensures that no value is present for Autostart, not even an explicit nil. +func (o *RolloutOptionsRequest) UnsetAutostart() { + o.Autostart.Unset() +} + +// GetSelectionIntervalMs returns the SelectionIntervalMs field value if set, zero value otherwise. +func (o *RolloutOptionsRequest) GetSelectionIntervalMs() int64 { + if o == nil || o.SelectionIntervalMs == nil { + var ret int64 + return ret + } + return *o.SelectionIntervalMs +} + +// GetSelectionIntervalMsOk returns a tuple with the SelectionIntervalMs field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RolloutOptionsRequest) GetSelectionIntervalMsOk() (*int64, bool) { + if o == nil || o.SelectionIntervalMs == nil { + return nil, false + } + return o.SelectionIntervalMs, true +} + +// HasSelectionIntervalMs returns a boolean if a field has been set. +func (o *RolloutOptionsRequest) HasSelectionIntervalMs() bool { + return o != nil && o.SelectionIntervalMs != nil +} + +// SetSelectionIntervalMs gets a reference to the given int64 and assigns it to the SelectionIntervalMs field. +func (o *RolloutOptionsRequest) SetSelectionIntervalMs(v int64) { + o.SelectionIntervalMs = &v +} + +// GetStrategy returns the Strategy field value. +func (o *RolloutOptionsRequest) GetStrategy() RolloutStrategy { + if o == nil { + var ret RolloutStrategy + return ret + } + return o.Strategy +} + +// GetStrategyOk returns a tuple with the Strategy field value +// and a boolean to check if the value has been set. +func (o *RolloutOptionsRequest) GetStrategyOk() (*RolloutStrategy, bool) { + if o == nil { + return nil, false + } + return &o.Strategy, true +} + +// SetStrategy sets field value. +func (o *RolloutOptionsRequest) SetStrategy(v RolloutStrategy) { + o.Strategy = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RolloutOptionsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Autostart.IsSet() { + toSerialize["autostart"] = o.Autostart.Get() + } + if o.SelectionIntervalMs != nil { + toSerialize["selection_interval_ms"] = o.SelectionIntervalMs + } + toSerialize["strategy"] = o.Strategy + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RolloutOptionsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Autostart datadog.NullableBool `json:"autostart,omitempty"` + SelectionIntervalMs *int64 `json:"selection_interval_ms,omitempty"` + Strategy *RolloutStrategy `json:"strategy"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Strategy == nil { + return fmt.Errorf("required field strategy missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"autostart", "selection_interval_ms", "strategy"}) + } else { + return err + } + + hasInvalidField := false + o.Autostart = all.Autostart + o.SelectionIntervalMs = all.SelectionIntervalMs + if !all.Strategy.IsValid() { + hasInvalidField = true + } else { + o.Strategy = *all.Strategy + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rollout_strategy.go b/api/datadogV2/model_rollout_strategy.go new file mode 100644 index 00000000000..51293e05bf0 --- /dev/null +++ b/api/datadogV2/model_rollout_strategy.go @@ -0,0 +1,66 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RolloutStrategy The progression strategy used by a progressive rollout. +type RolloutStrategy string + +// List of RolloutStrategy. +const ( + ROLLOUTSTRATEGY_UNIFORM_INTERVALS RolloutStrategy = "UNIFORM_INTERVALS" + ROLLOUTSTRATEGY_NO_ROLLOUT RolloutStrategy = "NO_ROLLOUT" +) + +var allowedRolloutStrategyEnumValues = []RolloutStrategy{ + ROLLOUTSTRATEGY_UNIFORM_INTERVALS, + ROLLOUTSTRATEGY_NO_ROLLOUT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RolloutStrategy) GetAllowedValues() []RolloutStrategy { + return allowedRolloutStrategyEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RolloutStrategy) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RolloutStrategy(value) + return nil +} + +// NewRolloutStrategyFromValue returns a pointer to a valid RolloutStrategy +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRolloutStrategyFromValue(v string) (*RolloutStrategy, error) { + ev := RolloutStrategy(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RolloutStrategy: valid values are %v", v, allowedRolloutStrategyEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RolloutStrategy) IsValid() bool { + for _, existing := range allowedRolloutStrategyEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RolloutStrategy value. +func (v RolloutStrategy) Ptr() *RolloutStrategy { + return &v +} diff --git a/api/datadogV2/model_targeting_rule.go b/api/datadogV2/model_targeting_rule.go new file mode 100644 index 00000000000..608d336e8ed --- /dev/null +++ b/api/datadogV2/model_targeting_rule.go @@ -0,0 +1,208 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TargetingRule Targeting rule details. +type TargetingRule struct { + // Conditions evaluated by this targeting rule. + Conditions []Condition `json:"conditions"` + // The timestamp when the targeting rule was created. + CreatedAt time.Time `json:"created_at"` + // The unique identifier of the targeting rule. + Id uuid.UUID `json:"id"` + // The timestamp when the targeting rule was last updated. + UpdatedAt time.Time `json:"updated_at"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTargetingRule instantiates a new TargetingRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTargetingRule(conditions []Condition, createdAt time.Time, id uuid.UUID, updatedAt time.Time) *TargetingRule { + this := TargetingRule{} + this.Conditions = conditions + this.CreatedAt = createdAt + this.Id = id + this.UpdatedAt = updatedAt + return &this +} + +// NewTargetingRuleWithDefaults instantiates a new TargetingRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTargetingRuleWithDefaults() *TargetingRule { + this := TargetingRule{} + return &this +} + +// GetConditions returns the Conditions field value. +func (o *TargetingRule) GetConditions() []Condition { + if o == nil { + var ret []Condition + return ret + } + return o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value +// and a boolean to check if the value has been set. +func (o *TargetingRule) GetConditionsOk() (*[]Condition, bool) { + if o == nil { + return nil, false + } + return &o.Conditions, true +} + +// SetConditions sets field value. +func (o *TargetingRule) SetConditions(v []Condition) { + o.Conditions = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *TargetingRule) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *TargetingRule) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *TargetingRule) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetId returns the Id field value. +func (o *TargetingRule) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *TargetingRule) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *TargetingRule) SetId(v uuid.UUID) { + o.Id = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *TargetingRule) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *TargetingRule) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *TargetingRule) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TargetingRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["conditions"] = o.Conditions + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["id"] = o.Id + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TargetingRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Conditions *[]Condition `json:"conditions"` + CreatedAt *time.Time `json:"created_at"` + Id *uuid.UUID `json:"id"` + UpdatedAt *time.Time `json:"updated_at"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Conditions == nil { + return fmt.Errorf("required field conditions missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updated_at missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"conditions", "created_at", "id", "updated_at"}) + } else { + return err + } + o.Conditions = *all.Conditions + o.CreatedAt = *all.CreatedAt + o.Id = *all.Id + o.UpdatedAt = *all.UpdatedAt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_targeting_rule_request.go b/api/datadogV2/model_targeting_rule_request.go new file mode 100644 index 00000000000..f996ef40ee5 --- /dev/null +++ b/api/datadogV2/model_targeting_rule_request.go @@ -0,0 +1,101 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TargetingRuleRequest Targeting rule request payload. +type TargetingRuleRequest struct { + // Conditions that must match for this rule. + Conditions []ConditionRequest `json:"conditions"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTargetingRuleRequest instantiates a new TargetingRuleRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTargetingRuleRequest(conditions []ConditionRequest) *TargetingRuleRequest { + this := TargetingRuleRequest{} + this.Conditions = conditions + return &this +} + +// NewTargetingRuleRequestWithDefaults instantiates a new TargetingRuleRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTargetingRuleRequestWithDefaults() *TargetingRuleRequest { + this := TargetingRuleRequest{} + return &this +} + +// GetConditions returns the Conditions field value. +func (o *TargetingRuleRequest) GetConditions() []ConditionRequest { + if o == nil { + var ret []ConditionRequest + return ret + } + return o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value +// and a boolean to check if the value has been set. +func (o *TargetingRuleRequest) GetConditionsOk() (*[]ConditionRequest, bool) { + if o == nil { + return nil, false + } + return &o.Conditions, true +} + +// SetConditions sets field value. +func (o *TargetingRuleRequest) SetConditions(v []ConditionRequest) { + o.Conditions = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TargetingRuleRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["conditions"] = o.Conditions + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TargetingRuleRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Conditions *[]ConditionRequest `json:"conditions"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Conditions == nil { + return fmt.Errorf("required field conditions missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"conditions"}) + } else { + return err + } + o.Conditions = *all.Conditions + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_upsert_allocation_request.go b/api/datadogV2/model_upsert_allocation_request.go new file mode 100644 index 00000000000..a0d305a5ff8 --- /dev/null +++ b/api/datadogV2/model_upsert_allocation_request.go @@ -0,0 +1,401 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// UpsertAllocationRequest Request to create or update a targeting rule (allocation) for a feature flag environment. +type UpsertAllocationRequest struct { + // The experiment ID for experiment-linked allocations. + ExperimentId datadog.NullableString `json:"experiment_id,omitempty"` + // Progressive release request payload. + ExposureSchedule *ExposureScheduleRequest `json:"exposure_schedule,omitempty"` + // Guardrail metrics used to monitor and auto-pause or abort. + GuardrailMetrics []GuardrailMetricRequest `json:"guardrail_metrics,omitempty"` + // The unique identifier of the targeting rule allocation. + Id *uuid.UUID `json:"id,omitempty"` + // The unique key of the targeting rule allocation. + Key string `json:"key"` + // The display name of the targeting rule. + Name string `json:"name"` + // Targeting rules that determine audience eligibility. + TargetingRules []TargetingRuleRequest `json:"targeting_rules,omitempty"` + // The type of targeting rule (called allocation in the API model). + Type AllocationType `json:"type"` + // Variant distribution weights. + VariantWeights []VariantWeightRequest `json:"variant_weights,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewUpsertAllocationRequest instantiates a new UpsertAllocationRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewUpsertAllocationRequest(key string, name string, typeVar AllocationType) *UpsertAllocationRequest { + this := UpsertAllocationRequest{} + this.Key = key + this.Name = name + this.Type = typeVar + return &this +} + +// NewUpsertAllocationRequestWithDefaults instantiates a new UpsertAllocationRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewUpsertAllocationRequestWithDefaults() *UpsertAllocationRequest { + this := UpsertAllocationRequest{} + return &this +} + +// GetExperimentId returns the ExperimentId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *UpsertAllocationRequest) GetExperimentId() string { + if o == nil || o.ExperimentId.Get() == nil { + var ret string + return ret + } + return *o.ExperimentId.Get() +} + +// GetExperimentIdOk returns a tuple with the ExperimentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *UpsertAllocationRequest) GetExperimentIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.ExperimentId.Get(), o.ExperimentId.IsSet() +} + +// HasExperimentId returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasExperimentId() bool { + return o != nil && o.ExperimentId.IsSet() +} + +// SetExperimentId gets a reference to the given datadog.NullableString and assigns it to the ExperimentId field. +func (o *UpsertAllocationRequest) SetExperimentId(v string) { + o.ExperimentId.Set(&v) +} + +// SetExperimentIdNil sets the value for ExperimentId to be an explicit nil. +func (o *UpsertAllocationRequest) SetExperimentIdNil() { + o.ExperimentId.Set(nil) +} + +// UnsetExperimentId ensures that no value is present for ExperimentId, not even an explicit nil. +func (o *UpsertAllocationRequest) UnsetExperimentId() { + o.ExperimentId.Unset() +} + +// GetExposureSchedule returns the ExposureSchedule field value if set, zero value otherwise. +func (o *UpsertAllocationRequest) GetExposureSchedule() ExposureScheduleRequest { + if o == nil || o.ExposureSchedule == nil { + var ret ExposureScheduleRequest + return ret + } + return *o.ExposureSchedule +} + +// GetExposureScheduleOk returns a tuple with the ExposureSchedule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetExposureScheduleOk() (*ExposureScheduleRequest, bool) { + if o == nil || o.ExposureSchedule == nil { + return nil, false + } + return o.ExposureSchedule, true +} + +// HasExposureSchedule returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasExposureSchedule() bool { + return o != nil && o.ExposureSchedule != nil +} + +// SetExposureSchedule gets a reference to the given ExposureScheduleRequest and assigns it to the ExposureSchedule field. +func (o *UpsertAllocationRequest) SetExposureSchedule(v ExposureScheduleRequest) { + o.ExposureSchedule = &v +} + +// GetGuardrailMetrics returns the GuardrailMetrics field value if set, zero value otherwise. +func (o *UpsertAllocationRequest) GetGuardrailMetrics() []GuardrailMetricRequest { + if o == nil || o.GuardrailMetrics == nil { + var ret []GuardrailMetricRequest + return ret + } + return o.GuardrailMetrics +} + +// GetGuardrailMetricsOk returns a tuple with the GuardrailMetrics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetGuardrailMetricsOk() (*[]GuardrailMetricRequest, bool) { + if o == nil || o.GuardrailMetrics == nil { + return nil, false + } + return &o.GuardrailMetrics, true +} + +// HasGuardrailMetrics returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasGuardrailMetrics() bool { + return o != nil && o.GuardrailMetrics != nil +} + +// SetGuardrailMetrics gets a reference to the given []GuardrailMetricRequest and assigns it to the GuardrailMetrics field. +func (o *UpsertAllocationRequest) SetGuardrailMetrics(v []GuardrailMetricRequest) { + o.GuardrailMetrics = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *UpsertAllocationRequest) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *UpsertAllocationRequest) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetKey returns the Key field value. +func (o *UpsertAllocationRequest) GetKey() string { + if o == nil { + var ret string + return ret + } + return o.Key +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Key, true +} + +// SetKey sets field value. +func (o *UpsertAllocationRequest) SetKey(v string) { + o.Key = v +} + +// GetName returns the Name field value. +func (o *UpsertAllocationRequest) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *UpsertAllocationRequest) SetName(v string) { + o.Name = v +} + +// GetTargetingRules returns the TargetingRules field value if set, zero value otherwise. +func (o *UpsertAllocationRequest) GetTargetingRules() []TargetingRuleRequest { + if o == nil || o.TargetingRules == nil { + var ret []TargetingRuleRequest + return ret + } + return o.TargetingRules +} + +// GetTargetingRulesOk returns a tuple with the TargetingRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetTargetingRulesOk() (*[]TargetingRuleRequest, bool) { + if o == nil || o.TargetingRules == nil { + return nil, false + } + return &o.TargetingRules, true +} + +// HasTargetingRules returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasTargetingRules() bool { + return o != nil && o.TargetingRules != nil +} + +// SetTargetingRules gets a reference to the given []TargetingRuleRequest and assigns it to the TargetingRules field. +func (o *UpsertAllocationRequest) SetTargetingRules(v []TargetingRuleRequest) { + o.TargetingRules = v +} + +// GetType returns the Type field value. +func (o *UpsertAllocationRequest) GetType() AllocationType { + if o == nil { + var ret AllocationType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetTypeOk() (*AllocationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *UpsertAllocationRequest) SetType(v AllocationType) { + o.Type = v +} + +// GetVariantWeights returns the VariantWeights field value if set, zero value otherwise. +func (o *UpsertAllocationRequest) GetVariantWeights() []VariantWeightRequest { + if o == nil || o.VariantWeights == nil { + var ret []VariantWeightRequest + return ret + } + return o.VariantWeights +} + +// GetVariantWeightsOk returns a tuple with the VariantWeights field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertAllocationRequest) GetVariantWeightsOk() (*[]VariantWeightRequest, bool) { + if o == nil || o.VariantWeights == nil { + return nil, false + } + return &o.VariantWeights, true +} + +// HasVariantWeights returns a boolean if a field has been set. +func (o *UpsertAllocationRequest) HasVariantWeights() bool { + return o != nil && o.VariantWeights != nil +} + +// SetVariantWeights gets a reference to the given []VariantWeightRequest and assigns it to the VariantWeights field. +func (o *UpsertAllocationRequest) SetVariantWeights(v []VariantWeightRequest) { + o.VariantWeights = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpsertAllocationRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ExperimentId.IsSet() { + toSerialize["experiment_id"] = o.ExperimentId.Get() + } + if o.ExposureSchedule != nil { + toSerialize["exposure_schedule"] = o.ExposureSchedule + } + if o.GuardrailMetrics != nil { + toSerialize["guardrail_metrics"] = o.GuardrailMetrics + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["key"] = o.Key + toSerialize["name"] = o.Name + if o.TargetingRules != nil { + toSerialize["targeting_rules"] = o.TargetingRules + } + toSerialize["type"] = o.Type + if o.VariantWeights != nil { + toSerialize["variant_weights"] = o.VariantWeights + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *UpsertAllocationRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ExperimentId datadog.NullableString `json:"experiment_id,omitempty"` + ExposureSchedule *ExposureScheduleRequest `json:"exposure_schedule,omitempty"` + GuardrailMetrics []GuardrailMetricRequest `json:"guardrail_metrics,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Key *string `json:"key"` + Name *string `json:"name"` + TargetingRules []TargetingRuleRequest `json:"targeting_rules,omitempty"` + Type *AllocationType `json:"type"` + VariantWeights []VariantWeightRequest `json:"variant_weights,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Key == nil { + return fmt.Errorf("required field key missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"experiment_id", "exposure_schedule", "guardrail_metrics", "id", "key", "name", "targeting_rules", "type", "variant_weights"}) + } else { + return err + } + + hasInvalidField := false + o.ExperimentId = all.ExperimentId + if all.ExposureSchedule != nil && all.ExposureSchedule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ExposureSchedule = all.ExposureSchedule + o.GuardrailMetrics = all.GuardrailMetrics + o.Id = all.Id + o.Key = *all.Key + o.Name = *all.Name + o.TargetingRules = all.TargetingRules + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.VariantWeights = all.VariantWeights + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_variant_weight.go b/api/datadogV2/model_variant_weight.go new file mode 100644 index 00000000000..0b6faf32964 --- /dev/null +++ b/api/datadogV2/model_variant_weight.go @@ -0,0 +1,293 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VariantWeight Variant weight details. +type VariantWeight struct { + // The timestamp when the variant weight was created. + CreatedAt *time.Time `json:"created_at,omitempty"` + // Unique identifier of the variant weight assignment. + Id *uuid.UUID `json:"id,omitempty"` + // The timestamp when the variant weight was last updated. + UpdatedAt *time.Time `json:"updated_at,omitempty"` + // The percentage weight for the variant. + Value float64 `json:"value"` + // A variant of a feature flag. + Variant *Variant `json:"variant,omitempty"` + // The variant ID. + VariantId uuid.UUID `json:"variant_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVariantWeight instantiates a new VariantWeight object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVariantWeight(value float64, variantId uuid.UUID) *VariantWeight { + this := VariantWeight{} + this.Value = value + this.VariantId = variantId + return &this +} + +// NewVariantWeightWithDefaults instantiates a new VariantWeight object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVariantWeightWithDefaults() *VariantWeight { + this := VariantWeight{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *VariantWeight) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *VariantWeight) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *VariantWeight) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *VariantWeight) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *VariantWeight) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *VariantWeight) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *VariantWeight) GetUpdatedAt() time.Time { + if o == nil || o.UpdatedAt == nil { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || o.UpdatedAt == nil { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *VariantWeight) HasUpdatedAt() bool { + return o != nil && o.UpdatedAt != nil +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *VariantWeight) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +// GetValue returns the Value field value. +func (o *VariantWeight) GetValue() float64 { + if o == nil { + var ret float64 + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetValueOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *VariantWeight) SetValue(v float64) { + o.Value = v +} + +// GetVariant returns the Variant field value if set, zero value otherwise. +func (o *VariantWeight) GetVariant() Variant { + if o == nil || o.Variant == nil { + var ret Variant + return ret + } + return *o.Variant +} + +// GetVariantOk returns a tuple with the Variant field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetVariantOk() (*Variant, bool) { + if o == nil || o.Variant == nil { + return nil, false + } + return o.Variant, true +} + +// HasVariant returns a boolean if a field has been set. +func (o *VariantWeight) HasVariant() bool { + return o != nil && o.Variant != nil +} + +// SetVariant gets a reference to the given Variant and assigns it to the Variant field. +func (o *VariantWeight) SetVariant(v Variant) { + o.Variant = &v +} + +// GetVariantId returns the VariantId field value. +func (o *VariantWeight) GetVariantId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.VariantId +} + +// GetVariantIdOk returns a tuple with the VariantId field value +// and a boolean to check if the value has been set. +func (o *VariantWeight) GetVariantIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.VariantId, true +} + +// SetVariantId sets field value. +func (o *VariantWeight) SetVariantId(v uuid.UUID) { + o.VariantId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VariantWeight) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt != nil { + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.UpdatedAt != nil { + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updated_at"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + toSerialize["value"] = o.Value + if o.Variant != nil { + toSerialize["variant"] = o.Variant + } + toSerialize["variant_id"] = o.VariantId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VariantWeight) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Value *float64 `json:"value"` + Variant *Variant `json:"variant,omitempty"` + VariantId *uuid.UUID `json:"variant_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + if all.VariantId == nil { + return fmt.Errorf("required field variant_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "id", "updated_at", "value", "variant", "variant_id"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = all.CreatedAt + o.Id = all.Id + o.UpdatedAt = all.UpdatedAt + o.Value = *all.Value + if all.Variant != nil && all.Variant.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Variant = all.Variant + o.VariantId = *all.VariantId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_variant_weight_request.go b/api/datadogV2/model_variant_weight_request.go new file mode 100644 index 00000000000..38ae85d30ed --- /dev/null +++ b/api/datadogV2/model_variant_weight_request.go @@ -0,0 +1,173 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VariantWeightRequest Variant weight request payload. +type VariantWeightRequest struct { + // The percentage weight for this variant. + Value float64 `json:"value"` + // The variant ID to assign weight to. + VariantId *uuid.UUID `json:"variant_id,omitempty"` + // The variant key to assign weight to. + VariantKey *string `json:"variant_key,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVariantWeightRequest instantiates a new VariantWeightRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVariantWeightRequest(value float64) *VariantWeightRequest { + this := VariantWeightRequest{} + this.Value = value + return &this +} + +// NewVariantWeightRequestWithDefaults instantiates a new VariantWeightRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVariantWeightRequestWithDefaults() *VariantWeightRequest { + this := VariantWeightRequest{} + return &this +} + +// GetValue returns the Value field value. +func (o *VariantWeightRequest) GetValue() float64 { + if o == nil { + var ret float64 + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *VariantWeightRequest) GetValueOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *VariantWeightRequest) SetValue(v float64) { + o.Value = v +} + +// GetVariantId returns the VariantId field value if set, zero value otherwise. +func (o *VariantWeightRequest) GetVariantId() uuid.UUID { + if o == nil || o.VariantId == nil { + var ret uuid.UUID + return ret + } + return *o.VariantId +} + +// GetVariantIdOk returns a tuple with the VariantId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeightRequest) GetVariantIdOk() (*uuid.UUID, bool) { + if o == nil || o.VariantId == nil { + return nil, false + } + return o.VariantId, true +} + +// HasVariantId returns a boolean if a field has been set. +func (o *VariantWeightRequest) HasVariantId() bool { + return o != nil && o.VariantId != nil +} + +// SetVariantId gets a reference to the given uuid.UUID and assigns it to the VariantId field. +func (o *VariantWeightRequest) SetVariantId(v uuid.UUID) { + o.VariantId = &v +} + +// GetVariantKey returns the VariantKey field value if set, zero value otherwise. +func (o *VariantWeightRequest) GetVariantKey() string { + if o == nil || o.VariantKey == nil { + var ret string + return ret + } + return *o.VariantKey +} + +// GetVariantKeyOk returns a tuple with the VariantKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VariantWeightRequest) GetVariantKeyOk() (*string, bool) { + if o == nil || o.VariantKey == nil { + return nil, false + } + return o.VariantKey, true +} + +// HasVariantKey returns a boolean if a field has been set. +func (o *VariantWeightRequest) HasVariantKey() bool { + return o != nil && o.VariantKey != nil +} + +// SetVariantKey gets a reference to the given string and assigns it to the VariantKey field. +func (o *VariantWeightRequest) SetVariantKey(v string) { + o.VariantKey = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VariantWeightRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["value"] = o.Value + if o.VariantId != nil { + toSerialize["variant_id"] = o.VariantId + } + if o.VariantKey != nil { + toSerialize["variant_key"] = o.VariantKey + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VariantWeightRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Value *float64 `json:"value"` + VariantId *uuid.UUID `json:"variant_id,omitempty"` + VariantKey *string `json:"variant_key,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"value", "variant_id", "variant_key"}) + } else { + return err + } + o.Value = *all.Value + o.VariantId = all.VariantId + o.VariantKey = all.VariantKey + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment.go b/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment.go new file mode 100644 index 00000000000..41371820135 --- /dev/null +++ b/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment.go @@ -0,0 +1,90 @@ +// Create targeting rules for a flag env returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + body := datadogV2.CreateAllocationsRequest{ + Data: datadogV2.AllocationDataRequest{ + Attributes: datadogV2.UpsertAllocationRequest{ + ExperimentId: *datadog.NewNullableString(datadog.PtrString("550e8400-e29b-41d4-a716-446655440030")), + ExposureSchedule: &datadogV2.ExposureScheduleRequest{ + AbsoluteStartTime: *datadog.NewNullableTime(datadog.PtrTime(time.Date(2025, 6, 13, 12, 0, 0, 0, time.UTC))), + ControlVariantId: *datadog.NewNullableString(datadog.PtrString("550e8400-e29b-41d4-a716-446655440012")), + ControlVariantKey: *datadog.NewNullableString(datadog.PtrString("control")), + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")), + RolloutOptions: datadogV2.RolloutOptionsRequest{ + Autostart: *datadog.NewNullableBool(datadog.PtrBool(false)), + SelectionIntervalMs: datadog.PtrInt64(3600000), + Strategy: datadogV2.ROLLOUTSTRATEGY_UNIFORM_INTERVALS, + }, + RolloutSteps: []datadogV2.ExposureRolloutStepRequest{ + { + ExposureRatio: 0.5, + GroupedStepIndex: 1, + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440040")), + IntervalMs: *datadog.NewNullableInt64(datadog.PtrInt64(3600000)), + IsPauseRecord: false, + }, + }, + }, + GuardrailMetrics: []datadogV2.GuardrailMetricRequest{ + { + MetricId: "metric-error-rate", + TriggerAction: datadogV2.GUARDRAILTRIGGERACTION_PAUSE, + }, + }, + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440020")), + Key: "prod-rollout", + Name: "Production Rollout", + TargetingRules: []datadogV2.TargetingRuleRequest{ + { + Conditions: []datadogV2.ConditionRequest{ + { + Attribute: "user_tier", + Operator: datadogV2.CONDITIONOPERATOR_ONE_OF, + Value: []string{ + "premium", + "enterprise", + }, + }, + }, + }, + }, + Type: datadogV2.ALLOCATIONTYPE_FEATURE_GATE, + VariantWeights: []datadogV2.VariantWeightRequest{ + { + Value: 50, + VariantId: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440001")), + VariantKey: datadog.PtrString("control"), + }, + }, + }, + Type: datadogV2.ALLOCATIONDATATYPE_ALLOCATIONS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.CreateAllocationsForFeatureFlagInEnvironment(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440000"), uuid.MustParse("550e8400-e29b-41d4-a716-446655440001"), body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment_3662093014.go b/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment_3662093014.go new file mode 100644 index 00000000000..1b1c2046ab1 --- /dev/null +++ b/examples/v2/feature-flags/CreateAllocationsForFeatureFlagInEnvironment_3662093014.go @@ -0,0 +1,55 @@ +// Create allocation for a flag in an environment returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "feature_flag" in the system + FeatureFlagDataAttributesVariants0ID := uuid.MustParse(os.Getenv("FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID")) + FeatureFlagDataID := uuid.MustParse(os.Getenv("FEATURE_FLAG_DATA_ID")) + + // there is a valid "environment" in the system + EnvironmentDataID := uuid.MustParse(os.Getenv("ENVIRONMENT_DATA_ID")) + + body := datadogV2.CreateAllocationsRequest{ + Data: datadogV2.AllocationDataRequest{ + Type: datadogV2.ALLOCATIONDATATYPE_ALLOCATIONS, + Attributes: datadogV2.UpsertAllocationRequest{ + Name: "New targeting rule Example-Feature-Flag", + Key: "new-targeting-rule-example-feature-flag", + TargetingRules: []datadogV2.TargetingRuleRequest{}, + VariantWeights: []datadogV2.VariantWeightRequest{ + { + VariantId: datadog.PtrUUID(FeatureFlagDataAttributesVariants0ID), + Value: 100, + }, + }, + GuardrailMetrics: []datadogV2.GuardrailMetricRequest{}, + Type: datadogV2.ALLOCATIONTYPE_CANARY, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.CreateAllocationsForFeatureFlagInEnvironment(ctx, FeatureFlagDataID, EnvironmentDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.CreateAllocationsForFeatureFlagInEnvironment`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/PauseExposureSchedule.go b/examples/v2/feature-flags/PauseExposureSchedule.go new file mode 100644 index 00000000000..aa13da009d7 --- /dev/null +++ b/examples/v2/feature-flags/PauseExposureSchedule.go @@ -0,0 +1,30 @@ +// Pause a progressive rollout returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.PauseExposureSchedule(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.PauseExposureSchedule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.PauseExposureSchedule`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/ResumeExposureSchedule.go b/examples/v2/feature-flags/ResumeExposureSchedule.go new file mode 100644 index 00000000000..41704e5a0b2 --- /dev/null +++ b/examples/v2/feature-flags/ResumeExposureSchedule.go @@ -0,0 +1,30 @@ +// Resume a progressive rollout returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.ResumeExposureSchedule(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.ResumeExposureSchedule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.ResumeExposureSchedule`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/StartExposureSchedule.go b/examples/v2/feature-flags/StartExposureSchedule.go new file mode 100644 index 00000000000..df47aa810ac --- /dev/null +++ b/examples/v2/feature-flags/StartExposureSchedule.go @@ -0,0 +1,30 @@ +// Start a progressive rollout returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.StartExposureSchedule(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.StartExposureSchedule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.StartExposureSchedule`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/StopExposureSchedule.go b/examples/v2/feature-flags/StopExposureSchedule.go new file mode 100644 index 00000000000..0a0c2a7dd8f --- /dev/null +++ b/examples/v2/feature-flags/StopExposureSchedule.go @@ -0,0 +1,30 @@ +// Stop a progressive rollout returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.StopExposureSchedule(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.StopExposureSchedule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.StopExposureSchedule`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment.go b/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment.go new file mode 100644 index 00000000000..3a5573a8250 --- /dev/null +++ b/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment.go @@ -0,0 +1,92 @@ +// Update targeting rules for a flag returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + body := datadogV2.OverwriteAllocationsRequest{ + Data: []datadogV2.AllocationDataRequest{ + { + Attributes: datadogV2.UpsertAllocationRequest{ + ExperimentId: *datadog.NewNullableString(datadog.PtrString("550e8400-e29b-41d4-a716-446655440030")), + ExposureSchedule: &datadogV2.ExposureScheduleRequest{ + AbsoluteStartTime: *datadog.NewNullableTime(datadog.PtrTime(time.Date(2025, 6, 13, 12, 0, 0, 0, time.UTC))), + ControlVariantId: *datadog.NewNullableString(datadog.PtrString("550e8400-e29b-41d4-a716-446655440012")), + ControlVariantKey: *datadog.NewNullableString(datadog.PtrString("control")), + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440010")), + RolloutOptions: datadogV2.RolloutOptionsRequest{ + Autostart: *datadog.NewNullableBool(datadog.PtrBool(false)), + SelectionIntervalMs: datadog.PtrInt64(3600000), + Strategy: datadogV2.ROLLOUTSTRATEGY_UNIFORM_INTERVALS, + }, + RolloutSteps: []datadogV2.ExposureRolloutStepRequest{ + { + ExposureRatio: 0.5, + GroupedStepIndex: 1, + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440040")), + IntervalMs: *datadog.NewNullableInt64(datadog.PtrInt64(3600000)), + IsPauseRecord: false, + }, + }, + }, + GuardrailMetrics: []datadogV2.GuardrailMetricRequest{ + { + MetricId: "metric-error-rate", + TriggerAction: datadogV2.GUARDRAILTRIGGERACTION_PAUSE, + }, + }, + Id: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440020")), + Key: "prod-rollout", + Name: "Production Rollout", + TargetingRules: []datadogV2.TargetingRuleRequest{ + { + Conditions: []datadogV2.ConditionRequest{ + { + Attribute: "user_tier", + Operator: datadogV2.CONDITIONOPERATOR_ONE_OF, + Value: []string{ + "premium", + "enterprise", + }, + }, + }, + }, + }, + Type: datadogV2.ALLOCATIONTYPE_FEATURE_GATE, + VariantWeights: []datadogV2.VariantWeightRequest{ + { + Value: 50, + VariantId: datadog.PtrUUID(uuid.MustParse("550e8400-e29b-41d4-a716-446655440001")), + VariantKey: datadog.PtrString("control"), + }, + }, + }, + Type: datadogV2.ALLOCATIONDATATYPE_ALLOCATIONS, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.UpdateAllocationsForFeatureFlagInEnvironment(ctx, uuid.MustParse("550e8400-e29b-41d4-a716-446655440000"), uuid.MustParse("550e8400-e29b-41d4-a716-446655440001"), body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment`:\n%s\n", responseContent) +} diff --git a/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment_3789036209.go b/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment_3789036209.go new file mode 100644 index 00000000000..d5078c266f6 --- /dev/null +++ b/examples/v2/feature-flags/UpdateAllocationsForFeatureFlagInEnvironment_3789036209.go @@ -0,0 +1,84 @@ +// Update targeting rules for a flag in an environment returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "feature_flag" in the system + FeatureFlagDataAttributesVariants0ID := uuid.MustParse(os.Getenv("FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID")) + FeatureFlagDataID := uuid.MustParse(os.Getenv("FEATURE_FLAG_DATA_ID")) + + // there is a valid "environment" in the system + EnvironmentDataID := uuid.MustParse(os.Getenv("ENVIRONMENT_DATA_ID")) + + body := datadogV2.OverwriteAllocationsRequest{ + Data: []datadogV2.AllocationDataRequest{ + { + Type: datadogV2.ALLOCATIONDATATYPE_ALLOCATIONS, + Attributes: datadogV2.UpsertAllocationRequest{ + Key: "overwrite-allocation-example-feature-flag", + Name: "New targeting rule Example-Feature-Flag", + TargetingRules: []datadogV2.TargetingRuleRequest{}, + VariantWeights: []datadogV2.VariantWeightRequest{ + { + VariantId: datadog.PtrUUID(FeatureFlagDataAttributesVariants0ID), + Value: 100, + }, + }, + ExposureSchedule: &datadogV2.ExposureScheduleRequest{ + RolloutOptions: datadogV2.RolloutOptionsRequest{ + Strategy: datadogV2.ROLLOUTSTRATEGY_UNIFORM_INTERVALS, + Autostart: *datadog.NewNullableBool(datadog.PtrBool(false)), + SelectionIntervalMs: datadog.PtrInt64(86400000), + }, + RolloutSteps: []datadogV2.ExposureRolloutStepRequest{ + { + ExposureRatio: 0.05, + IntervalMs: *datadog.NewNullableInt64(nil), + IsPauseRecord: false, + GroupedStepIndex: 0, + }, + { + ExposureRatio: 0.25, + IntervalMs: *datadog.NewNullableInt64(nil), + IsPauseRecord: false, + GroupedStepIndex: 1, + }, + { + ExposureRatio: 1, + IntervalMs: *datadog.NewNullableInt64(nil), + IsPauseRecord: false, + GroupedStepIndex: 2, + }, + }, + }, + GuardrailMetrics: []datadogV2.GuardrailMetricRequest{}, + Type: datadogV2.ALLOCATIONTYPE_CANARY, + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFeatureFlagsApi(apiClient) + resp, r, err := api.UpdateAllocationsForFeatureFlagInEnvironment(ctx, FeatureFlagDataID, EnvironmentDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FeatureFlagsApi.UpdateAllocationsForFeatureFlagInEnvironment`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.freeze new file mode 100644 index 00000000000..7f87fe7c2da --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-04-01T20:36:45.896Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.yaml new file mode 100644 index 00000000000..1b7a5554b7b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Create_allocation_for_a_flag_in_an_environment_returns_Created_response.yaml @@ -0,0 +1,120 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Test feature flag for BDD scenarios","key":"test-feature-flag-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","name":"Test Feature Flag Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","value_type":"BOOLEAN","variants":[{"key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-1","name":"Variant Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 A","value":"true"},{"key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-2","name":"Variant Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 B","value":"false"}]},"type":"feature-flags"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags + response: + body: '{"data":{"id":"449ff1d1-7a4f-416f-a6ce-be1abd3031c1","type":"feature-flags","attributes":{"archived_at":null,"created_at":"2026-04-01T20:36:46.153578Z","created_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","description":"Test + feature flag for BDD scenarios","distribution_channel":"ALL","feature_flag_environments":[{"environment_id":"592600c2-8327-424d-960f-608c327ee96d","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-9bfe74798563","override_allocation_key":"allocation-override-9bfe74798563","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"809cd83d-51ac-4f60-9ce5-cfad4d662114","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-04b9843f6754","override_allocation_key":"allocation-override-04b9843f6754","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"21c84268-9fc7-4b6d-82ea-bb2090469aba","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-ac33b80880b1","override_allocation_key":"allocation-override-ac33b80880b1","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"0b94dbaa-9efb-419d-8bd7-ef56f3828986","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773321543","environment_queries":["staging","test"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-1018a5595c76","override_allocation_key":"allocation-override-1018a5595c76","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"afdaa512-6307-4965-bf92-62cc6bea5d00","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773322166","environment_queries":["test-Test-Typescript-Create_an_environment_returns_Created_response-1773322166","env-Test-Typescript-Create_an_environment_returns_Created_response-1773322166"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-9cf98d18b2bc","override_allocation_key":"allocation-override-9cf98d18b2bc","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null}],"key":"test-feature-flag-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","last_updated_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"Test + Feature Flag Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","require_approval":false,"tags":[],"updated_at":"2026-04-01T20:36:46.153578Z","value_type":"BOOLEAN","variants":[{"id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-1","name":"Variant + Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 + A","value":"true","created_at":"2026-04-01T20:36:46.172226Z","updated_at":"2026-04-01T20:36:46.172226Z"},{"id":"b8079ed4-249a-42fb-b9ec-ff95900c37af","key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-2","name":"Variant + Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 + B","value":"false","created_at":"2026-04-01T20:36:46.181731Z","updated_at":"2026-04-01T20:36:46.181731Z"}]}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test Environment Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","queries":["test-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","env-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805"]},"type":"environments"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags/environments + response: + body: '{"data":{"id":"927d4fe0-11f9-4a08-8859-ae044a4e04f0","type":"environments","attributes":{"is_production":false,"name":"Test + Environment Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","queries":["test-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","env-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805"],"require_feature_flag_approval":false}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"guardrail_metrics":[],"key":"new-targeting-rule-test-create_allocation_for_a_flag_in_an_environment_returns_created_response-1775075805","name":"New targeting rule Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","targeting_rules":[],"type":"CANARY","variant_weights":[{"value":100,"variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051"}]},"type":"allocations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 2 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags/449ff1d1-7a4f-416f-a6ce-be1abd3031c1/environments/927d4fe0-11f9-4a08-8859-ae044a4e04f0/allocations + response: + body: '{"data":{"id":"adb0e4b9-2c9f-4ce0-bc77-68c11d5e1ba2","type":"allocations","attributes":{"created_at":"2026-04-01T20:36:47.111398323Z","environment_ids":["927d4fe0-11f9-4a08-8859-ae044a4e04f0"],"experiment_id":null,"guardrail_metrics":[],"key":"new-targeting-rule-test-create_allocation_for_a_flag_in_an_environment_returns_created_response-1775075805","name":"New + targeting rule Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","order_position":0,"targeting_rules":[],"type":"CANARY","updated_at":"2026-04-01T20:36:47.111398323Z","variant_weights":[{"id":"9c5fccaf-ca32-49dd-8a48-5a47a6204cc4","created_at":"2026-04-01T20:36:47.119918Z","updated_at":"2026-04-01T20:36:47.119918Z","value":100,"variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","variant":{"id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-1","name":"Variant + Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 + A","value":"true","created_at":"2026-04-01T20:36:46.172226Z","updated_at":"2026-04-01T20:36:46.172226Z"}}]}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/feature-flags/environments/927d4fe0-11f9-4a08-8859-ae044a4e04f0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 4 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags/449ff1d1-7a4f-416f-a6ce-be1abd3031c1/archive + response: + body: '{"data":{"id":"449ff1d1-7a4f-416f-a6ce-be1abd3031c1","type":"feature-flags","attributes":{"archived_at":"2026-04-01T20:36:47.922174Z","created_at":"2026-04-01T20:36:46.153578Z","created_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","description":"Test + feature flag for BDD scenarios","distribution_channel":"ALL","feature_flag_environments":[{"environment_id":"592600c2-8327-424d-960f-608c327ee96d","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-9bfe74798563","override_allocation_key":"allocation-override-9bfe74798563","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"809cd83d-51ac-4f60-9ce5-cfad4d662114","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-04b9843f6754","override_allocation_key":"allocation-override-04b9843f6754","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"21c84268-9fc7-4b6d-82ea-bb2090469aba","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-ac33b80880b1","override_allocation_key":"allocation-override-ac33b80880b1","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"0b94dbaa-9efb-419d-8bd7-ef56f3828986","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773321543","environment_queries":["staging","test"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-1018a5595c76","override_allocation_key":"allocation-override-1018a5595c76","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"afdaa512-6307-4965-bf92-62cc6bea5d00","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773322166","environment_queries":["test-Test-Typescript-Create_an_environment_returns_Created_response-1773322166","env-Test-Typescript-Create_an_environment_returns_Created_response-1773322166"],"status":"DISABLED","default_variant_id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","override_variant_id":null,"default_allocation_key":"allocation-default-9cf98d18b2bc","override_allocation_key":"allocation-override-9cf98d18b2bc","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null}],"key":"test-feature-flag-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","last_updated_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"Test + Feature Flag Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805","require_approval":false,"tags":[],"updated_at":"2026-04-01T20:36:47.922174Z","value_type":"BOOLEAN","variants":[{"id":"4fda6911-d77b-4ca7-ba8d-daa41622e051","key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-1","name":"Variant + Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 + A","value":"true","created_at":"2026-04-01T20:36:46.172226Z","updated_at":"2026-04-01T20:36:46.172226Z"},{"id":"b8079ed4-249a-42fb-b9ec-ff95900c37af","key":"variant-Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805-2","name":"Variant + Test-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1775075805 + B","value":"false","created_at":"2026-04-01T20:36:46.181731Z","updated_at":"2026-04-01T20:36:46.181731Z"}]}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.freeze new file mode 100644 index 00000000000..c59070e48be --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-01T20:36:50.944Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.yaml new file mode 100644 index 00000000000..6a7ae2e434a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Feature_Flags/Scenario_Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response.yaml @@ -0,0 +1,120 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Test feature flag for BDD scenarios","key":"test-feature-flag-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","name":"Test Feature Flag Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","value_type":"BOOLEAN","variants":[{"key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-1","name":"Variant Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 A","value":"true"},{"key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-2","name":"Variant Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 B","value":"false"}]},"type":"feature-flags"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags + response: + body: '{"data":{"id":"ede225ed-3a62-4cb5-b678-73851d56c700","type":"feature-flags","attributes":{"archived_at":null,"created_at":"2026-04-01T20:36:51.103987Z","created_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","description":"Test + feature flag for BDD scenarios","distribution_channel":"ALL","feature_flag_environments":[{"environment_id":"592600c2-8327-424d-960f-608c327ee96d","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-2950ef4bf91c","override_allocation_key":"allocation-override-2950ef4bf91c","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"809cd83d-51ac-4f60-9ce5-cfad4d662114","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-f27ec0d632e1","override_allocation_key":"allocation-override-f27ec0d632e1","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"21c84268-9fc7-4b6d-82ea-bb2090469aba","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-7c7249a02089","override_allocation_key":"allocation-override-7c7249a02089","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"0b94dbaa-9efb-419d-8bd7-ef56f3828986","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773321543","environment_queries":["staging","test"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-c915dfafd596","override_allocation_key":"allocation-override-c915dfafd596","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"afdaa512-6307-4965-bf92-62cc6bea5d00","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773322166","environment_queries":["test-Test-Typescript-Create_an_environment_returns_Created_response-1773322166","env-Test-Typescript-Create_an_environment_returns_Created_response-1773322166"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-af80336ddd7c","override_allocation_key":"allocation-override-af80336ddd7c","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null}],"key":"test-feature-flag-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","last_updated_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"Test + Feature Flag Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","require_approval":false,"tags":[],"updated_at":"2026-04-01T20:36:51.103987Z","value_type":"BOOLEAN","variants":[{"id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-1","name":"Variant + Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 + A","value":"true","created_at":"2026-04-01T20:36:51.109817Z","updated_at":"2026-04-01T20:36:51.109817Z"},{"id":"209acfa7-b3d6-4373-bcb7-162bbe4460c9","key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-2","name":"Variant + Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 + B","value":"false","created_at":"2026-04-01T20:36:51.115427Z","updated_at":"2026-04-01T20:36:51.115427Z"}]}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test Environment Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","queries":["test-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","env-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810"]},"type":"environments"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags/environments + response: + body: '{"data":{"id":"73900c64-e4c9-46a3-ac5b-d5fa80be2b49","type":"environments","attributes":{"is_production":false,"name":"Test + Environment Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","queries":["test-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","env-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810"],"require_feature_flag_approval":false}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":[{"attributes":{"exposure_schedule":{"rollout_options":{"autostart":false,"selection_interval_ms":86400000,"strategy":"UNIFORM_INTERVALS"},"rollout_steps":[{"exposure_ratio":0.05,"grouped_step_index":0,"interval_ms":null,"is_pause_record":false},{"exposure_ratio":0.25,"grouped_step_index":1,"interval_ms":null,"is_pause_record":false},{"exposure_ratio":1,"grouped_step_index":2,"interval_ms":null,"is_pause_record":false}]},"guardrail_metrics":[],"key":"overwrite-allocation-test-update_targeting_rules_for_a_flag_in_an_environment_returns_ok_response-1775075810","name":"New targeting rule Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","targeting_rules":[],"type":"CANARY","variant_weights":[{"value":100,"variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f"}]},"type":"allocations"}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 2 + method: PUT + url: https://api.datadoghq.com/api/v2/feature-flags/ede225ed-3a62-4cb5-b678-73851d56c700/environments/73900c64-e4c9-46a3-ac5b-d5fa80be2b49/allocations + response: + body: '{"data":[{"id":"576deb88-9917-4848-87b1-f9ea276f6bf3","type":"allocations","attributes":{"created_at":"2026-04-01T20:36:51.950824558Z","environment_ids":["73900c64-e4c9-46a3-ac5b-d5fa80be2b49"],"experiment_id":null,"exposure_schedule":{"id":"871b9d47-219d-469d-89de-e9322ad135fd","allocation_id":"576deb88-9917-4848-87b1-f9ea276f6bf3","control_variant_id":null,"absolute_start_time":null,"rollout_options":{"strategy":"UNIFORM_INTERVALS","autostart":false,"selection_interval_ms":86400000},"rollout_steps":[{"id":"92089f1f-3065-447c-a674-a88d38641967","allocation_exposure_schedule_id":"871b9d47-219d-469d-89de-e9322ad135fd","order_position":0,"exposure_ratio":0.05,"interval_ms":86400000,"is_pause_record":false,"grouped_step_index":0,"created_at":"2026-04-01T20:36:51.958618Z","updated_at":"2026-04-01T20:36:51.958618Z"},{"id":"f471ec77-92d2-4d87-9983-e733d53bece5","allocation_exposure_schedule_id":"871b9d47-219d-469d-89de-e9322ad135fd","order_position":1,"exposure_ratio":0.25,"interval_ms":86400000,"is_pause_record":false,"grouped_step_index":1,"created_at":"2026-04-01T20:36:51.958618Z","updated_at":"2026-04-01T20:36:51.958618Z"},{"id":"c32bf3c7-1a30-40aa-811e-a5bcde7c10aa","allocation_exposure_schedule_id":"871b9d47-219d-469d-89de-e9322ad135fd","order_position":2,"exposure_ratio":1,"interval_ms":null,"is_pause_record":false,"grouped_step_index":2,"created_at":"2026-04-01T20:36:51.958618Z","updated_at":"2026-04-01T20:36:51.958618Z"}],"guardrail_triggers":[],"guardrail_triggered_action":null,"created_at":"2026-04-01T20:36:51.955888Z","updated_at":"2026-04-01T20:36:51.955888Z"},"guardrail_metrics":[],"key":"overwrite-allocation-test-update_targeting_rules_for_a_flag_in_an_environment_returns_ok_response-1775075810","name":"New + targeting rule Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","order_position":0,"targeting_rules":[],"type":"CANARY","updated_at":"2026-04-01T20:36:51.950824558Z","variant_weights":[{"id":"1833845a-a5aa-45a5-a400-57b522edc42f","created_at":"2026-04-01T20:36:51.963476Z","updated_at":"2026-04-01T20:36:51.963476Z","value":100,"variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","variant":{"id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-1","name":"Variant + Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 + A","value":"true","created_at":"2026-04-01T20:36:51.109817Z","updated_at":"2026-04-01T20:36:51.109817Z"}}]}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/feature-flags/environments/73900c64-e4c9-46a3-ac5b-d5fa80be2b49 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 4 + method: POST + url: https://api.datadoghq.com/api/v2/feature-flags/ede225ed-3a62-4cb5-b678-73851d56c700/archive + response: + body: '{"data":{"id":"ede225ed-3a62-4cb5-b678-73851d56c700","type":"feature-flags","attributes":{"archived_at":"2026-04-01T20:36:52.682946Z","created_at":"2026-04-01T20:36:51.103987Z","created_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","description":"Test + feature flag for BDD scenarios","distribution_channel":"ALL","feature_flag_environments":[{"environment_id":"592600c2-8327-424d-960f-608c327ee96d","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774470658"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-2950ef4bf91c","override_allocation_key":"allocation-override-2950ef4bf91c","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"809cd83d-51ac-4f60-9ce5-cfad4d662114","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774471346"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-f27ec0d632e1","override_allocation_key":"allocation-override-f27ec0d632e1","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"21c84268-9fc7-4b6d-82ea-bb2090469aba","environment_name":"Test + Environment Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","environment_queries":["test-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385","env-Test-Typescript-Create_allocation_for_a_flag_in_an_environment_returns_Created_response-1774472385"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-7c7249a02089","override_allocation_key":"allocation-override-7c7249a02089","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"0b94dbaa-9efb-419d-8bd7-ef56f3828986","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773321543","environment_queries":["staging","test"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-c915dfafd596","override_allocation_key":"allocation-override-c915dfafd596","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null},{"environment_id":"afdaa512-6307-4965-bf92-62cc6bea5d00","environment_name":"Test + Environment Test-Typescript-Create_an_environment_returns_Created_response-1773322166","environment_queries":["test-Test-Typescript-Create_an_environment_returns_Created_response-1773322166","env-Test-Typescript-Create_an_environment_returns_Created_response-1773322166"],"status":"DISABLED","default_variant_id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","override_variant_id":null,"default_allocation_key":"allocation-default-af80336ddd7c","override_allocation_key":"allocation-override-af80336ddd7c","rules":[],"rollout_percentage":0,"allocations":null,"is_production":false,"require_feature_flag_approval":false,"pending_suggestion_id":null}],"key":"test-feature-flag-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","last_updated_by":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"Test + Feature Flag Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810","require_approval":false,"tags":[],"updated_at":"2026-04-01T20:36:52.682946Z","value_type":"BOOLEAN","variants":[{"id":"73ffe05f-ba09-46c0-ba5e-9d14b1da564f","key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-1","name":"Variant + Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 + A","value":"true","created_at":"2026-04-01T20:36:51.109817Z","updated_at":"2026-04-01T20:36:51.109817Z"},{"id":"209acfa7-b3d6-4373-bcb7-162bbe4460c9","key":"variant-Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810-2","name":"Variant + Test-Update_targeting_rules_for_a_flag_in_an_environment_returns_OK_response-1775075810 + B","value":"false","created_at":"2026-04-01T20:36:51.115427Z","updated_at":"2026-04-01T20:36:51.115427Z"}]}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/feature_flags.feature b/tests/scenarios/features/v2/feature_flags.feature index fcf9045b9d9..fd2ff16520c 100644 --- a/tests/scenarios/features/v2/feature_flags.feature +++ b/tests/scenarios/features/v2/feature_flags.feature @@ -53,6 +53,17 @@ 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" + @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 + And there is a valid "environment" in the system + And new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "feature_flag.data.id" + And request contains "environment_id" parameter from "environment.data.id" + And body with value {"data":{"type":"allocations","attributes":{"name":"New targeting rule {{ unique }}","key":"new-targeting-rule-{{ unique_lower }}","targeting_rules":[],"variant_weights":[{"variant_id":"{{ feature_flag.data.attributes.variants[0].id }}","value":100}],"guardrail_metrics":[],"type":"CANARY"}}} + When the request is sent + Then the response status is 201 Created + @skip @team:DataDog/feature-flags Scenario: Create an environment returns "Bad Request" response Given new "CreateFeatureFlagsEnvironment" request @@ -74,6 +85,51 @@ Feature: Feature Flags When the request is sent Then the response status is 201 Created + @generated @skip @team:DataDog/feature-flags + Scenario: Create targeting rules for a flag env returns "Accepted - Approval required for this change" response + Given new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}} + When the request is sent + Then the response status is 202 Accepted - Approval required for this change + + @generated @skip @team:DataDog/feature-flags + Scenario: Create targeting rules for a flag env returns "Bad Request" response + Given new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Create targeting rules for a flag env returns "Conflict" response + Given new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Create targeting rules for a flag env returns "Created" response + Given new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/feature-flags + Scenario: Create targeting rules for a flag env returns "Not Found" response + Given new "CreateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}} + 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 @@ -190,6 +246,118 @@ Feature: Feature Flags When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/feature-flags + Scenario: Pause a progressive rollout returns "Bad Request" response + Given new "PauseExposureSchedule" request + And request contains "exposure_schedule_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: Pause a progressive rollout returns "Conflict" response + Given new "PauseExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Pause a progressive rollout returns "Not Found" response + Given new "PauseExposureSchedule" request + And request contains "exposure_schedule_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: Pause a progressive rollout returns "OK" response + Given new "PauseExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + 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 + And request contains "exposure_schedule_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: Resume a progressive rollout returns "Conflict" response + Given new "ResumeExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Resume a progressive rollout returns "Not Found" response + Given new "ResumeExposureSchedule" request + And request contains "exposure_schedule_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: Resume a progressive rollout returns "OK" response + Given new "ResumeExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/feature-flags + Scenario: Start a progressive rollout returns "Bad Request" response + Given new "StartExposureSchedule" request + And request contains "exposure_schedule_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: Start a progressive rollout returns "Conflict" response + Given new "StartExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Start a progressive rollout returns "Not Found" response + Given new "StartExposureSchedule" request + And request contains "exposure_schedule_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: Start a progressive rollout returns "OK" response + Given new "StartExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/feature-flags + Scenario: Stop a progressive rollout returns "Bad Request" response + Given new "StopExposureSchedule" request + And request contains "exposure_schedule_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: Stop a progressive rollout returns "Conflict" response + Given new "StopExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Stop a progressive rollout returns "Not Found" response + Given new "StopExposureSchedule" request + And request contains "exposure_schedule_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: Stop a progressive rollout returns "OK" response + Given new "StopExposureSchedule" request + And request contains "exposure_schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/feature-flags Scenario: Unarchive a feature flag returns "Bad Request" response Given new "UnarchiveFeatureFlag" request @@ -263,3 +431,59 @@ Feature: Feature Flags And body with value {"data": {"type": "environments", "attributes": {"name": "Updated Test Environment {{ unique }}", "queries": ["updated-{{ unique }}", "live-{{ unique }}"]}}} When the request is sent Then the response status is 200 OK + + @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag in an environment returns "OK" response + Given there is a valid "feature_flag" in the system + And there is a valid "environment" in the system + And new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "feature_flag.data.id" + And request contains "environment_id" parameter from "environment.data.id" + And body with value {"data":[{"type":"allocations","attributes":{"key":"overwrite-allocation-{{ unique_lower }}","name":"New targeting rule {{ unique }}","targeting_rules":[],"variant_weights":[{"variant_id":"{{ feature_flag.data.attributes.variants[0].id }}","value":100}],"exposure_schedule":{"rollout_options":{"strategy":"UNIFORM_INTERVALS","autostart":false,"selection_interval_ms":86400000},"rollout_steps":[{"exposure_ratio":0.05,"interval_ms":null,"is_pause_record":false,"grouped_step_index":0},{"exposure_ratio":0.25,"interval_ms":null,"is_pause_record":false,"grouped_step_index":1},{"exposure_ratio":1,"interval_ms":null,"is_pause_record":false,"grouped_step_index":2}]},"guardrail_metrics":[],"type":"CANARY"}}]} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag returns "Accepted - Approval required for this change" response + Given new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}]} + When the request is sent + Then the response status is 202 Accepted - Approval required for this change + + @generated @skip @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag returns "Bad Request" response + Given new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag returns "Conflict" response + Given new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}]} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag returns "Not Found" response + Given new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Update targeting rules for a flag returns "OK" response + Given new "UpdateAllocationsForFeatureFlagInEnvironment" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "environment_id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"experiment_id": "550e8400-e29b-41d4-a716-446655440030", "exposure_schedule": {"absolute_start_time": "2025-06-13T12:00:00Z", "control_variant_id": "550e8400-e29b-41d4-a716-446655440012", "control_variant_key": "control", "id": "550e8400-e29b-41d4-a716-446655440010", "rollout_options": {"autostart": false, "selection_interval_ms": 3600000, "strategy": "UNIFORM_INTERVALS"}, "rollout_steps": [{"exposure_ratio": 0.5, "grouped_step_index": 1, "id": "550e8400-e29b-41d4-a716-446655440040", "interval_ms": 3600000, "is_pause_record": false}]}, "guardrail_metrics": [{"metric_id": "metric-error-rate", "trigger_action": "PAUSE"}], "id": "550e8400-e29b-41d4-a716-446655440020", "key": "prod-rollout", "name": "Production Rollout", "targeting_rules": [{"conditions": [{"attribute": "user_tier", "operator": "ONE_OF", "value": ["premium", "enterprise"]}]}], "type": "FEATURE_GATE", "variant_weights": [{"value": 50, "variant_id": "550e8400-e29b-41d4-a716-446655440001", "variant_key": "control"}]}, "type": "allocations"}]} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 8413be265af..12e386bd8f7 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -465,6 +465,27 @@ "tag": "Feature Flags", "operationId": "CreateFeatureFlagsEnvironment" }, + { + "parameters": [ + { + "name": "feature_flag_id", + "source": "feature_flag.data.id" + }, + { + "name": "environment_id", + "source": "environment.data.id" + }, + { + "name": "body", + "value": "{\"data\":[{\"type\":\"allocations\",\"attributes\":{\"name\":\"Exposure Schedule Allocation {{ unique }}\",\"key\":\"exposure-schedule-allocation-{{ unique_lower }}\",\"type\":\"CANARY\",\"targeting_rules\":[],\"variant_weights\":[{\"variant_id\":\"{{ feature_flag.data.attributes.variants[0].id }}\",\"value\":100}],\"exposure_schedule\":{\"rollout_options\":{\"strategy\":\"UNIFORM_INTERVALS\",\"autostart\":false,\"selection_interval_ms\":86400000},\"rollout_steps\":[{\"exposure_ratio\":0.5,\"interval_ms\":null,\"is_pause_record\":false,\"grouped_step_index\":0},{\"exposure_ratio\":1,\"interval_ms\":null,\"is_pause_record\":false,\"grouped_step_index\":1}]},\"guardrail_metrics\":[]}}]}" + } + ], + "source": "data[0].attributes.exposure_schedule", + "step": "there is a valid \"exposure_schedule\" in the system", + "key": "exposure_schedule", + "tag": "Feature Flags", + "operationId": "UpdateAllocationsForFeatureFlagInEnvironment" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 8b9940b568d..1f11ffb7e77 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1841,6 +1841,30 @@ "type": "idempotent" } }, + "PauseExposureSchedule": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, + "ResumeExposureSchedule": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, + "StartExposureSchedule": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, + "StopExposureSchedule": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, "GetFeatureFlag": { "tag": "Feature Flags", "undo": { @@ -1866,6 +1890,18 @@ "type": "unsafe" } }, + "CreateAllocationsForFeatureFlagInEnvironment": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, + "UpdateAllocationsForFeatureFlagInEnvironment": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, "DisableFeatureFlagEnvironment": { "tag": "Feature Flags", "undo": {