|
| 1 | +// Bulk write datastore items returns "OK" response |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV2::api_actions_datastores::ActionsDatastoresAPI; |
| 4 | +use datadog_api_client::datadogV2::model::BulkPutAppsDatastoreItemsRequest; |
| 5 | +use datadog_api_client::datadogV2::model::BulkPutAppsDatastoreItemsRequestData; |
| 6 | +use datadog_api_client::datadogV2::model::BulkPutAppsDatastoreItemsRequestDataAttributes; |
| 7 | +use datadog_api_client::datadogV2::model::DatastoreItemsDataType; |
| 8 | +use serde_json::Value; |
| 9 | +use std::collections::BTreeMap; |
| 10 | + |
| 11 | +#[tokio::main] |
| 12 | +async fn main() { |
| 13 | + // there is a valid "datastore" in the system |
| 14 | + let datastore_data_id = std::env::var("DATASTORE_DATA_ID").unwrap(); |
| 15 | + let body = BulkPutAppsDatastoreItemsRequest::new().data( |
| 16 | + BulkPutAppsDatastoreItemsRequestData::new(DatastoreItemsDataType::ITEMS).attributes( |
| 17 | + BulkPutAppsDatastoreItemsRequestDataAttributes::new(vec![ |
| 18 | + BTreeMap::from([ |
| 19 | + ("id".to_string(), Value::from("cust_3141")), |
| 20 | + ("name".to_string(), Value::from("Johnathan")), |
| 21 | + ]), |
| 22 | + BTreeMap::from([ |
| 23 | + ("id".to_string(), Value::from("cust_3142")), |
| 24 | + ("name".to_string(), Value::from("Mary")), |
| 25 | + ]), |
| 26 | + ]), |
| 27 | + ), |
| 28 | + ); |
| 29 | + let configuration = datadog::Configuration::new(); |
| 30 | + let api = ActionsDatastoresAPI::with_config(configuration); |
| 31 | + let resp = api |
| 32 | + .bulk_write_datastore_items(datastore_data_id.clone(), body) |
| 33 | + .await; |
| 34 | + if let Ok(value) = resp { |
| 35 | + println!("{:#?}", value); |
| 36 | + } else { |
| 37 | + println!("{:#?}", resp.unwrap_err()); |
| 38 | + } |
| 39 | +} |
0 commit comments