|
| 1 | +// Create and publish a form returns "OK" response |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV2::api_forms::FormsAPI; |
| 4 | +use datadog_api_client::datadogV2::model::CreateFormData; |
| 5 | +use datadog_api_client::datadogV2::model::CreateFormDataAttributes; |
| 6 | +use datadog_api_client::datadogV2::model::CreateFormRequest; |
| 7 | +use datadog_api_client::datadogV2::model::FormDataDefinition; |
| 8 | +use datadog_api_client::datadogV2::model::FormType; |
| 9 | +use datadog_api_client::datadogV2::model::FormUiDefinition; |
| 10 | + |
| 11 | +#[tokio::main] |
| 12 | +async fn main() { |
| 13 | + let body = CreateFormRequest::new(CreateFormData::new( |
| 14 | + CreateFormDataAttributes::new( |
| 15 | + FormDataDefinition::new(), |
| 16 | + "User Feedback Form".to_string(), |
| 17 | + FormUiDefinition::new(), |
| 18 | + ) |
| 19 | + .anonymous(false) |
| 20 | + .description("A form to collect user feedback.".to_string()) |
| 21 | + .idp_survey(false) |
| 22 | + .single_response(false), |
| 23 | + FormType::FORMS, |
| 24 | + )); |
| 25 | + let mut configuration = datadog::Configuration::new(); |
| 26 | + configuration.set_unstable_operation_enabled("v2.CreateAndPublishForm", true); |
| 27 | + let api = FormsAPI::with_config(configuration); |
| 28 | + let resp = api.create_and_publish_form(body).await; |
| 29 | + if let Ok(value) = resp { |
| 30 | + println!("{:#?}", value); |
| 31 | + } else { |
| 32 | + println!("{:#?}", resp.unwrap_err()); |
| 33 | + } |
| 34 | +} |
0 commit comments