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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32282,7 +32282,7 @@ components:
options:
$ref: "#/components/schemas/DeploymentRulesOptions"
type:
description: The type of the deployment rule (faulty_deployment_detection or monitor).
description: The type of the deployment rule (`faulty_deployment_detection`, `monitor`, or `bits_deployment_analysis`).
example: "faulty_deployment_detection"
type: string
required:
Expand Down Expand Up @@ -43367,10 +43367,10 @@ components:
x-enum-varnames: [DEPLOYMENT_GATE_RULE_EVALUATION]
DeploymentGateRuleEvaluationType:
description: Type of deployment gate rule.
enum: [monitor, faulty_deployment_detection]
enum: [monitor, faulty_deployment_detection, bits_deployment_analysis]
example: faulty_deployment_detection
type: string
x-enum-varnames: [MONITOR, FAULTY_DEPLOYMENT_DETECTION]
x-enum-varnames: [MONITOR, FAULTY_DEPLOYMENT_DETECTION, BITS_DEPLOYMENT_ANALYSIS]
DeploymentGateRuleEvaluationsResponse:
description: Paginated deployment gate rule evaluations.
properties:
Expand Down Expand Up @@ -43438,6 +43438,43 @@ components:
data:
$ref: "#/components/schemas/ListDeploymentRuleResponseData"
type: object
DeploymentGatesBitsDeploymentAnalysisRule:
description: A Bits Deployment Analysis rule to evaluate as part of a deployment gate evaluation.
properties:
dry_run:
description: Rule-level dry run. When enabled, Datadog evaluates the rule normally, but the rule always returns `pass`. The real result appears in the Datadog UI.
example: false
type: boolean
name:
description: Human-readable name for this rule.
example: "bits deployment analysis"
type: string
options:
$ref: "#/components/schemas/DeploymentGatesBitsDeploymentAnalysisRuleOptions"
type:
$ref: "#/components/schemas/DeploymentGatesBitsDeploymentAnalysisRuleType"
required:
- type
- name
type: object
DeploymentGatesBitsDeploymentAnalysisRuleOptions:
description: Options for a `bits_deployment_analysis` rule.
properties:
duration:
description: Evaluation window in seconds. Maximum 7200 (2 hours).
example: 900
format: int64
maximum: 7200
type: integer
type: object
DeploymentGatesBitsDeploymentAnalysisRuleType:
description: The type identifier for a Bits Deployment Analysis rule.
enum:
- bits_deployment_analysis
example: bits_deployment_analysis
type: string
x-enum-varnames:
- BITS_DEPLOYMENT_ANALYSIS
DeploymentGatesEvaluationConfiguration:
description: |-
Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated
Expand Down Expand Up @@ -43647,6 +43684,7 @@ components:
oneOf:
- $ref: "#/components/schemas/DeploymentGatesMonitorRule"
- $ref: "#/components/schemas/DeploymentGatesFDDRule"
- $ref: "#/components/schemas/DeploymentGatesBitsDeploymentAnalysisRule"
DeploymentGatesFDDRule:
description: A faulty deployment detection rule to evaluate as part of a deployment gate evaluation.
properties:
Expand Down Expand Up @@ -44043,11 +44081,13 @@ components:
enum:
- faulty_deployment_detection
- monitor
- bits_deployment_analysis
example: faulty_deployment_detection
type: string
x-enum-varnames:
- FAULTY_DEPLOYMENT_DETECTION
- MONITOR
- BITS_DEPLOYMENT_ANALYSIS
DeploymentRuleResponseDataAttributesUpdatedBy:
description: Information about the user who updated the deployment rule.
properties:
Expand All @@ -44067,7 +44107,9 @@ components:
- id
type: object
DeploymentRulesOptions:
description: Options for deployment rule response representing either faulty deployment detection or monitor options.
description: |-
Options for deployment rule response representing either faulty deployment detection or monitor options.
Bits Deployment Analysis rules use the faulty deployment detection options shape and accept only `duration`.
oneOf:
- $ref: "#/components/schemas/DeploymentRuleOptionsFaultyDeploymentDetection"
- $ref: "#/components/schemas/DeploymentRuleOptionsMonitor"
Expand Down
42 changes: 42 additions & 0 deletions examples/v2/deployment-gates/CreateDeploymentRule_2546866693.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Create bits deployment analysis deployment rule returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.deployment_gates_api import DeploymentGatesApi
from datadog_api_client.v2.model.create_deployment_rule_params import CreateDeploymentRuleParams
from datadog_api_client.v2.model.create_deployment_rule_params_data import CreateDeploymentRuleParamsData
from datadog_api_client.v2.model.create_deployment_rule_params_data_attributes import (
CreateDeploymentRuleParamsDataAttributes,
)
from datadog_api_client.v2.model.deployment_rule_data_type import DeploymentRuleDataType
from datadog_api_client.v2.model.deployment_rule_options_faulty_deployment_detection import (
DeploymentRuleOptionsFaultyDeploymentDetection,
)

