|
| 1 | +// Post dependencies for analysis returns "OK" response |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI; |
| 4 | +use datadog_api_client::datadogV2::model::ScaRequest; |
| 5 | +use datadog_api_client::datadogV2::model::ScaRequestData; |
| 6 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributes; |
| 7 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesCommit; |
| 8 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItems; |
| 9 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItems; |
| 10 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition; |
| 11 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition; |
| 12 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems; |
| 13 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesFilesItems; |
| 14 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesRelationsItems; |
| 15 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesRepository; |
| 16 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesVulnerabilitiesItems; |
| 17 | +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems; |
| 18 | +use datadog_api_client::datadogV2::model::ScaRequestDataType; |
| 19 | + |
| 20 | +#[tokio::main] |
| 21 | +async fn main() { |
| 22 | + let body = |
| 23 | + ScaRequest |
| 24 | + ::new().data( |
| 25 | + ScaRequestData::new( |
| 26 | + ScaRequestDataType::SCAREQUESTS, |
| 27 | + ).attributes( |
| 28 | + ScaRequestDataAttributes::new() |
| 29 | + .commit(ScaRequestDataAttributesCommit::new()) |
| 30 | + .dependencies( |
| 31 | + vec![ |
| 32 | + ScaRequestDataAttributesDependenciesItems::new() |
| 33 | + .exclusions(vec![]) |
| 34 | + .locations( |
| 35 | + vec![ |
| 36 | + ScaRequestDataAttributesDependenciesItemsLocationsItems::new() |
| 37 | + .block( |
| 38 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition |
| 39 | + ::new() |
| 40 | + .end( |
| 41 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 42 | + ::new(), |
| 43 | + ) |
| 44 | + .start( |
| 45 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 46 | + ::new(), |
| 47 | + ), |
| 48 | + ) |
| 49 | + .name( |
| 50 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition |
| 51 | + ::new() |
| 52 | + .end( |
| 53 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 54 | + ::new(), |
| 55 | + ) |
| 56 | + .start( |
| 57 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 58 | + ::new(), |
| 59 | + ), |
| 60 | + ) |
| 61 | + .namespace( |
| 62 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition |
| 63 | + ::new() |
| 64 | + .end( |
| 65 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 66 | + ::new(), |
| 67 | + ) |
| 68 | + .start( |
| 69 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 70 | + ::new(), |
| 71 | + ), |
| 72 | + ) |
| 73 | + .version( |
| 74 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition |
| 75 | + ::new() |
| 76 | + .end( |
| 77 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 78 | + ::new(), |
| 79 | + ) |
| 80 | + .start( |
| 81 | + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition |
| 82 | + ::new(), |
| 83 | + ), |
| 84 | + ) |
| 85 | + ], |
| 86 | + ) |
| 87 | + .reachable_symbol_properties( |
| 88 | + vec![ |
| 89 | + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems::new() |
| 90 | + ], |
| 91 | + ) |
| 92 | + ], |
| 93 | + ) |
| 94 | + .files(vec![ScaRequestDataAttributesFilesItems::new()]) |
| 95 | + .relations(vec![ScaRequestDataAttributesRelationsItems::new().depends_on(vec![])]) |
| 96 | + .repository(ScaRequestDataAttributesRepository::new()) |
| 97 | + .vulnerabilities( |
| 98 | + vec![ |
| 99 | + ScaRequestDataAttributesVulnerabilitiesItems |
| 100 | + ::new().affects(vec![ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems::new()]) |
| 101 | + ], |
| 102 | + ), |
| 103 | + ), |
| 104 | + ); |
| 105 | + let mut configuration = datadog::Configuration::new(); |
| 106 | + configuration.set_unstable_operation_enabled("v2.CreateSCAResult", true); |
| 107 | + let api = StaticAnalysisAPI::with_config(configuration); |
| 108 | + let resp = api.create_sca_result(body).await; |
| 109 | + if let Ok(value) = resp { |
| 110 | + println!("{:#?}", value); |
| 111 | + } else { |
| 112 | + println!("{:#?}", resp.unwrap_err()); |
| 113 | + } |
| 114 | +} |
0 commit comments