@@ -29,6 +29,29 @@ impl GetFindingOptionalParams {
29
29
}
30
30
}
31
31
32
+ /// GetRuleVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_rule_version_history`]
33
+ #[ non_exhaustive]
34
+ #[ derive( Clone , Default , Debug ) ]
35
+ pub struct GetRuleVersionHistoryOptionalParams {
36
+ /// Size for a given page. The maximum allowed value is 100.
37
+ pub page_size : Option < i64 > ,
38
+ /// Specific page number to return.
39
+ pub page_number : Option < i64 > ,
40
+ }
41
+
42
+ impl GetRuleVersionHistoryOptionalParams {
43
+ /// Size for a given page. The maximum allowed value is 100.
44
+ pub fn page_size ( mut self , value : i64 ) -> Self {
45
+ self . page_size = Some ( value) ;
46
+ self
47
+ }
48
+ /// Specific page number to return.
49
+ pub fn page_number ( mut self , value : i64 ) -> Self {
50
+ self . page_number = Some ( value) ;
51
+ self
52
+ }
53
+ }
54
+
32
55
/// GetSBOMOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_sbom`]
33
56
#[ non_exhaustive]
34
57
#[ derive( Clone , Default , Debug ) ]
@@ -858,6 +881,14 @@ pub enum GetHistoricalJobError {
858
881
UnknownValue ( serde_json:: Value ) ,
859
882
}
860
883
884
+ /// GetRuleVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_rule_version_history`]
885
+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
886
+ #[ serde( untagged) ]
887
+ pub enum GetRuleVersionHistoryError {
888
+ APIErrorResponse ( crate :: datadogV2:: model:: APIErrorResponse ) ,
889
+ UnknownValue ( serde_json:: Value ) ,
890
+ }
891
+
861
892
/// GetSBOMError is a struct for typed errors of method [`SecurityMonitoringAPI::get_sbom`]
862
893
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
863
894
#[ serde( untagged) ]
@@ -3739,6 +3770,141 @@ impl SecurityMonitoringAPI {
3739
3770
}
3740
3771
}
3741
3772
3773
+ /// Get a rule's version history.
3774
+ pub async fn get_rule_version_history (
3775
+ & self ,
3776
+ rule_id : String ,
3777
+ params : GetRuleVersionHistoryOptionalParams ,
3778
+ ) -> Result <
3779
+ crate :: datadogV2:: model:: GetRuleVersionHistoryResponse ,
3780
+ datadog:: Error < GetRuleVersionHistoryError > ,
3781
+ > {
3782
+ match self
3783
+ . get_rule_version_history_with_http_info ( rule_id, params)
3784
+ . await
3785
+ {
3786
+ Ok ( response_content) => {
3787
+ if let Some ( e) = response_content. entity {
3788
+ Ok ( e)
3789
+ } else {
3790
+ Err ( datadog:: Error :: Serde ( serde:: de:: Error :: custom (
3791
+ "response content was None" ,
3792
+ ) ) )
3793
+ }
3794
+ }
3795
+ Err ( err) => Err ( err) ,
3796
+ }
3797
+ }
3798
+
3799
+ /// Get a rule's version history.
3800
+ pub async fn get_rule_version_history_with_http_info (
3801
+ & self ,
3802
+ rule_id : String ,
3803
+ params : GetRuleVersionHistoryOptionalParams ,
3804
+ ) -> Result <
3805
+ datadog:: ResponseContent < crate :: datadogV2:: model:: GetRuleVersionHistoryResponse > ,
3806
+ datadog:: Error < GetRuleVersionHistoryError > ,
3807
+ > {
3808
+ let local_configuration = & self . config ;
3809
+ let operation_id = "v2.get_rule_version_history" ;
3810
+ if local_configuration. is_unstable_operation_enabled ( operation_id) {
3811
+ warn ! ( "Using unstable operation {operation_id}" ) ;
3812
+ } else {
3813
+ let local_error = datadog:: UnstableOperationDisabledError {
3814
+ msg : "Operation 'v2.get_rule_version_history' is not enabled" . to_string ( ) ,
3815
+ } ;
3816
+ return Err ( datadog:: Error :: UnstableOperationDisabledError ( local_error) ) ;
3817
+ }
3818
+
3819
+ // unbox and build optional parameters
3820
+ let page_size = params. page_size ;
3821
+ let page_number = params. page_number ;
3822
+
3823
+ let local_client = & self . client ;
3824
+
3825
+ let local_uri_str = format ! (
3826
+ "{}/api/v2/security_monitoring/rules/{rule_id}/version_history" ,
3827
+ local_configuration. get_operation_host( operation_id) ,
3828
+ rule_id = datadog:: urlencode( rule_id)
3829
+ ) ;
3830
+ let mut local_req_builder =
3831
+ local_client. request ( reqwest:: Method :: GET , local_uri_str. as_str ( ) ) ;
3832
+
3833
+ if let Some ( ref local_query_param) = page_size {
3834
+ local_req_builder =
3835
+ local_req_builder. query ( & [ ( "page[size]" , & local_query_param. to_string ( ) ) ] ) ;
3836
+ } ;
3837
+ if let Some ( ref local_query_param) = page_number {
3838
+ local_req_builder =
3839
+ local_req_builder. query ( & [ ( "page[number]" , & local_query_param. to_string ( ) ) ] ) ;
3840
+ } ;
3841
+
3842
+ // build headers
3843
+ let mut headers = HeaderMap :: new ( ) ;
3844
+ headers. insert ( "Accept" , HeaderValue :: from_static ( "application/json" ) ) ;
3845
+
3846
+ // build user agent
3847
+ match HeaderValue :: from_str ( local_configuration. user_agent . as_str ( ) ) {
3848
+ Ok ( user_agent) => headers. insert ( reqwest:: header:: USER_AGENT , user_agent) ,
3849
+ Err ( e) => {
3850
+ log:: warn!( "Failed to parse user agent header: {e}, falling back to default" ) ;
3851
+ headers. insert (
3852
+ reqwest:: header:: USER_AGENT ,
3853
+ HeaderValue :: from_static ( datadog:: DEFAULT_USER_AGENT . as_str ( ) ) ,
3854
+ )
3855
+ }
3856
+ } ;
3857
+
3858
+ // build auth
3859
+ if let Some ( local_key) = local_configuration. auth_keys . get ( "apiKeyAuth" ) {
3860
+ headers. insert (
3861
+ "DD-API-KEY" ,
3862
+ HeaderValue :: from_str ( local_key. key . as_str ( ) )
3863
+ . expect ( "failed to parse DD-API-KEY header" ) ,
3864
+ ) ;
3865
+ } ;
3866
+ if let Some ( local_key) = local_configuration. auth_keys . get ( "appKeyAuth" ) {
3867
+ headers. insert (
3868
+ "DD-APPLICATION-KEY" ,
3869
+ HeaderValue :: from_str ( local_key. key . as_str ( ) )
3870
+ . expect ( "failed to parse DD-APPLICATION-KEY header" ) ,
3871
+ ) ;
3872
+ } ;
3873
+
3874
+ local_req_builder = local_req_builder. headers ( headers) ;
3875
+ let local_req = local_req_builder. build ( ) ?;
3876
+ log:: debug!( "request content: {:?}" , local_req. body( ) ) ;
3877
+ let local_resp = local_client. execute ( local_req) . await ?;
3878
+
3879
+ let local_status = local_resp. status ( ) ;
3880
+ let local_content = local_resp. text ( ) . await ?;
3881
+ log:: debug!( "response content: {}" , local_content) ;
3882
+
3883
+ if !local_status. is_client_error ( ) && !local_status. is_server_error ( ) {
3884
+ match serde_json:: from_str :: < crate :: datadogV2:: model:: GetRuleVersionHistoryResponse > (
3885
+ & local_content,
3886
+ ) {
3887
+ Ok ( e) => {
3888
+ return Ok ( datadog:: ResponseContent {
3889
+ status : local_status,
3890
+ content : local_content,
3891
+ entity : Some ( e) ,
3892
+ } )
3893
+ }
3894
+ Err ( e) => return Err ( datadog:: Error :: Serde ( e) ) ,
3895
+ } ;
3896
+ } else {
3897
+ let local_entity: Option < GetRuleVersionHistoryError > =
3898
+ serde_json:: from_str ( & local_content) . ok ( ) ;
3899
+ let local_error = datadog:: ResponseContent {
3900
+ status : local_status,
3901
+ content : local_content,
3902
+ entity : local_entity,
3903
+ } ;
3904
+ Err ( datadog:: Error :: ResponseError ( local_error) )
3905
+ }
3906
+ }
3907
+
3742
3908
/// Get a single SBOM related to an asset by its type and name.
3743
3909
///
3744
3910
pub async fn get_sbom (
0 commit comments