# there is a valid "deployment_gate" in the system
DEPLOYMENT_GATE_DATA_ID = environ["DEPLOYMENT_GATE_DATA_ID"]

body = CreateDeploymentRuleParams(
data=CreateDeploymentRuleParamsData(
attributes=CreateDeploymentRuleParamsDataAttributes(
dry_run=False,
name="Bits deployment analysis rule",
options=DeploymentRuleOptionsFaultyDeploymentDetection(
duration=900,
),
type="bits_deployment_analysis",
),
type=DeploymentRuleDataType.DEPLOYMENT_RULE,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_deployment_rule"] = True
with ApiClient(configuration) as api_client:
api_instance = DeploymentGatesApi(api_client)
response = api_instance.create_deployment_rule(gate_id=DEPLOYMENT_GATE_DATA_ID, body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Trigger a deployment gates evaluation with an inline bits deployment analysis rule returns "Accepted" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.deployment_gates_api import DeploymentGatesApi
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule import (
DeploymentGatesBitsDeploymentAnalysisRule,
)
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_options import (
DeploymentGatesBitsDeploymentAnalysisRuleOptions,
)
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_type import (
DeploymentGatesBitsDeploymentAnalysisRuleType,
)
from datadog_api_client.v2.model.deployment_gates_evaluation_configuration import DeploymentGatesEvaluationConfiguration
from datadog_api_client.v2.model.deployment_gates_evaluation_request import DeploymentGatesEvaluationRequest
from datadog_api_client.v2.model.deployment_gates_evaluation_request_attributes import (
DeploymentGatesEvaluationRequestAttributes,
)
from datadog_api_client.v2.model.deployment_gates_evaluation_request_data import DeploymentGatesEvaluationRequestData
from datadog_api_client.v2.model.deployment_gates_evaluation_request_data_type import (
DeploymentGatesEvaluationRequestDataType,
)

# there is a valid "deployment_gate" in the system
DEPLOYMENT_GATE_DATA_ATTRIBUTES_IDENTIFIER = environ["DEPLOYMENT_GATE_DATA_ATTRIBUTES_IDENTIFIER"]

body = DeploymentGatesEvaluationRequest(
data=DeploymentGatesEvaluationRequestData(
attributes=DeploymentGatesEvaluationRequestAttributes(
configuration=DeploymentGatesEvaluationConfiguration(
dry_run=False,
rules=[
DeploymentGatesBitsDeploymentAnalysisRule(
dry_run=False,
name="bits deployment analysis",
options=DeploymentGatesBitsDeploymentAnalysisRuleOptions(
duration=900,
),
type=DeploymentGatesBitsDeploymentAnalysisRuleType.BITS_DEPLOYMENT_ANALYSIS,
),
],
),
env="production",
identifier=DEPLOYMENT_GATE_DATA_ATTRIBUTES_IDENTIFIER,
service="my-service",
),
type=DeploymentGatesEvaluationRequestDataType.DEPLOYMENT_GATES_EVALUATION_REQUEST,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["trigger_deployment_gates_evaluation"] = True
with ApiClient(configuration) as api_client:
api_instance = DeploymentGatesApi(api_client)
response = api_instance.trigger_deployment_gates_evaluation(body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def __init__(
:type name: str

:param options: Options for deployment rule response representing either faulty deployment detection or monitor options.
Bits Deployment Analysis rules use the faulty deployment detection options shape and accept only ``duration``.
:type options: DeploymentRulesOptions

:param type: The type of the deployment rule (faulty_deployment_detection or monitor).
:param type: The type of the deployment rule ( ``faulty_deployment_detection`` , ``monitor`` , or ``bits_deployment_analysis`` ).
:type type: str
"""
if dry_run is not unset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ class DeploymentGateRuleEvaluationType(ModelSimple):
"""
Type of deployment gate rule.

:param value: Must be one of ["monitor", "faulty_deployment_detection"].
:param value: Must be one of ["monitor", "faulty_deployment_detection", "bits_deployment_analysis"].
:type value: str
"""

allowed_values = {
"monitor",
"faulty_deployment_detection",
"bits_deployment_analysis",
}
MONITOR: ClassVar["DeploymentGateRuleEvaluationType"]
FAULTY_DEPLOYMENT_DETECTION: ClassVar["DeploymentGateRuleEvaluationType"]
BITS_DEPLOYMENT_ANALYSIS: ClassVar["DeploymentGateRuleEvaluationType"]

@cached_property
def openapi_types(_):
Expand All @@ -38,3 +40,4 @@ def openapi_types(_):
DeploymentGateRuleEvaluationType.FAULTY_DEPLOYMENT_DETECTION = DeploymentGateRuleEvaluationType(
"faulty_deployment_detection"
)
DeploymentGateRuleEvaluationType.BITS_DEPLOYMENT_ANALYSIS = DeploymentGateRuleEvaluationType("bits_deployment_analysis")
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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.
from __future__ import annotations

from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_options import (
DeploymentGatesBitsDeploymentAnalysisRuleOptions,
)
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_type import (
DeploymentGatesBitsDeploymentAnalysisRuleType,
)


class DeploymentGatesBitsDeploymentAnalysisRule(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_options import (
DeploymentGatesBitsDeploymentAnalysisRuleOptions,
)
from datadog_api_client.v2.model.deployment_gates_bits_deployment_analysis_rule_type import (
DeploymentGatesBitsDeploymentAnalysisRuleType,
)

return {
"dry_run": (bool,),
"name": (str,),
"options": (DeploymentGatesBitsDeploymentAnalysisRuleOptions,),
"type": (DeploymentGatesBitsDeploymentAnalysisRuleType,),
}

attribute_map = {
"dry_run": "dry_run",
"name": "name",
"options": "options",
"type": "type",
}

def __init__(
self_,
name: str,
type: DeploymentGatesBitsDeploymentAnalysisRuleType,
dry_run: Union[bool, UnsetType] = unset,
options: Union[DeploymentGatesBitsDeploymentAnalysisRuleOptions, UnsetType] = unset,
**kwargs,
):
"""
A Bits Deployment Analysis rule to evaluate as part of a deployment gate evaluation.

:param dry_run: Rule-level dry run. When enabled, Datadog evaluates the rule normally, but the rule always returns ``pass``. The real result appears in the Datadog UI.
:type dry_run: bool, optional

:param name: Human-readable name for this rule.
:type name: str

:param options: Options for a ``bits_deployment_analysis`` rule.
:type options: DeploymentGatesBitsDeploymentAnalysisRuleOptions, optional

:param type: The type identifier for a Bits Deployment Analysis rule.
:type type: DeploymentGatesBitsDeploymentAnalysisRuleType
"""
if dry_run is not unset:
kwargs["dry_run"] = dry_run
if options is not unset:
kwargs["options"] = options
super().__init__(kwargs)

self_.name = name
self_.type = type
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.
from __future__ import annotations

from typing import Union

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


class DeploymentGatesBitsDeploymentAnalysisRuleOptions(ModelNormal):
validations = {
"duration": {
"inclusive_maximum": 7200,
},
}

@cached_property
def openapi_types(_):
return {
"duration": (int,),
}

attribute_map = {
"duration": "duration",
}

def __init__(self_, duration: Union[int, UnsetType] = unset, **kwargs):
"""
Options for a ``bits_deployment_analysis`` rule.

:param duration: Evaluation window in seconds. Maximum 7200 (2 hours).
:type duration: int, optional
"""
if duration is not unset:
kwargs["duration"] = duration
super().__init__(kwargs)
Loading
Loading