From 741bbd009f4d72ef1a7d1e1c505f269c304cba78 Mon Sep 17 00:00:00 2001 From: Andrzej Ressel Date: Tue, 17 Dec 2024 00:35:46 +0100 Subject: [PATCH] Number and integer enums --- examples/typesystem/src/lib.rs | 42 +- .../src/types/builder_version.rs | 2 - .../src/types/integer_enum.rs | 32 + .../src/types/mod.rs | 4 + .../src/types/my_enum.rs | 2 + .../src/types/number_enum.rs | 32 + providers/typesystem.json | 30 + .../src/code_generation/yaml/model.rs | 2 + pulumi_wasm_generator_lib/src/model.rs | 20 +- .../provider/resource_code.rs.handlebars | 4 +- .../src/output/rust/source_code_types_code.rs | 142 +++- .../src/output/rust/source_code_types_mod.rs | 4 +- .../types_code_integer_enum.rs.handlebars | 42 ++ .../rust/types_code_number_enum.rs.handlebars | 42 ++ ...s => types_code_string_enum.rs.handlebars} | 2 +- pulumi_wasm_generator_lib/src/schema.rs | 141 +++- pulumi_wasm_generator_lib/src/utils.rs | 8 + .../tests/output/array-of-enum-map/Cargo.toml | 21 + .../output/array-of-enum-map/lib/Cargo.toml | 12 + .../array-of-enum-map/lib/src/function/mod.rs | 0 .../output/array-of-enum-map/lib/src/lib.rs | 22 + .../lib/src/resource/example_server.rs | 25 + .../array-of-enum-map/lib/src/resource/mod.rs | 1 + .../annotation_store_schema_value_type.rs | 15 + .../array-of-enum-map/lib/src/types/mod.rs | 3 + .../lib/wit/deps/pulumi-wasm.wit | 59 ++ .../array-of-enum-map/lib/wit/world.wit | 30 + .../array-of-enum-map/provider/Cargo.toml | 23 + .../provider/src/function/mod.rs | 0 .../array-of-enum-map/provider/src/lib.rs | 9 + .../provider/src/resource/example_server.rs | 29 + .../provider/src/resource/mod.rs | 1 + .../provider/wit/deps/pulumi-wasm.wit | 59 ++ .../array-of-enum-map/provider/wit/world.wit | 30 + .../array-of-enum-map/rust-toolchain.toml | 3 + .../output/array-of-enum-map/schema.json | 66 ++ .../tests/output/array-of-enum-map/src/lib.rs | 0 .../azure-native-nested-types/schema.json | 673 ++++++++++++++++++ .../tests/output/different-enum/Cargo.toml | 21 + .../output/different-enum/lib/Cargo.toml | 12 + .../different-enum/lib/src/function/mod.rs | 0 .../output/different-enum/lib/src/lib.rs | 22 + .../different-enum/lib/src/resource/mod.rs | 2 + .../lib/src/resource/tree_nursery.rs | 28 + .../lib/src/resource/tree_rubber_tree.rs | 45 ++ .../src/types/cloud_audit_options_log_name.rs | 17 + .../different-enum/lib/src/types/container.rs | 16 + .../lib/src/types/container_brightness.rs | 32 + .../lib/src/types/container_color.rs | 11 + .../lib/src/types/container_size.rs | 37 + .../different-enum/lib/src/types/diameter.rs | 32 + .../different-enum/lib/src/types/farm.rs | 7 + .../different-enum/lib/src/types/mod.rs | 19 + .../lib/src/types/rubber_tree_variety.rs | 11 + .../different-enum/lib/src/types/tree_size.rs | 9 + .../lib/wit/deps/pulumi-wasm.wit | 59 ++ .../output/different-enum/lib/wit/world.wit | 56 ++ .../output/different-enum/provider/Cargo.toml | 23 + .../provider/src/function/mod.rs | 0 .../output/different-enum/provider/src/lib.rs | 9 + .../provider/src/resource/mod.rs | 2 + .../provider/src/resource/tree_nursery.rs | 26 + .../provider/src/resource/tree_rubber_tree.rs | 41 ++ .../provider/wit/deps/pulumi-wasm.wit | 59 ++ .../different-enum/provider/wit/world.wit | 56 ++ .../output/different-enum/rust-toolchain.toml | 3 + .../tests/output/different-enum/schema.json | 267 +++++++ .../tests/output/different-enum/src/lib.rs | 0 pulumi_wasm_generator_lib/tests/test.rs | 10 + pulumi_wasm_provider_common/src/lib.rs | 6 +- 70 files changed, 2533 insertions(+), 37 deletions(-) create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/integer_enum.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/number_enum.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars create mode 100644 pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars rename pulumi_wasm_generator_lib/src/output/rust/{types_code_enum.rs.handlebars => types_code_string_enum.rs.handlebars} (89%) create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/example_server.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/annotation_store_schema_value_type.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/deps/pulumi-wasm.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/world.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/lib.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/example_server.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/deps/pulumi-wasm.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/world.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/rust-toolchain.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/schema.json create mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/src/lib.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/azure-native-nested-types/schema.json create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/cloud_audit_options_log_name.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_brightness.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_color.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_size.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/diameter.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/farm.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/rubber_tree_variety.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree_size.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/deps/pulumi-wasm.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/world.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/Cargo.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/lib.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/deps/pulumi-wasm.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/world.wit create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/rust-toolchain.toml create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/schema.json create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/src/lib.rs diff --git a/examples/typesystem/src/lib.rs b/examples/typesystem/src/lib.rs index 984d98aab..189436d45 100644 --- a/examples/typesystem/src/lib.rs +++ b/examples/typesystem/src/lib.rs @@ -4,7 +4,8 @@ mod tests { use pulumi_wasm_rust::Output; use pulumi_wasm_typesystem::typesystem_server::TypesystemServerArgs; use pulumi_wasm_typesystem::{ - MyEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, UnionCaseWithConst2, + IntegerEnum, MyEnum, NumberEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, + UnionCaseWithConst2, }; use std::panic::catch_unwind; @@ -34,17 +35,54 @@ mod tests { } #[test] - fn test_enum_deserialization() { + fn test_string_enum_deserialization() { let enum1 = MyEnum::Value1; let enum2 = MyEnum::Value2; + let enum3 = MyEnum::special_characters; let enum1_json = serde_json::to_string(&enum1).unwrap(); let enum2_json = serde_json::to_string(&enum2).unwrap(); + let enum3_json = serde_json::to_string(&enum3).unwrap(); assert_eq!(enum1_json, r#""VALUE1""#); assert_eq!(enum2_json, r#""Value2""#); + assert_eq!(enum3_json, r#""Plants'R'Us""#); let deserialized_enum1: MyEnum = serde_json::from_str(&enum1_json).unwrap(); let deserialized_enum2: MyEnum = serde_json::from_str(&enum2_json).unwrap(); + let deserialized_enum3: MyEnum = serde_json::from_str(&enum3_json).unwrap(); + assert_eq!(deserialized_enum1, enum1); + assert_eq!(deserialized_enum2, enum2); + assert_eq!(deserialized_enum3, enum3); + } + + #[test] + fn test_integer_enum_deserialization() { + let enum1 = IntegerEnum::Value1; + let enum2 = IntegerEnum::Value2; + + let enum1_json = serde_json::to_string(&enum1).unwrap(); + let enum2_json = serde_json::to_string(&enum2).unwrap(); + assert_eq!(enum1_json, "1"); + assert_eq!(enum2_json, "2"); + + let deserialized_enum1: IntegerEnum = serde_json::from_str(&enum1_json).unwrap(); + let deserialized_enum2: IntegerEnum = serde_json::from_str(&enum2_json).unwrap(); + assert_eq!(deserialized_enum1, enum1); + assert_eq!(deserialized_enum2, enum2); + } + + #[test] + fn test_number_enum_deserialization() { + let enum1 = NumberEnum::Value1; + let enum2 = NumberEnum::Value2; + + let enum1_json = serde_json::to_string(&enum1).unwrap(); + let enum2_json = serde_json::to_string(&enum2).unwrap(); + assert_eq!(enum1_json, "1.0"); + assert_eq!(enum2_json, "2.0"); + + let deserialized_enum1: NumberEnum = serde_json::from_str(&enum1_json).unwrap(); + let deserialized_enum2: NumberEnum = serde_json::from_str(&enum2_json).unwrap(); assert_eq!(deserialized_enum1, enum1); assert_eq!(deserialized_enum2, enum2); } diff --git a/providers/pulumi_wasm_provider_docker_rust/src/types/builder_version.rs b/providers/pulumi_wasm_provider_docker_rust/src/types/builder_version.rs index 4f33d1191..31d737a25 100644 --- a/providers/pulumi_wasm_provider_docker_rust/src/types/builder_version.rs +++ b/providers/pulumi_wasm_provider_docker_rust/src/types/builder_version.rs @@ -3,9 +3,7 @@ #[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] pub enum BuilderVersion { /// The first generation builder for Docker Daemon - #[serde(rename = "BuilderV1")] BuilderV1, /// The builder based on moby/buildkit project - #[serde(rename = "BuilderBuildKit")] BuilderBuildKit, } diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/integer_enum.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/integer_enum.rs new file mode 100644 index 000000000..47b18a871 --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/integer_enum.rs @@ -0,0 +1,32 @@ +#[derive(Debug, PartialEq, Clone)] +pub enum IntegerEnum { + Value1, + Value2, +} + +impl serde::Serialize for IntegerEnum { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + IntegerEnum::Value1 => 1, + IntegerEnum::Value2 => 2, + }; + serializer.serialize_i64(value) + } +} + +impl<'de> serde::Deserialize<'de> for IntegerEnum { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = i64::deserialize(deserializer)?; + match f { + 1 => Ok(IntegerEnum::Value1), + 2 => Ok(IntegerEnum::Value2), + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs index 44fda6497..d798c4283 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs @@ -1,5 +1,9 @@ +mod integer_enum; +pub use integer_enum::*; mod my_enum; pub use my_enum::*; +mod number_enum; +pub use number_enum::*; mod union_case_1; pub use union_case_1::*; mod union_case_2; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/my_enum.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/my_enum.rs index bb11851f4..5066e95f1 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/types/my_enum.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/my_enum.rs @@ -3,4 +3,6 @@ pub enum MyEnum { #[serde(rename = "VALUE1")] Value1, Value2, + #[serde(rename = "Plants'R'Us")] + special_characters, } diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/number_enum.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/number_enum.rs new file mode 100644 index 000000000..715f4d92b --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/number_enum.rs @@ -0,0 +1,32 @@ +#[derive(Debug, PartialEq, Clone)] +pub enum NumberEnum { + Value1, + Value2, +} + +impl serde::Serialize for NumberEnum { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + NumberEnum::Value1 => 1.0, + NumberEnum::Value2 => 2.0, + }; + serializer.serialize_f64(value) + } +} + +impl<'de> serde::Deserialize<'de> for NumberEnum { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = f64::deserialize(deserializer)?; + match f { + 1.0 => Ok(NumberEnum::Value1), + 2.0 => Ok(NumberEnum::Value2), + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/providers/typesystem.json b/providers/typesystem.json index 52c8fa0e3..0d69890e3 100644 --- a/providers/typesystem.json +++ b/providers/typesystem.json @@ -132,6 +132,36 @@ }, { "name": "Value2" + }, + { + "name": "special_characters", + "value": "Plants'R'Us" + } + ] + }, + "typesystem:index:NumberEnum": { + "type": "number", + "enum": [ + { + "name": "Value1", + "value": 1.0 + }, + { + "name": "Value2", + "value": 2.0 + } + ] + }, + "typesystem:index:IntegerEnum": { + "type": "integer", + "enum": [ + { + "name": "Value1", + "value": 1 + }, + { + "name": "Value2", + "value": 2 } ] } diff --git a/pulumi_wasm_generator_lib/src/code_generation/yaml/model.rs b/pulumi_wasm_generator_lib/src/code_generation/yaml/model.rs index 31537ef45..df66bfdde 100644 --- a/pulumi_wasm_generator_lib/src/code_generation/yaml/model.rs +++ b/pulumi_wasm_generator_lib/src/code_generation/yaml/model.rs @@ -253,6 +253,8 @@ fn map_type( let gtp = match tpe { GlobalType::Object(_, gtp) => gtp, + GlobalType::NumberEnum(_, _) => panic!("NumberEnum type is not supported"), + GlobalType::IntegerEnum(_, _) => panic!("IntegerEnum type is not supported"), GlobalType::StringEnum(_, _) => panic!("StringEnum type is not supported"), GlobalType::String => panic!("String type is not supported"), GlobalType::Boolean => panic!("Boolean type is not supported"), diff --git a/pulumi_wasm_generator_lib/src/model.rs b/pulumi_wasm_generator_lib/src/model.rs index 8963ced64..1deb27915 100644 --- a/pulumi_wasm_generator_lib/src/model.rs +++ b/pulumi_wasm_generator_lib/src/model.rs @@ -132,10 +132,12 @@ pub(crate) struct GlobalTypeProperty { pub(crate) description: Option, } -#[derive(Debug, PartialEq, Hash, Ord, PartialOrd, Eq)] +#[derive(Debug, PartialEq, PartialOrd)] pub(crate) enum GlobalType { Object(Option, Vec), StringEnum(Option, Vec), + NumberEnum(Option, Vec), + IntegerEnum(Option, Vec), String, Boolean, Number, @@ -149,6 +151,20 @@ pub(crate) struct StringEnumElement { pub(crate) description: Option, } +#[derive(Debug, PartialEq, PartialOrd)] +pub(crate) struct NumberEnumElement { + pub(crate) name: String, + pub(crate) value: f64, + pub(crate) description: Option, +} + +#[derive(Debug, PartialEq, PartialOrd)] +pub(crate) struct IntegerEnumElement { + pub(crate) name: String, + pub(crate) value: i64, + pub(crate) description: Option, +} + #[derive(Debug, PartialEq, Hash, Ord, PartialOrd, Eq)] pub(crate) struct Resource { pub(crate) element_id: ElementId, @@ -167,7 +183,7 @@ pub(crate) struct Function { pub(crate) output_properties: Vec, } -#[derive(Debug, PartialEq, Hash, Ord, PartialOrd, Eq)] +#[derive(Debug, PartialEq)] pub(crate) struct Package { pub(crate) name: String, pub(crate) display_name: Option, diff --git a/pulumi_wasm_generator_lib/src/output/provider/resource_code.rs.handlebars b/pulumi_wasm_generator_lib/src/output/provider/resource_code.rs.handlebars index 3c3ff9f0f..93fa9d592 100644 --- a/pulumi_wasm_generator_lib/src/output/provider/resource_code.rs.handlebars +++ b/pulumi_wasm_generator_lib/src/output/provider/resource_code.rs.handlebars @@ -4,7 +4,7 @@ use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, r use crate::Component; impl {{interface.name}}::Guest for Component { - fn invoke(name: String, args: {{interface.name}}::Args) -> {{interface.name}}::Res { + fn invoke(name: String, args: {{interface.name}}::Args){{#if interface.output_properties}} -> {{interface.name}}::Res{{/if}} { pulumi_wasm_common::setup_logger(); let request = RegisterResourceRequest { type_: "{{interface.type}}".into(), @@ -25,11 +25,13 @@ impl {{interface.name}}::Guest for Component { let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); +{{#if interface.output_properties}} {{interface.name}}::Res { {{#each interface.output_properties}} {{arg_name}}: hashmap.remove("{{name}}").unwrap(), {{/each}} } +{{/if}} } } diff --git a/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs b/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs index 2fd3c3c58..2a459b5cf 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs +++ b/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs @@ -7,7 +7,9 @@ use std::collections::{BTreeSet, HashMap}; use std::path::PathBuf; static TEMPLATE: &str = include_str!("types_code.rs.handlebars"); -static ENUM_TEMPLATE: &str = include_str!("types_code_enum.rs.handlebars"); +static STRING_ENUM_TEMPLATE: &str = include_str!("types_code_string_enum.rs.handlebars"); +static NUMBER_ENUM_TEMPLATE: &str = include_str!("types_code_number_enum.rs.handlebars"); +static INTEGER_ENUM_TEMPLATE: &str = include_str!("types_code_integer_enum.rs.handlebars"); #[derive(Serialize)] struct Property { @@ -31,20 +33,50 @@ struct RefType { } #[derive(Serialize)] -struct Enum { +struct StringEnum { struct_name: String, file_name: String, description_lines: Vec, - values: Vec, + values: Vec, } #[derive(Serialize)] -struct EnumValue { +struct StringEnumValue { name: String, description_lines: Vec, value: Option, } +#[derive(Serialize)] +struct IntegerEnum { + struct_name: String, + file_name: String, + description_lines: Vec, + values: Vec, +} + +#[derive(Serialize)] +struct IntegerEnumValue { + name: String, + description_lines: Vec, + value: i64, +} + +#[derive(Serialize)] +struct NumberEnum { + struct_name: String, + file_name: String, + description_lines: Vec, + values: Vec, +} + +#[derive(Serialize)] +struct NumberEnumValue { + name: String, + description_lines: Vec, + value: f64, +} + #[derive(Serialize)] struct AliasType { name: String, @@ -55,12 +87,16 @@ struct AliasType { struct Package { name: String, types: Vec, - enums: Vec, + string_enums: Vec, + number_enums: Vec, + integer_enums: Vec, } fn convert_model(package: &crate::model::Package) -> Package { let mut real_types = Vec::new(); - let mut enums = Vec::new(); + let mut string_enums = Vec::new(); + let mut number_enums = Vec::new(); + let mut integer_enums = Vec::new(); package .types @@ -99,15 +135,55 @@ fn convert_model(package: &crate::model::Package) -> Package { real_types.push(ref_type); } GlobalType::StringEnum(description, enum_values) => { - let enum_type = Enum { + let enum_type = StringEnum { + struct_name: element_id.get_rust_struct_name(), + file_name: element_id.get_rust_struct_name().to_case(Case::Snake), + description_lines: crate::utils::to_lines(description.clone(), package, None), + values: enum_values + .iter() + .map(|enum_value| StringEnumValue { + name: enum_value.name.clone(), + value: enum_value.value.clone().map(|s| format!("\"{}\"", s)), + description_lines: crate::utils::to_lines( + enum_value.description.clone(), + package, + None, + ), + }) + .collect(), + }; + string_enums.push(enum_type); + } + GlobalType::NumberEnum(description, enum_values) => { + let enum_type = NumberEnum { + struct_name: element_id.get_rust_struct_name(), + file_name: element_id.get_rust_struct_name().to_case(Case::Snake), + description_lines: crate::utils::to_lines(description.clone(), package, None), + values: enum_values + .iter() + .map(|enum_value| NumberEnumValue { + name: enum_value.name.clone(), + value: enum_value.value, + description_lines: crate::utils::to_lines( + enum_value.description.clone(), + package, + None, + ), + }) + .collect(), + }; + number_enums.push(enum_type); + } + GlobalType::IntegerEnum(description, enum_values) => { + let enum_type = IntegerEnum { struct_name: element_id.get_rust_struct_name(), file_name: element_id.get_rust_struct_name().to_case(Case::Snake), description_lines: crate::utils::to_lines(description.clone(), package, None), values: enum_values .iter() - .map(|enum_value| EnumValue { + .map(|enum_value| IntegerEnumValue { name: enum_value.name.clone(), - value: enum_value.value.clone(), + value: enum_value.value, description_lines: crate::utils::to_lines( enum_value.description.clone(), package, @@ -116,7 +192,7 @@ fn convert_model(package: &crate::model::Package) -> Package { }) .collect(), }; - enums.push(enum_type); + integer_enums.push(enum_type); } GlobalType::String => {} GlobalType::Boolean => {} @@ -127,7 +203,9 @@ fn convert_model(package: &crate::model::Package) -> Package { Package { name: package.name.clone(), types: real_types, - enums, + string_enums, + number_enums, + integer_enums, } } @@ -151,12 +229,44 @@ pub(crate) fn generate_source_code(package: &crate::model::Package) -> HashMap

= package - .enums + let string_enums: HashMap<_, _> = package + .string_enums + .iter() + .map(|enum_| { + let rendered_file = handlebars + .render_template(STRING_ENUM_TEMPLATE, &json!({"enum": enum_})) + .unwrap() + .trim_start() + .to_string(); //FIXME + ( + PathBuf::from(format!("{}.rs", enum_.file_name)), + rendered_file, + ) + }) + .collect(); + + let number_enums: HashMap<_, _> = package + .number_enums + .iter() + .map(|enum_| { + let rendered_file = handlebars + .render_template(NUMBER_ENUM_TEMPLATE, &json!({"enum": enum_})) + .unwrap() + .trim_start() + .to_string(); //FIXME + ( + PathBuf::from(format!("{}.rs", enum_.file_name)), + rendered_file, + ) + }) + .collect(); + + let integer_enums: HashMap<_, _> = package + .integer_enums .iter() .map(|enum_| { let rendered_file = handlebars - .render_template(ENUM_TEMPLATE, &json!({"enum": enum_})) + .render_template(INTEGER_ENUM_TEMPLATE, &json!({"enum": enum_})) .unwrap() .trim_start() .to_string(); //FIXME @@ -169,7 +279,9 @@ pub(crate) fn generate_source_code(package: &crate::model::Package) -> HashMap

Package { }; real_types.push(ref_type); } - GlobalType::StringEnum(_, _) => { + GlobalType::StringEnum(_, _) + | GlobalType::IntegerEnum(_, _) + | GlobalType::NumberEnum(_, _) => { let ref_type = RefType { file_name: element_id.get_rust_struct_name().to_case(Case::Snake), }; diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars new file mode 100644 index 000000000..cca674028 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars @@ -0,0 +1,42 @@ +{{#each enum.description_lines}} + //! {{&this}} +{{/each}} + +#[derive(Debug, PartialEq, Clone)] +pub enum {{enum.struct_name}} { + {{#each enum.values as |value|}} + {{#each value.description_lines}} + /// {{&this}} + {{/each}} + {{value.name}}, + {{/each}} +} + +impl serde::Serialize for {{enum.struct_name}} { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + {{#each enum.values as |value|}} + {{@root.enum.struct_name}}::{{value.name}} => {{value.value}}, + {{/each}} + }; + serializer.serialize_i64(value) + } +} + +impl<'de> serde::Deserialize<'de> for {{enum.struct_name}} { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = i64::deserialize(deserializer)?; + match f { + {{#each enum.values as |value|}} + {{value.value}} => Ok({{@root.enum.struct_name}}::{{value.name}}), + {{/each}} + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars new file mode 100644 index 000000000..2134a8556 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars @@ -0,0 +1,42 @@ +{{#each enum.description_lines}} + //! {{&this}} +{{/each}} + +#[derive(Debug, PartialEq, Clone)] +pub enum {{enum.struct_name}} { + {{#each enum.values as |value|}} + {{#each value.description_lines}} + /// {{&this}} + {{/each}} + {{value.name}}, + {{/each}} +} + +impl serde::Serialize for {{enum.struct_name}} { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + {{#each enum.values as |value|}} + {{@root.enum.struct_name}}::{{value.name}} => {{value.value}}, + {{/each}} + }; + serializer.serialize_f64(value) + } +} + +impl<'de> serde::Deserialize<'de> for {{enum.struct_name}} { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = f64::deserialize(deserializer)?; + match f { + {{#each enum.values as |value|}} + {{value.value}} => Ok({{@root.enum.struct_name}}::{{value.name}}), + {{/each}} + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types_code_string_enum.rs.handlebars similarity index 89% rename from pulumi_wasm_generator_lib/src/output/rust/types_code_enum.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/types_code_string_enum.rs.handlebars index 690c8381a..d940e49fb 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/types_code_enum.rs.handlebars +++ b/pulumi_wasm_generator_lib/src/output/rust/types_code_string_enum.rs.handlebars @@ -9,7 +9,7 @@ pub enum {{enum.struct_name}} { /// {{&this}} {{/each}} {{#if value.value}} - #[serde(rename = "{{value.value}}")] + #[serde(rename = {{{value.value}}})] {{/if}} {{value.name}}, {{/each}} diff --git a/pulumi_wasm_generator_lib/src/schema.rs b/pulumi_wasm_generator_lib/src/schema.rs index f0b933d57..bad3185b5 100644 --- a/pulumi_wasm_generator_lib/src/schema.rs +++ b/pulumi_wasm_generator_lib/src/schema.rs @@ -1,8 +1,10 @@ use crate::model::{ - ElementId, GlobalType, GlobalTypeProperty, InputProperty, OutputProperty, Ref, - StringEnumElement, + ElementId, GlobalType, GlobalTypeProperty, InputProperty, IntegerEnumElement, + NumberEnumElement, OutputProperty, Ref, StringEnumElement, }; +use crate::utils::sanitize_identifier; use anyhow::{anyhow, Context, Result}; +use convert_case::{Case, Casing}; use serde::Deserialize; use std::collections::{BTreeMap, BTreeSet, HashSet}; @@ -79,7 +81,7 @@ struct ObjectType { #[serde(default)] required: BTreeSet, #[serde(rename = "enum")] - enum_: Option>, + enum_: Option, } #[derive(Deserialize, Debug)] @@ -93,7 +95,29 @@ struct Resource { } #[derive(Deserialize, Debug)] -struct EnumValue { +#[serde(untagged)] +enum ObjectTypeEnum { + String(Vec), + Integer(Vec), + Number(Vec), +} + +#[derive(Deserialize, Debug)] +struct IntegerEnumValue { + name: String, + description: Option, + value: i64, +} + +#[derive(Deserialize, Debug)] +struct NumberEnumValue { + name: String, + description: Option, + value: f64, +} + +#[derive(Deserialize, Debug)] +struct StringEnumValue { name: Option, description: Option, value: Option, @@ -381,20 +405,57 @@ fn convert_to_global_type( r#type: Some(TypeEnum::Boolean), .. } => Ok(GlobalType::Boolean), + + ObjectType { + r#type: Some(TypeEnum::Integer), + enum_: Some(ObjectTypeEnum::Integer(enum_cases)), + description, + .. + } => Ok(create_integer_enum(description, enum_cases)), + ObjectType { + r#type: Some(TypeEnum::Integer), + enum_: Some(e), + .. + } => Err(anyhow!("Invalid integer enum combination {:?}", e)), ObjectType { r#type: Some(TypeEnum::Integer), .. } => Ok(GlobalType::Integer), + + ObjectType { + r#type: Some(TypeEnum::Number), + enum_: Some(ObjectTypeEnum::Number(enum_cases)), + description, + .. + } => Ok(create_number_enum(description, enum_cases)), + ObjectType { + r#type: Some(TypeEnum::Number), + enum_: Some(ObjectTypeEnum::Integer(enum_cases)), + description, + .. + } => Ok(create_number_integer_enum(description, enum_cases)), + + ObjectType { + r#type: Some(TypeEnum::Number), + enum_: Some(e), + .. + } => Err(anyhow!("Invalid number enum combination {:?}", e)), ObjectType { r#type: Some(TypeEnum::Number), .. } => Ok(GlobalType::Number), + ObjectType { r#type: Some(TypeEnum::String), - enum_: Some(enum_cases), + enum_: Some(ObjectTypeEnum::String(enum_cases)), description, .. } => Ok(create_string_enum(description, enum_cases)), + ObjectType { + r#type: Some(TypeEnum::String), + enum_: Some(e), + .. + } => Err(anyhow!("Invalid string enum combination {:?}", e)), ObjectType { r#type: Some(TypeEnum::String), .. @@ -404,21 +465,50 @@ fn convert_to_global_type( Ok((element_id, tpe)) } -fn create_string_enum(description: &Option, enum_values: &[EnumValue]) -> GlobalType { +fn create_number_integer_enum( + description: &Option, + enum_values: &[IntegerEnumValue], +) -> GlobalType { + GlobalType::NumberEnum( + description.clone(), + enum_values + .iter() + .map(|enum_value| NumberEnumElement { + name: enum_value.name.clone(), + value: enum_value.value as f64, + description: enum_value.description.clone(), + }) + .collect(), + ) +} + +fn create_string_enum(description: &Option, enum_values: &[StringEnumValue]) -> GlobalType { GlobalType::StringEnum( description.clone(), enum_values .iter() .map(|enum_value| { - let (real_name, real_value) = match (&enum_value.name, &enum_value.value) { - (Some(name), Some(value)) => (name.clone(), Some(value.clone())), - (Some(name), None) => (name.clone(), None), - (None, Some(value)) => (value.clone(), None), + let (name, value) = match (&enum_value.name, &enum_value.value) { + (Some(name), Some(value)) => (sanitize_identifier(name), value.clone()), + (Some(name), None) => ( + sanitize_identifier(name).to_case(Case::UpperCamel), + name.clone(), + ), + (None, Some(value)) => ( + sanitize_identifier(value).to_case(Case::UpperCamel), + value.clone(), + ), (None, None) => { panic!("Invalid enum value: {enum_value:?}") } }; + let (real_name, real_value) = if (name == value) { + (name, None) + } else { + (name, Some(value)) + }; + StringEnumElement { name: real_name, value: real_value, @@ -429,6 +519,37 @@ fn create_string_enum(description: &Option, enum_values: &[EnumValue]) - ) } +fn create_integer_enum( + description: &Option, + enum_values: &[IntegerEnumValue], +) -> GlobalType { + GlobalType::IntegerEnum( + description.clone(), + enum_values + .iter() + .map(|enum_value| IntegerEnumElement { + name: enum_value.name.clone(), + value: enum_value.value.clone(), + description: enum_value.description.clone(), + }) + .collect(), + ) +} + +fn create_number_enum(description: &Option, enum_values: &[NumberEnumValue]) -> GlobalType { + GlobalType::NumberEnum( + description.clone(), + enum_values + .iter() + .map(|enum_value| NumberEnumElement { + name: enum_value.name.clone(), + value: enum_value.value.clone(), + description: enum_value.description.clone(), + }) + .collect(), + ) +} + fn invalid_required_complextype_required_fields() -> HashSet<(ElementId, String)> { HashSet::from([ // https://github.com/pulumi/pulumi-docker/issues/1052 diff --git a/pulumi_wasm_generator_lib/src/utils.rs b/pulumi_wasm_generator_lib/src/utils.rs index 80cc00b5d..ba6005d35 100644 --- a/pulumi_wasm_generator_lib/src/utils.rs +++ b/pulumi_wasm_generator_lib/src/utils.rs @@ -80,6 +80,14 @@ pub(crate) fn escape_wit_identifier(s: &str) -> &str { } } +pub(crate) fn sanitize_identifier(input: &str) -> String { + // Filter characters that are valid for an identifier in Rust + input + .chars() + .filter(|c| c.is_alphanumeric() || *c == '_') // Keep letters, digits, and underscores + .collect() +} + pub(crate) fn to_lines( s: Option, package: &crate::model::Package, diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/Cargo.toml new file mode 100644 index 000000000..10895020d --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "main" +version = "0.0.1" +edition = "2021" + +[workspace] +members = [ + "provider", + "lib" +] + +[workspace.dependencies] +wit-bindgen-rt = "0.33.0" +wit-bindgen = "0.33.0" +automod = "1.0.14" +pulumi_wasm_common = { path = "../../../../pulumi_wasm_common" } +pulumi_wasm_rust = { path = "../../../../pulumi_wasm_rust" } +pulumi_wasm_wit = { path = "../../../../pulumi_wasm_wit" } +pulumi_wasm_provider_common = { path = "../../../../pulumi_wasm_provider_common" } +serde = "1.0.197" +bon = "2.2.1" \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/Cargo.toml new file mode 100644 index 000000000..cc5d0446e --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pulumi_wasm_example" +version = "1.0.0-0.0.0-DEV" +edition = "2021" + +[dependencies] +wit-bindgen.workspace = true +pulumi_wasm_rust.workspace = true +serde.workspace = true +pulumi_wasm_wit = { workspace = true, features = ["client"] } +bon.workspace = true +pulumi_wasm_provider_common.workspace = true diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs new file mode 100644 index 000000000..760081ab4 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs @@ -0,0 +1,22 @@ +use pulumi_wasm_rust::Output; +use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface::Output as WitOutput; +#[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] +mod resource; +pub use resource::*; +#[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] +mod types; +pub use types::*; + +mod bindings { + wit_bindgen::generate!({ + // the name of the world in the `*.wit` input file + world: "example-pulumi-client", + with: { + "component:pulumi-wasm/output-interface@0.0.0-DEV": pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface + } + }); +} + +fn into_domain(output: WitOutput) -> Output { + unsafe { Output::::new_from_handle(output) } +} diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/example_server.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/example_server.rs new file mode 100644 index 000000000..be233b042 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/example_server.rs @@ -0,0 +1,25 @@ + +#[derive(bon::Builder, Clone)] +#[builder(finish_fn = build_struct)] +pub struct ExampleServerArgs { + #[builder(into, default)] + pub map_array_enum: pulumi_wasm_rust::Output>>>, +} + +pub struct ExampleServerResult { + pub map_array_enum: pulumi_wasm_rust::Output>>>, +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn create(name: &str, args: ExampleServerArgs) -> ExampleServerResult { + + let result = crate::bindings::pulumi::example::example_server::invoke(name, &crate::bindings::pulumi::example::example_server::Args { + map_array_enum: &args.map_array_enum.get_inner(), + }); + + ExampleServerResult { + map_array_enum: crate::into_domain(result.map_array_enum), + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/mod.rs new file mode 100644 index 000000000..6b46b16e6 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/mod.rs @@ -0,0 +1 @@ +pub mod example_server; diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/annotation_store_schema_value_type.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/annotation_store_schema_value_type.rs new file mode 100644 index 000000000..f6d84bdd3 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/annotation_store_schema_value_type.rs @@ -0,0 +1,15 @@ +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum AnnotationStoreSchemaValueType { + #[serde(rename = "LONG")] + Long, + #[serde(rename = "INT")] + Int, + #[serde(rename = "STRING")] + String, + #[serde(rename = "FLOAT")] + Float, + #[serde(rename = "DOUBLE")] + Double, + #[serde(rename = "BOOLEAN")] + Boolean, +} diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/mod.rs new file mode 100644 index 000000000..b8ecdf1b8 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/types/mod.rs @@ -0,0 +1,3 @@ +mod annotation_store_schema_value_type; +pub use annotation_store_schema_value_type::*; + diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/deps/pulumi-wasm.wit b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/deps/pulumi-wasm.wit new file mode 100644 index 000000000..d41010180 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/deps/pulumi-wasm.wit @@ -0,0 +1,59 @@ +package component:pulumi-wasm@0.0.0-DEV; + +interface output-interface { + + resource output { + constructor(value: string); + map: func(function-name: string) -> output; + } + combine: func(outputs: list>) -> output; +} + + +interface register-interface { + use output-interface.{output}; + + record object-field { + name: string, + value: borrow + } + + record result-field { + name: string + } + + record register-resource-result-field { + name: string, + output: output + } + + record register-resource-request { + %type: string, + name: string, + object: list, + results: list + } + + record register-resource-result { + fields: list + } + + register: func(request: register-resource-request) -> register-resource-result; + + record resource-invoke-result-field { + name: string, + output: output + } + + record resource-invoke-request { + token: string, + object: list, + results: list + } + + record resource-invoke-result { + fields: list + } + + invoke: func(request: resource-invoke-request) -> resource-invoke-result; +} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/world.wit b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/world.wit new file mode 100644 index 000000000..ea8780ea0 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/wit/world.wit @@ -0,0 +1,30 @@ +package pulumi:example@1.0.0--0.0.0-DEV; + +world example-pulumi { + import component:pulumi-wasm/register-interface@0.0.0-DEV; + export example-server; +} + +world example-pulumi-client { + import example-server; +} + +interface example-server { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + map-array-enum: borrow, + } + + record res { + map-array-enum: output, + } + + invoke: func( + name: string, + args: args + ) -> res; + +} + diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/Cargo.toml new file mode 100644 index 000000000..17ee7ffd7 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "pulumi_wasm_example_provider" +version = "1.0.0-0.0.0-DEV" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wit-bindgen-rt.workspace = true +pulumi_wasm_common.workspace = true + +[package.metadata.component] +package = "pulumi:example" + +[package.metadata.component.target] +path = "wit" +world = "example-pulumi" + +[package.metadata.component.target.dependencies] +"component:pulumi-wasm" = { path = "wit/deps/pulumi-wasm.wit" } diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/function/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/lib.rs new file mode 100644 index 000000000..b7a2350e1 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/lib.rs @@ -0,0 +1,9 @@ +mod resource; + +#[allow(unused_braces)] +#[allow(unused_imports)] +#[allow(static_mut_refs)] +mod bindings; +bindings::export!(Component with_types_in bindings); + +struct Component {} diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/example_server.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/example_server.rs new file mode 100644 index 000000000..afa4f8324 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/example_server.rs @@ -0,0 +1,29 @@ +use std::collections::HashMap; +use crate::bindings::exports::pulumi::example::example_server; +use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; +use crate::Component; + +impl example_server::Guest for Component { + fn invoke(name: String, args: example_server::Args) -> example_server::Res { + pulumi_wasm_common::setup_logger(); + let request = RegisterResourceRequest { + type_: "example:index:ExampleServer".into(), + name, + object: vec![ + ObjectField { name: "mapArrayEnum".into(), value: args.map_array_enum }, + ], + results: vec![ + ResultField { name: "mapArrayEnum".into() }, + ], + }; + + let o = register(&request); + + let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); + + example_server::Res { + map_array_enum: hashmap.remove("mapArrayEnum").unwrap(), + } + + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/mod.rs new file mode 100644 index 000000000..6b46b16e6 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/src/resource/mod.rs @@ -0,0 +1 @@ +pub mod example_server; diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/deps/pulumi-wasm.wit b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/deps/pulumi-wasm.wit new file mode 100644 index 000000000..d41010180 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/deps/pulumi-wasm.wit @@ -0,0 +1,59 @@ +package component:pulumi-wasm@0.0.0-DEV; + +interface output-interface { + + resource output { + constructor(value: string); + map: func(function-name: string) -> output; + } + combine: func(outputs: list>) -> output; +} + + +interface register-interface { + use output-interface.{output}; + + record object-field { + name: string, + value: borrow + } + + record result-field { + name: string + } + + record register-resource-result-field { + name: string, + output: output + } + + record register-resource-request { + %type: string, + name: string, + object: list, + results: list + } + + record register-resource-result { + fields: list + } + + register: func(request: register-resource-request) -> register-resource-result; + + record resource-invoke-result-field { + name: string, + output: output + } + + record resource-invoke-request { + token: string, + object: list, + results: list + } + + record resource-invoke-result { + fields: list + } + + invoke: func(request: resource-invoke-request) -> resource-invoke-result; +} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/world.wit b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/world.wit new file mode 100644 index 000000000..ea8780ea0 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/provider/wit/world.wit @@ -0,0 +1,30 @@ +package pulumi:example@1.0.0--0.0.0-DEV; + +world example-pulumi { + import component:pulumi-wasm/register-interface@0.0.0-DEV; + export example-server; +} + +world example-pulumi-client { + import example-server; +} + +interface example-server { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + map-array-enum: borrow, + } + + record res { + map-array-enum: output, + } + + invoke: func( + name: string, + args: args + ) -> res; + +} + diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/rust-toolchain.toml b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/rust-toolchain.toml new file mode 100644 index 000000000..7466ea07d --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.83.0" +targets = ["wasm32-wasip1"] \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/schema.json b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/schema.json new file mode 100644 index 000000000..8436068ed --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/schema.json @@ -0,0 +1,66 @@ +{ + "name": "example", + "version": "1.0.0", + "types":{ + "example:index:AnnotationStoreSchemaValueType": { + "type": "string", + "enum": [ + { + "name": "Long", + "value": "LONG" + }, + { + "name": "Int", + "value": "INT" + }, + { + "name": "String", + "value": "STRING" + }, + { + "name": "Float", + "value": "FLOAT" + }, + { + "name": "Double", + "value": "DOUBLE" + }, + { + "name": "Boolean", + "value": "BOOLEAN" + } + ] + } + }, + "resources": { + "example:index:ExampleServer": { + "properties":{ + "mapArrayEnum": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "$ref": "#/types/example:index:AnnotationStoreSchemaValueType" + } + } + } + }, + "inputProperties": { + "mapArrayEnum": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "$ref": "#/types/example:index:AnnotationStoreSchemaValueType" + } + } + } + } + } + }, + "language": { + "go": { + "importBasePath": "array-of-enum-map/example" + } + } +} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/output/azure-native-nested-types/schema.json b/pulumi_wasm_generator_lib/tests/output/azure-native-nested-types/schema.json new file mode 100644 index 000000000..a7514683d --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/azure-native-nested-types/schema.json @@ -0,0 +1,673 @@ +{ + "name": "azure-native", + "displayName": "Azure Native", + "description": "A native Pulumi package for creating and managing Azure resources.", + "keywords": [ + "pulumi", + "azure", + "azure-native", + "category/cloud", + "kind/native" + ], + "homepage": "https://pulumi.com", + "license": "Apache-2.0", + "repository": "https://github.com/pulumi/pulumi-azure-native", + "publisher": "Pulumi", + "types": { + "azure-native:documentdb:SqlContainerGetPropertiesResponseResource": { + "properties": { + "indexingPolicy": { + "type": "object", + "$ref": "#/types/azure-native:documentdb:IndexingPolicyResponse", + "description": "The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container" + } + }, + "type": "object" + }, + "azure-native:documentdb:IndexingPolicyResponse": { + "description": "Cosmos DB indexing policy", + "properties": { + "compositeIndexes": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/types/azure-native:documentdb:CompositePathResponse" + } + }, + "description": "List of composite path list" + } + }, + "type": "object" + }, + "azure-native:documentdb:CompositePathResponse": { + "properties": { + "order": { + "type": "string", + "description": "Sort order for composite paths." + }, + "path": { + "type": "string", + "description": "The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*)" + } + }, + "type": "object" + } + }, + "resources": { + "azure-native:documentdb:SqlResourceSqlContainer": { + "description": "An Azure Cosmos DB container.\nAPI Version: 2021-03-15.\n\n{{% examples %}}\n## Example Usage\n{{% example %}}\n### CosmosDBSqlContainerCreateUpdate\n```csharp\nusing Pulumi;\nusing AzureNative = Pulumi.AzureNative;\n\nclass MyStack : Stack\n{\n public MyStack()\n {\n var sqlResourceSqlContainer = new AzureNative.DocumentDB.SqlResourceSqlContainer(\"sqlResourceSqlContainer\", new AzureNative.DocumentDB.SqlResourceSqlContainerArgs\n {\n AccountName = \"ddb1\",\n ContainerName = \"containerName\",\n DatabaseName = \"databaseName\",\n Location = \"West US\",\n Options = ,\n Resource = new AzureNative.DocumentDB.Inputs.SqlContainerResourceArgs\n {\n ConflictResolutionPolicy = new AzureNative.DocumentDB.Inputs.ConflictResolutionPolicyArgs\n {\n ConflictResolutionPath = \"/path\",\n Mode = \"LastWriterWins\",\n },\n DefaultTtl = 100,\n Id = \"containerName\",\n IndexingPolicy = new AzureNative.DocumentDB.Inputs.IndexingPolicyArgs\n {\n Automatic = true,\n ExcludedPaths = {},\n IncludedPaths = \n {\n new AzureNative.DocumentDB.Inputs.IncludedPathArgs\n {\n Indexes = \n {\n new AzureNative.DocumentDB.Inputs.IndexesArgs\n {\n DataType = \"String\",\n Kind = \"Range\",\n Precision = -1,\n },\n new AzureNative.DocumentDB.Inputs.IndexesArgs\n {\n DataType = \"Number\",\n Kind = \"Range\",\n Precision = -1,\n },\n },\n Path = \"/*\",\n },\n },\n IndexingMode = \"consistent\",\n },\n PartitionKey = new AzureNative.DocumentDB.Inputs.ContainerPartitionKeyArgs\n {\n Kind = \"Hash\",\n Paths = \n {\n \"/AccountNumber\",\n },\n },\n UniqueKeyPolicy = new AzureNative.DocumentDB.Inputs.UniqueKeyPolicyArgs\n {\n UniqueKeys = \n {\n new AzureNative.DocumentDB.Inputs.UniqueKeyArgs\n {\n Paths = \n {\n \"/testPath\",\n },\n },\n },\n },\n },\n ResourceGroupName = \"rg1\",\n Tags = ,\n });\n }\n\n}\n\n```\n\n```go\npackage main\n\nimport (\n\tdocumentdb \"github.com/pulumi/pulumi-azure-native/sdk/go/azure/documentdb\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := documentdb.NewSqlResourceSqlContainer(ctx, \"sqlResourceSqlContainer\", \u0026documentdb.SqlResourceSqlContainerArgs{\n\t\t\tAccountName: pulumi.String(\"ddb1\"),\n\t\t\tContainerName: pulumi.String(\"containerName\"),\n\t\t\tDatabaseName: pulumi.String(\"databaseName\"),\n\t\t\tLocation: pulumi.String(\"West US\"),\n\t\t\tOptions: nil,\n\t\t\tResource: \u0026documentdb.SqlContainerResourceArgs{\n\t\t\t\tConflictResolutionPolicy: \u0026documentdb.ConflictResolutionPolicyArgs{\n\t\t\t\t\tConflictResolutionPath: pulumi.String(\"/path\"),\n\t\t\t\t\tMode: pulumi.String(\"LastWriterWins\"),\n\t\t\t\t},\n\t\t\t\tDefaultTtl: pulumi.Int(100),\n\t\t\t\tId: pulumi.String(\"containerName\"),\n\t\t\t\tIndexingPolicy: \u0026documentdb.IndexingPolicyArgs{\n\t\t\t\t\tAutomatic: pulumi.Bool(true),\n\t\t\t\t\tExcludedPaths: documentdb.ExcludedPathArray{},\n\t\t\t\t\tIncludedPaths: documentdb.IncludedPathArray{\n\t\t\t\t\t\t\u0026documentdb.IncludedPathArgs{\n\t\t\t\t\t\t\tIndexes: documentdb.IndexesArray{\n\t\t\t\t\t\t\t\t\u0026documentdb.IndexesArgs{\n\t\t\t\t\t\t\t\t\tDataType: pulumi.String(\"String\"),\n\t\t\t\t\t\t\t\t\tKind: pulumi.String(\"Range\"),\n\t\t\t\t\t\t\t\t\tPrecision: -1,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\u0026documentdb.IndexesArgs{\n\t\t\t\t\t\t\t\t\tDataType: pulumi.String(\"Number\"),\n\t\t\t\t\t\t\t\t\tKind: pulumi.String(\"Range\"),\n\t\t\t\t\t\t\t\t\tPrecision: -1,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tPath: pulumi.String(\"/*\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tIndexingMode: pulumi.String(\"consistent\"),\n\t\t\t\t},\n\t\t\t\tPartitionKey: \u0026documentdb.ContainerPartitionKeyArgs{\n\t\t\t\t\tKind: pulumi.String(\"Hash\"),\n\t\t\t\t\tPaths: pulumi.StringArray{\n\t\t\t\t\t\tpulumi.String(\"/AccountNumber\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tUniqueKeyPolicy: \u0026documentdb.UniqueKeyPolicyArgs{\n\t\t\t\t\tUniqueKeys: documentdb.UniqueKeyArray{\n\t\t\t\t\t\t\u0026documentdb.UniqueKeyArgs{\n\t\t\t\t\t\t\tPaths: pulumi.StringArray{\n\t\t\t\t\t\t\t\tpulumi.String(\"/testPath\"),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tResourceGroupName: pulumi.String(\"rg1\"),\n\t\t\tTags: nil,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n\n```\n\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as azure_native from \"@pulumi/azure-native\";\n\nconst sqlResourceSqlContainer = new azure_native.documentdb.SqlResourceSqlContainer(\"sqlResourceSqlContainer\", {\n accountName: \"ddb1\",\n containerName: \"containerName\",\n databaseName: \"databaseName\",\n location: \"West US\",\n options: {},\n resource: {\n conflictResolutionPolicy: {\n conflictResolutionPath: \"/path\",\n mode: \"LastWriterWins\",\n },\n defaultTtl: 100,\n id: \"containerName\",\n indexingPolicy: {\n automatic: true,\n excludedPaths: [],\n includedPaths: [{\n indexes: [\n {\n dataType: \"String\",\n kind: \"Range\",\n precision: -1,\n },\n {\n dataType: \"Number\",\n kind: \"Range\",\n precision: -1,\n },\n ],\n path: \"/*\",\n }],\n indexingMode: \"consistent\",\n },\n partitionKey: {\n kind: \"Hash\",\n paths: [\"/AccountNumber\"],\n },\n uniqueKeyPolicy: {\n uniqueKeys: [{\n paths: [\"/testPath\"],\n }],\n },\n },\n resourceGroupName: \"rg1\",\n tags: {},\n});\n\n```\n\n```python\nimport pulumi\nimport pulumi_azure_native as azure_native\n\nsql_resource_sql_container = azure_native.documentdb.SqlResourceSqlContainer(\"sqlResourceSqlContainer\",\n account_name=\"ddb1\",\n container_name=\"containerName\",\n database_name=\"databaseName\",\n location=\"West US\",\n options=azure_native.documentdb.CreateUpdateOptionsArgs(),\n resource=azure_native.documentdb.SqlContainerResourceArgs(\n conflict_resolution_policy=azure_native.documentdb.ConflictResolutionPolicyArgs(\n conflict_resolution_path=\"/path\",\n mode=\"LastWriterWins\",\n ),\n default_ttl=100,\n id=\"containerName\",\n indexing_policy=azure_native.documentdb.IndexingPolicyArgs(\n automatic=True,\n excluded_paths=[],\n included_paths=[azure_native.documentdb.IncludedPathArgs(\n indexes=[\n azure_native.documentdb.IndexesArgs(\n data_type=\"String\",\n kind=\"Range\",\n precision=-1,\n ),\n azure_native.documentdb.IndexesArgs(\n data_type=\"Number\",\n kind=\"Range\",\n precision=-1,\n ),\n ],\n path=\"/*\",\n )],\n indexing_mode=\"consistent\",\n ),\n partition_key=azure_native.documentdb.ContainerPartitionKeyArgs(\n kind=\"Hash\",\n paths=[\"/AccountNumber\"],\n ),\n unique_key_policy=azure_native.documentdb.UniqueKeyPolicyArgs(\n unique_keys=[azure_native.documentdb.UniqueKeyArgs(\n paths=[\"/testPath\"],\n )],\n ),\n ),\n resource_group_name=\"rg1\",\n tags={})\n\n```\n\n{{% /example %}}\n{{% /examples %}}\n\n## Import\n\nAn existing resource can be imported using its type token, name, and identifier, e.g.\n\n```sh\n$ pulumi import azure-native:documentdb:SqlResourceSqlContainer containerName /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/ddb1/sqlDatabases/databaseName/sqlContainers/containerName \n```\n", + "properties": { + "resource": { + "type": "object", + "$ref": "#/types/azure-native:documentdb:SqlContainerGetPropertiesResponseResource" + } + }, + "type": "object", + "inputProperties": { + } + } + }, + "language": { + "csharp": { + "namespaces": { + "aad": "Aad", + "aadiam": "AadIam", + "addons": "Addons", + "adhybridhealthservice": "ADHybridHealthService", + "advisor": "Advisor", + "agfoodplatform": "AgFoodPlatform", + "alertsmanagement": "AlertsManagement", + "analysisservices": "AnalysisServices", + "apimanagement": "ApiManagement", + "appconfiguration": "AppConfiguration", + "appplatform": "AppPlatform", + "attestation": "Attestation", + "authorization": "Authorization", + "automanage": "Automanage", + "automation": "Automation", + "autonomousdevelopmentplatform": "AutonomousDevelopmentPlatform", + "avs": "AVS", + "azure-native": "AzureNative", + "azureactivedirectory": "AzureActiveDirectory", + "azurearcdata": "AzureArcData", + "azuredata": "AzureData", + "azurestack": "AzureStack", + "azurestackhci": "AzureStackHCI", + "baremetalinfrastructure": "BareMetalInfrastructure", + "batch": "Batch", + "billing": "Billing", + "blockchain": "Blockchain", + "blueprint": "Blueprint", + "botservice": "BotService", + "cache": "Cache", + "capacity": "Capacity", + "cdn": "Cdn", + "certificateregistration": "CertificateRegistration", + "changeanalysis": "ChangeAnalysis", + "chaos": "Chaos", + "cognitiveservices": "CognitiveServices", + "commerce": "Commerce", + "communication": "Communication", + "compute": "Compute", + "confidentialledger": "ConfidentialLedger", + "confluent": "Confluent", + "connectedvmwarevsphere": "ConnectedVMwarevSphere", + "consumption": "Consumption", + "containerinstance": "ContainerInstance", + "containerregistry": "ContainerRegistry", + "containerservice": "ContainerService", + "costmanagement": "CostManagement", + "customerinsights": "CustomerInsights", + "customerlockbox": "CustomerLockbox", + "customproviders": "CustomProviders", + "databox": "DataBox", + "databoxedge": "DataBoxEdge", + "databricks": "Databricks", + "datacatalog": "DataCatalog", + "datadog": "Datadog", + "datafactory": "DataFactory", + "datalakeanalytics": "DataLakeAnalytics", + "datalakestore": "DataLakeStore", + "datamigration": "DataMigration", + "dataprotection": "DataProtection", + "datashare": "DataShare", + "dbformariadb": "DBforMariaDB", + "dbformysql": "DBforMySQL", + "dbforpostgresql": "DBforPostgreSQL", + "delegatednetwork": "DelegatedNetwork", + "deploymentmanager": "DeploymentManager", + "desktopvirtualization": "DesktopVirtualization", + "devices": "Devices", + "deviceupdate": "DeviceUpdate", + "devops": "DevOps", + "devspaces": "DevSpaces", + "devtestlab": "DevTestLab", + "digitaltwins": "DigitalTwins", + "documentdb": "DocumentDB", + "domainregistration": "DomainRegistration", + "dynamics365fraudprotection": "Dynamics365Fraudprotection", + "dynamicstelemetry": "DynamicsTelemetry", + "edgeorder": "EdgeOrder", + "edgeorderpartner": "EdgeOrderPartner", + "elastic": "Elastic", + "engagementfabric": "EngagementFabric", + "enterpriseknowledgegraph": "EnterpriseKnowledgeGraph", + "eventgrid": "EventGrid", + "eventhub": "EventHub", + "extendedlocation": "ExtendedLocation", + "features": "Features", + "fluidrelay": "FluidRelay", + "guestconfiguration": "GuestConfiguration", + "hanaonazure": "HanaOnAzure", + "hardwaresecuritymodules": "HardwareSecurityModules", + "hdinsight": "HDInsight", + "healthbot": "HealthBot", + "healthcareapis": "HealthcareApis", + "hybridcompute": "HybridCompute", + "hybridconnectivity": "HybridConnectivity", + "hybriddata": "HybridData", + "hybridnetwork": "HybridNetwork", + "importexport": "ImportExport", + "insights": "Insights", + "intune": "Intune", + "iotcentral": "IoTCentral", + "iotsecurity": "IoTSecurity", + "keyvault": "KeyVault", + "kubernetes": "Kubernetes", + "kubernetesconfiguration": "KubernetesConfiguration", + "kusto": "Kusto", + "labservices": "LabServices", + "loadtestservice": "LoadTestService", + "logic": "Logic", + "logz": "Logz", + "m365securityandcompliance": "M365SecurityAndCompliance", + "machinelearning": "MachineLearning", + "machinelearningcompute": "MachineLearningCompute", + "machinelearningexperimentation": "MachineLearningExperimentation", + "machinelearningservices": "MachineLearningServices", + "maintenance": "Maintenance", + "managedidentity": "ManagedIdentity", + "managednetwork": "ManagedNetwork", + "managedservices": "ManagedServices", + "management": "Management", + "managementpartner": "ManagementPartner", + "maps": "Maps", + "marketplace": "Marketplace", + "marketplacenotifications": "MarketplaceNotifications", + "marketplaceordering": "MarketplaceOrdering", + "media": "Media", + "migrate": "Migrate", + "mixedreality": "MixedReality", + "netapp": "NetApp", + "network": "Network", + "notebooks": "Notebooks", + "notificationhubs": "NotificationHubs", + "offazure": "OffAzure", + "operationalinsights": "OperationalInsights", + "operationsmanagement": "OperationsManagement", + "orbital": "Orbital", + "peering": "Peering", + "policyinsights": "PolicyInsights", + "portal": "Portal", + "powerbi": "PowerBI", + "powerbidedicated": "PowerBIDedicated", + "powerplatform": "PowerPlatform", + "providerhub": "ProviderHub", + "purview": "Purview", + "quantum": "Quantum", + "quota": "Quota", + "recoveryservices": "RecoveryServices", + "redhatopenshift": "RedHatOpenShift", + "relay": "Relay", + "resourceconnector": "ResourceConnector", + "resourcegraph": "ResourceGraph", + "resourcehealth": "ResourceHealth", + "resources": "Resources", + "saas": "SaaS", + "scheduler": "Scheduler", + "search": "Search", + "security": "Security", + "securityandcompliance": "SecurityAndCompliance", + "securityinsights": "SecurityInsights", + "serialconsole": "SerialConsole", + "servicebus": "ServiceBus", + "servicefabric": "ServiceFabric", + "servicefabricmesh": "ServiceFabricMesh", + "servicelinker": "ServiceLinker", + "signalrservice": "SignalRService", + "softwareplan": "SoftwarePlan", + "solutions": "Solutions", + "sql": "Sql", + "sqlvirtualmachine": "SqlVirtualMachine", + "storage": "Storage", + "storagecache": "StorageCache", + "storagepool": "StoragePool", + "storagesync": "StorageSync", + "storsimple": "StorSimple", + "streamanalytics": "StreamAnalytics", + "subscription": "Subscription", + "support": "Support", + "synapse": "Synapse", + "testbase": "TestBase", + "timeseriesinsights": "TimeSeriesInsights", + "videoanalyzer": "VideoAnalyzer", + "videoindexer": "VideoIndexer", + "virtualmachineimages": "VirtualMachineImages", + "visualstudio": "VisualStudio", + "vmwarecloudsimple": "VMwareCloudSimple", + "web": "Web", + "webpubsub": "WebPubSub", + "windowsesu": "WindowsESU", + "windowsiot": "WindowsIoT", + "workloadmonitor": "WorkloadMonitor" + }, + "packageReferences": { + "System.Collections.Immutable": "5.0.0" + } + }, + "go": { + "disableFunctionOutputVersions": true, + "disableInputTypeRegistrations": true, + "generateResourceContainerTypes": false, + "importBasePath": "github.com/pulumi/pulumi-azure-native/sdk/go/azure", + "packageImportAliases": { + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/aad": "aad", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/aadiam": "aadiam", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/addons": "addons", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/adhybridhealthservice": "adhybridhealthservice", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/advisor": "advisor", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/agfoodplatform": "agfoodplatform", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/alertsmanagement": "alertsmanagement", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/analysisservices": "analysisservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/apimanagement": "apimanagement", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/appconfiguration": "appconfiguration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/appplatform": "appplatform", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/attestation": "attestation", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/authorization": "authorization", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/automanage": "automanage", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/automation": "automation", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/autonomousdevelopmentplatform": "autonomousdevelopmentplatform", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/avs": "avs", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/azureactivedirectory": "azureactivedirectory", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/azurearcdata": "azurearcdata", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/azuredata": "azuredata", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/azurestack": "azurestack", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/azurestackhci": "azurestackhci", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/baremetalinfrastructure": "baremetalinfrastructure", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/batch": "batch", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/billing": "billing", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/blockchain": "blockchain", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/blueprint": "blueprint", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/botservice": "botservice", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/cache": "cache", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/capacity": "capacity", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/cdn": "cdn", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/certificateregistration": "certificateregistration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/changeanalysis": "changeanalysis", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/chaos": "chaos", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/cognitiveservices": "cognitiveservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/commerce": "commerce", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/communication": "communication", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/compute": "compute", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/confidentialledger": "confidentialledger", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/confluent": "confluent", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/connectedvmwarevsphere": "connectedvmwarevsphere", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/consumption": "consumption", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerinstance": "containerinstance", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerregistry": "containerregistry", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerservice": "containerservice", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/costmanagement": "costmanagement", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/customerinsights": "customerinsights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/customerlockbox": "customerlockbox", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/customproviders": "customproviders", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/databox": "databox", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/databoxedge": "databoxedge", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/databricks": "databricks", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datacatalog": "datacatalog", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datadog": "datadog", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datafactory": "datafactory", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datalakeanalytics": "datalakeanalytics", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datalakestore": "datalakestore", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datamigration": "datamigration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dataprotection": "dataprotection", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/datashare": "datashare", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dbformariadb": "dbformariadb", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dbformysql": "dbformysql", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dbforpostgresql": "dbforpostgresql", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/delegatednetwork": "delegatednetwork", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/deploymentmanager": "deploymentmanager", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/desktopvirtualization": "desktopvirtualization", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/devices": "devices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/deviceupdate": "deviceupdate", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/devops": "devops", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/devspaces": "devspaces", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/devtestlab": "devtestlab", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/digitaltwins": "digitaltwins", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/documentdb": "documentdb", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/domainregistration": "domainregistration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dynamics365fraudprotection": "dynamics365fraudprotection", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/dynamicstelemetry": "dynamicstelemetry", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/edgeorder": "edgeorder", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/edgeorderpartner": "edgeorderpartner", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/elastic": "elastic", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/engagementfabric": "engagementfabric", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/enterpriseknowledgegraph": "enterpriseknowledgegraph", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/eventgrid": "eventgrid", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/eventhub": "eventhub", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/extendedlocation": "extendedlocation", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/features": "features", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/fluidrelay": "fluidrelay", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/guestconfiguration": "guestconfiguration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hanaonazure": "hanaonazure", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hardwaresecuritymodules": "hardwaresecuritymodules", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hdinsight": "hdinsight", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/healthbot": "healthbot", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/healthcareapis": "healthcareapis", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hybridcompute": "hybridcompute", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hybridconnectivity": "hybridconnectivity", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hybriddata": "hybriddata", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/hybridnetwork": "hybridnetwork", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/importexport": "importexport", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/insights": "insights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/intune": "intune", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/iotcentral": "iotcentral", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/iotsecurity": "iotsecurity", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/keyvault": "keyvault", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/kubernetes": "kubernetes", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/kubernetesconfiguration": "kubernetesconfiguration", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/kusto": "kusto", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/labservices": "labservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/loadtestservice": "loadtestservice", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/logic": "logic", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/logz": "logz", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/m365securityandcompliance": "m365securityandcompliance", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/machinelearning": "machinelearning", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/machinelearningcompute": "machinelearningcompute", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/machinelearningexperimentation": "machinelearningexperimentation", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/machinelearningservices": "machinelearningservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/maintenance": "maintenance", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/managedidentity": "managedidentity", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/managednetwork": "managednetwork", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/managedservices": "managedservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/management": "management", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/managementpartner": "managementpartner", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/maps": "maps", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/marketplace": "marketplace", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/marketplacenotifications": "marketplacenotifications", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/marketplaceordering": "marketplaceordering", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/media": "media", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/migrate": "migrate", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/mixedreality": "mixedreality", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/netapp": "netapp", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/network": "network", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/notebooks": "notebooks", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/notificationhubs": "notificationhubs", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/offazure": "offazure", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/operationalinsights": "operationalinsights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/operationsmanagement": "operationsmanagement", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/orbital": "orbital", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/peering": "peering", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/policyinsights": "policyinsights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/portal": "portal", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/powerbi": "powerbi", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/powerbidedicated": "powerbidedicated", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/powerplatform": "powerplatform", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/providerhub": "providerhub", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/purview": "purview", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/quantum": "quantum", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/quota": "quota", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/recoveryservices": "recoveryservices", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/redhatopenshift": "redhatopenshift", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/relay": "relay", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/resourceconnector": "resourceconnector", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/resourcegraph": "resourcegraph", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/resourcehealth": "resourcehealth", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/resources": "resources", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/saas": "saas", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/scheduler": "scheduler", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/search": "search", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/security": "security", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/securityandcompliance": "securityandcompliance", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/securityinsights": "securityinsights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/serialconsole": "serialconsole", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/servicebus": "servicebus", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/servicefabric": "servicefabric", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/servicefabricmesh": "servicefabricmesh", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/servicelinker": "servicelinker", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/signalrservice": "signalrservice", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/softwareplan": "softwareplan", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/solutions": "solutions", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/sql": "sql", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/sqlvirtualmachine": "sqlvirtualmachine", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storage": "storage", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storagecache": "storagecache", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storagepool": "storagepool", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storagesync": "storagesync", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storsimple": "storsimple", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/streamanalytics": "streamanalytics", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/subscription": "subscription", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/support": "support", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/synapse": "synapse", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/testbase": "testbase", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/timeseriesinsights": "timeseriesinsights", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/videoanalyzer": "videoanalyzer", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/videoindexer": "videoindexer", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/virtualmachineimages": "virtualmachineimages", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/visualstudio": "visualstudio", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/vmwarecloudsimple": "vmwarecloudsimple", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/web": "web", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/webpubsub": "webpubsub", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/windowsesu": "windowsesu", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/windowsiot": "windowsiot", + "github.com/pulumi/pulumi-azure-native/sdk/go/azure/workloadmonitor": "workloadmonitor" + } + }, + "nodejs": { + "optimizeNodeModuleLoading": ["lazy-load-functions", "lazy-load-resources", "use-type-only-enums-references"], + "dependencies": { + "@pulumi/pulumi": "^3.0.0" + }, + "readme": "The native Azure provider package offers support for all Azure Resource Manager (ARM)\nresources and their properties. Resources are exposed as types from modules based on Azure Resource\nProviders such as 'compute', 'network', 'storage', and 'web', among many others. Using this package\nallows you to programmatically declare instances of any Azure resource and any supported resource\nversion using infrastructure as code, which Pulumi then uses to drive the ARM API." + }, + "python": { + "moduleNameOverrides": { + "aad": "aad", + "aadiam": "aadiam", + "addons": "addons", + "adhybridhealthservice": "adhybridhealthservice", + "advisor": "advisor", + "agfoodplatform": "agfoodplatform", + "alertsmanagement": "alertsmanagement", + "analysisservices": "analysisservices", + "apimanagement": "apimanagement", + "appconfiguration": "appconfiguration", + "appplatform": "appplatform", + "attestation": "attestation", + "authorization": "authorization", + "automanage": "automanage", + "automation": "automation", + "autonomousdevelopmentplatform": "autonomousdevelopmentplatform", + "avs": "avs", + "azureactivedirectory": "azureactivedirectory", + "azurearcdata": "azurearcdata", + "azuredata": "azuredata", + "azurestack": "azurestack", + "azurestackhci": "azurestackhci", + "baremetalinfrastructure": "baremetalinfrastructure", + "batch": "batch", + "billing": "billing", + "blockchain": "blockchain", + "blueprint": "blueprint", + "botservice": "botservice", + "cache": "cache", + "capacity": "capacity", + "cdn": "cdn", + "certificateregistration": "certificateregistration", + "changeanalysis": "changeanalysis", + "chaos": "chaos", + "cognitiveservices": "cognitiveservices", + "commerce": "commerce", + "communication": "communication", + "compute": "compute", + "confidentialledger": "confidentialledger", + "confluent": "confluent", + "connectedvmwarevsphere": "connectedvmwarevsphere", + "consumption": "consumption", + "containerinstance": "containerinstance", + "containerregistry": "containerregistry", + "containerservice": "containerservice", + "costmanagement": "costmanagement", + "customerinsights": "customerinsights", + "customerlockbox": "customerlockbox", + "customproviders": "customproviders", + "databox": "databox", + "databoxedge": "databoxedge", + "databricks": "databricks", + "datacatalog": "datacatalog", + "datadog": "datadog", + "datafactory": "datafactory", + "datalakeanalytics": "datalakeanalytics", + "datalakestore": "datalakestore", + "datamigration": "datamigration", + "dataprotection": "dataprotection", + "datashare": "datashare", + "dbformariadb": "dbformariadb", + "dbformysql": "dbformysql", + "dbforpostgresql": "dbforpostgresql", + "delegatednetwork": "delegatednetwork", + "deploymentmanager": "deploymentmanager", + "desktopvirtualization": "desktopvirtualization", + "devices": "devices", + "deviceupdate": "deviceupdate", + "devops": "devops", + "devspaces": "devspaces", + "devtestlab": "devtestlab", + "digitaltwins": "digitaltwins", + "documentdb": "documentdb", + "domainregistration": "domainregistration", + "dynamics365fraudprotection": "dynamics365fraudprotection", + "dynamicstelemetry": "dynamicstelemetry", + "edgeorder": "edgeorder", + "edgeorderpartner": "edgeorderpartner", + "elastic": "elastic", + "engagementfabric": "engagementfabric", + "enterpriseknowledgegraph": "enterpriseknowledgegraph", + "eventgrid": "eventgrid", + "eventhub": "eventhub", + "extendedlocation": "extendedlocation", + "features": "features", + "fluidrelay": "fluidrelay", + "guestconfiguration": "guestconfiguration", + "hanaonazure": "hanaonazure", + "hardwaresecuritymodules": "hardwaresecuritymodules", + "hdinsight": "hdinsight", + "healthbot": "healthbot", + "healthcareapis": "healthcareapis", + "hybridcompute": "hybridcompute", + "hybridconnectivity": "hybridconnectivity", + "hybriddata": "hybriddata", + "hybridnetwork": "hybridnetwork", + "importexport": "importexport", + "insights": "insights", + "intune": "intune", + "iotcentral": "iotcentral", + "iotsecurity": "iotsecurity", + "keyvault": "keyvault", + "kubernetes": "kubernetes", + "kubernetesconfiguration": "kubernetesconfiguration", + "kusto": "kusto", + "labservices": "labservices", + "loadtestservice": "loadtestservice", + "logic": "logic", + "logz": "logz", + "m365securityandcompliance": "m365securityandcompliance", + "machinelearning": "machinelearning", + "machinelearningcompute": "machinelearningcompute", + "machinelearningexperimentation": "machinelearningexperimentation", + "machinelearningservices": "machinelearningservices", + "maintenance": "maintenance", + "managedidentity": "managedidentity", + "managednetwork": "managednetwork", + "managedservices": "managedservices", + "management": "management", + "managementpartner": "managementpartner", + "maps": "maps", + "marketplace": "marketplace", + "marketplacenotifications": "marketplacenotifications", + "marketplaceordering": "marketplaceordering", + "media": "media", + "migrate": "migrate", + "mixedreality": "mixedreality", + "netapp": "netapp", + "network": "network", + "notebooks": "notebooks", + "notificationhubs": "notificationhubs", + "offazure": "offazure", + "operationalinsights": "operationalinsights", + "operationsmanagement": "operationsmanagement", + "orbital": "orbital", + "peering": "peering", + "policyinsights": "policyinsights", + "portal": "portal", + "powerbi": "powerbi", + "powerbidedicated": "powerbidedicated", + "powerplatform": "powerplatform", + "providerhub": "providerhub", + "purview": "purview", + "quantum": "quantum", + "quota": "quota", + "recoveryservices": "recoveryservices", + "redhatopenshift": "redhatopenshift", + "relay": "relay", + "resourceconnector": "resourceconnector", + "resourcegraph": "resourcegraph", + "resourcehealth": "resourcehealth", + "resources": "resources", + "saas": "saas", + "scheduler": "scheduler", + "search": "search", + "security": "security", + "securityandcompliance": "securityandcompliance", + "securityinsights": "securityinsights", + "serialconsole": "serialconsole", + "servicebus": "servicebus", + "servicefabric": "servicefabric", + "servicefabricmesh": "servicefabricmesh", + "servicelinker": "servicelinker", + "signalrservice": "signalrservice", + "softwareplan": "softwareplan", + "solutions": "solutions", + "sql": "sql", + "sqlvirtualmachine": "sqlvirtualmachine", + "storage": "storage", + "storagecache": "storagecache", + "storagepool": "storagepool", + "storagesync": "storagesync", + "storsimple": "storsimple", + "streamanalytics": "streamanalytics", + "subscription": "subscription", + "support": "support", + "synapse": "synapse", + "testbase": "testbase", + "timeseriesinsights": "timeseriesinsights", + "videoanalyzer": "videoanalyzer", + "videoindexer": "videoindexer", + "virtualmachineimages": "virtualmachineimages", + "visualstudio": "visualstudio", + "vmwarecloudsimple": "vmwarecloudsimple", + "web": "web", + "webpubsub": "webpubsub", + "windowsesu": "windowsesu", + "windowsiot": "windowsiot", + "workloadmonitor": "workloadmonitor" + }, + "readme": "The native Azure provider package offers support for all Azure Resource Manager (ARM)\nresources and their properties. Resources are exposed as types from modules based on Azure Resource\nProviders such as 'compute', 'network', 'storage', and 'web', among many others. Using this package\nallows you to programmatically declare instances of any Azure resource and any supported resource\nversion using infrastructure as code, which Pulumi then uses to drive the ARM API.", + "requires": { + "pulumi": "\u003e=3.0.0,\u003c4.0.0" + }, + "usesIOClasses": true + } + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/different-enum/Cargo.toml new file mode 100644 index 000000000..10895020d --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "main" +version = "0.0.1" +edition = "2021" + +[workspace] +members = [ + "provider", + "lib" +] + +[workspace.dependencies] +wit-bindgen-rt = "0.33.0" +wit-bindgen = "0.33.0" +automod = "1.0.14" +pulumi_wasm_common = { path = "../../../../pulumi_wasm_common" } +pulumi_wasm_rust = { path = "../../../../pulumi_wasm_rust" } +pulumi_wasm_wit = { path = "../../../../pulumi_wasm_wit" } +pulumi_wasm_provider_common = { path = "../../../../pulumi_wasm_provider_common" } +serde = "1.0.197" +bon = "2.2.1" \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/Cargo.toml new file mode 100644 index 000000000..73aaa00e4 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pulumi_wasm_plant" +version = "0.0.1-0.0.0-DEV" +edition = "2021" + +[dependencies] +wit-bindgen.workspace = true +pulumi_wasm_rust.workspace = true +serde.workspace = true +pulumi_wasm_wit = { workspace = true, features = ["client"] } +bon.workspace = true +pulumi_wasm_provider_common.workspace = true diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs new file mode 100644 index 000000000..b11cc0671 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs @@ -0,0 +1,22 @@ +use pulumi_wasm_rust::Output; +use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface::Output as WitOutput; +#[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] +mod resource; +pub use resource::*; +#[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] +mod types; +pub use types::*; + +mod bindings { + wit_bindgen::generate!({ + // the name of the world in the `*.wit` input file + world: "plant-pulumi-client", + with: { + "component:pulumi-wasm/output-interface@0.0.0-DEV": pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface + } + }); +} + +fn into_domain(output: WitOutput) -> Output { + unsafe { Output::::new_from_handle(output) } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs new file mode 100644 index 000000000..d572521a1 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs @@ -0,0 +1,2 @@ +pub mod tree_nursery; +pub mod tree_rubber_tree; diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs new file mode 100644 index 000000000..70d9abaf3 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs @@ -0,0 +1,28 @@ + +#[derive(bon::Builder, Clone)] +#[builder(finish_fn = build_struct)] +pub struct NurseryArgs { + /// The sizes of trees available + #[builder(into, default)] + pub sizes: pulumi_wasm_rust::Output>>, + /// The varieties available + #[builder(into)] + pub varieties: pulumi_wasm_rust::Output>, +} + +pub struct NurseryResult { +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn create(name: &str, args: NurseryArgs) -> NurseryResult { + + let result = crate::bindings::pulumi::plant::tree_nursery::invoke(name, &crate::bindings::pulumi::plant::tree_nursery::Args { + sizes: &args.sizes.get_inner(), + varieties: &args.varieties.get_inner(), + }); + + NurseryResult { + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs new file mode 100644 index 000000000..324864a25 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs @@ -0,0 +1,45 @@ + +#[derive(bon::Builder, Clone)] +#[builder(finish_fn = build_struct)] +pub struct RubberTreeArgs { + #[builder(into, default)] + pub container: pulumi_wasm_rust::Output>, + #[builder(into)] + pub diameter: pulumi_wasm_rust::Output, + #[builder(into, default)] + pub farm: pulumi_wasm_rust::Output>>, + #[builder(into, default)] + pub size: pulumi_wasm_rust::Output>, + #[builder(into)] + pub type_: pulumi_wasm_rust::Output, +} + +pub struct RubberTreeResult { + pub container: pulumi_wasm_rust::Output>, + pub diameter: pulumi_wasm_rust::Output, + pub farm: pulumi_wasm_rust::Output>>, + pub size: pulumi_wasm_rust::Output>, + pub type_: pulumi_wasm_rust::Output, +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn create(name: &str, args: RubberTreeArgs) -> RubberTreeResult { + + let result = crate::bindings::pulumi::plant::tree_rubber_tree::invoke(name, &crate::bindings::pulumi::plant::tree_rubber_tree::Args { + container: &args.container.get_inner(), + diameter: &args.diameter.get_inner(), + farm: &args.farm.get_inner(), + size: &args.size.get_inner(), + type_: &args.type_.get_inner(), + }); + + RubberTreeResult { + container: crate::into_domain(result.container), + diameter: crate::into_domain(result.diameter), + farm: crate::into_domain(result.farm), + size: crate::into_domain(result.size), + type_: crate::into_domain(result.type_), + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/cloud_audit_options_log_name.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/cloud_audit_options_log_name.rs new file mode 100644 index 000000000..1e9cbc2a3 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/cloud_audit_options_log_name.rs @@ -0,0 +1,17 @@ +//! The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913 + +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum CloudAuditOptionsLogName { + /// Default. Should not be used. + #[serde(rename = "UNSPECIFIED_LOG_NAME")] + UnspecifiedLogName, + /// Corresponds to "cloudaudit.googleapis.com/activity" + #[serde(rename = "ADMIN_ACTIVITY")] + AdminActivity, + /// Corresponds to "cloudaudit.googleapis.com/data_access" + #[serde(rename = "DATA_ACCESS")] + DataAccess, + /// What if triple quotes """ are used in the description + #[serde(rename = "SYNTHETIC")] + Synthetic, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container.rs new file mode 100644 index 000000000..254fbf765 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container.rs @@ -0,0 +1,16 @@ +#[derive(serde::Deserialize, serde::Serialize, bon::Builder, Debug, PartialEq, Clone)] +#[builder(finish_fn = build_struct)] +pub struct Container { + #[builder(into, default)] + #[serde(rename = "brightness")] + pub r#brightness: Box>, + #[builder(into, default)] + #[serde(rename = "color")] + pub r#color: Box>>, + #[builder(into, default)] + #[serde(rename = "material")] + pub r#material: Box>, + #[builder(into)] + #[serde(rename = "size")] + pub r#size: Box, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_brightness.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_brightness.rs new file mode 100644 index 000000000..3284c8c7a --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_brightness.rs @@ -0,0 +1,32 @@ +#[derive(Debug, PartialEq, Clone)] +pub enum ContainerBrightness { + ZeroPointOne, + One, +} + +impl serde::Serialize for ContainerBrightness { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + ContainerBrightness::ZeroPointOne => 0.1, + ContainerBrightness::One => 1.0, + }; + serializer.serialize_f64(value) + } +} + +impl<'de> serde::Deserialize<'de> for ContainerBrightness { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = f64::deserialize(deserializer)?; + match f { + 0.1 => Ok(ContainerBrightness::ZeroPointOne), + 1.0 => Ok(ContainerBrightness::One), + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_color.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_color.rs new file mode 100644 index 000000000..2bb5b3a5b --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_color.rs @@ -0,0 +1,11 @@ +//! plant container colors + +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum ContainerColor { + #[serde(rename = "red")] + Red, + #[serde(rename = "blue")] + Blue, + #[serde(rename = "yellow")] + Yellow, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_size.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_size.rs new file mode 100644 index 000000000..89d41e430 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/container_size.rs @@ -0,0 +1,37 @@ +//! plant container sizes + +#[derive(Debug, PartialEq, Clone)] +pub enum ContainerSize { + FourInch, + SixInch, + EightInch, +} + +impl serde::Serialize for ContainerSize { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + ContainerSize::FourInch => 4, + ContainerSize::SixInch => 6, + ContainerSize::EightInch => 8, + }; + serializer.serialize_i64(value) + } +} + +impl<'de> serde::Deserialize<'de> for ContainerSize { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = i64::deserialize(deserializer)?; + match f { + 4 => Ok(ContainerSize::FourInch), + 6 => Ok(ContainerSize::SixInch), + 8 => Ok(ContainerSize::EightInch), + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/diameter.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/diameter.rs new file mode 100644 index 000000000..8e1a580fb --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/diameter.rs @@ -0,0 +1,32 @@ +#[derive(Debug, PartialEq, Clone)] +pub enum Diameter { + sixinch, + twelveinch, +} + +impl serde::Serialize for Diameter { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let value = match self { + Diameter::sixinch => 6.0, + Diameter::twelveinch => 12.0, + }; + serializer.serialize_f64(value) + } +} + +impl<'de> serde::Deserialize<'de> for Diameter { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let f = f64::deserialize(deserializer)?; + match f { + 6.0 => Ok(Diameter::sixinch), + 12.0 => Ok(Diameter::twelveinch), + _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), + } + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/farm.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/farm.rs new file mode 100644 index 000000000..69d04ea31 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/farm.rs @@ -0,0 +1,7 @@ +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum Farm { + #[serde(rename = "Pulumi Planters Inc.")] + PulumiPlantersInc, + #[serde(rename = "Plants'R'Us")] + PlantsRUs, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/mod.rs new file mode 100644 index 000000000..d826605e7 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/mod.rs @@ -0,0 +1,19 @@ +mod cloud_audit_options_log_name; +pub use cloud_audit_options_log_name::*; +mod container; +pub use container::*; +mod container_brightness; +pub use container_brightness::*; +mod container_color; +pub use container_color::*; +mod container_size; +pub use container_size::*; +mod diameter; +pub use diameter::*; +mod farm; +pub use farm::*; +mod rubber_tree_variety; +pub use rubber_tree_variety::*; +mod tree_size; +pub use tree_size::*; + diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/rubber_tree_variety.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/rubber_tree_variety.rs new file mode 100644 index 000000000..39491e530 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/rubber_tree_variety.rs @@ -0,0 +1,11 @@ +//! types of rubber trees + +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum RubberTreeVariety { + /// A burgundy rubber tree. + Burgundy, + /// A ruby rubber tree. + Ruby, + /// A tineke rubber tree. + Tineke, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree_size.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree_size.rs new file mode 100644 index 000000000..f6908d0d7 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree_size.rs @@ -0,0 +1,9 @@ +#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] +pub enum TreeSize { + #[serde(rename = "small")] + Small, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "large")] + Large, +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/deps/pulumi-wasm.wit b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/deps/pulumi-wasm.wit new file mode 100644 index 000000000..d41010180 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/deps/pulumi-wasm.wit @@ -0,0 +1,59 @@ +package component:pulumi-wasm@0.0.0-DEV; + +interface output-interface { + + resource output { + constructor(value: string); + map: func(function-name: string) -> output; + } + combine: func(outputs: list>) -> output; +} + + +interface register-interface { + use output-interface.{output}; + + record object-field { + name: string, + value: borrow + } + + record result-field { + name: string + } + + record register-resource-result-field { + name: string, + output: output + } + + record register-resource-request { + %type: string, + name: string, + object: list, + results: list + } + + record register-resource-result { + fields: list + } + + register: func(request: register-resource-request) -> register-resource-result; + + record resource-invoke-result-field { + name: string, + output: output + } + + record resource-invoke-request { + token: string, + object: list, + results: list + } + + record resource-invoke-result { + fields: list + } + + invoke: func(request: resource-invoke-request) -> resource-invoke-result; +} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/world.wit b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/world.wit new file mode 100644 index 000000000..6137f6586 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/wit/world.wit @@ -0,0 +1,56 @@ +package pulumi:plant@0.0.1--0.0.0-DEV; + +world plant-pulumi { + import component:pulumi-wasm/register-interface@0.0.0-DEV; + export tree-nursery; + export tree-rubber-tree; +} + +world plant-pulumi-client { + import tree-nursery; + import tree-rubber-tree; +} + +interface tree-nursery { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + sizes: borrow, + varieties: borrow, + } + + + invoke: func( + name: string, + args: args + ); + +} +interface tree-rubber-tree { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + container: borrow, + diameter: borrow, + farm: borrow, + size: borrow, + %type: borrow, + } + + record res { + container: output, + diameter: output, + farm: output, + size: output, + %type: output, + } + + invoke: func( + name: string, + args: args + ) -> res; + +} + diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/Cargo.toml b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/Cargo.toml new file mode 100644 index 000000000..72634517c --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "pulumi_wasm_plant_provider" +version = "0.0.1-0.0.0-DEV" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wit-bindgen-rt.workspace = true +pulumi_wasm_common.workspace = true + +[package.metadata.component] +package = "pulumi:plant" + +[package.metadata.component.target] +path = "wit" +world = "plant-pulumi" + +[package.metadata.component.target.dependencies] +"component:pulumi-wasm" = { path = "wit/deps/pulumi-wasm.wit" } diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/function/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/lib.rs new file mode 100644 index 000000000..b7a2350e1 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/lib.rs @@ -0,0 +1,9 @@ +mod resource; + +#[allow(unused_braces)] +#[allow(unused_imports)] +#[allow(static_mut_refs)] +mod bindings; +bindings::export!(Component with_types_in bindings); + +struct Component {} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/mod.rs new file mode 100644 index 000000000..d572521a1 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/mod.rs @@ -0,0 +1,2 @@ +pub mod tree_nursery; +pub mod tree_rubber_tree; diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs new file mode 100644 index 000000000..b9a225824 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs @@ -0,0 +1,26 @@ +use std::collections::HashMap; +use crate::bindings::exports::pulumi::plant::tree_nursery; +use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; +use crate::Component; + +impl tree_nursery::Guest for Component { + fn invoke(name: String, args: tree_nursery::Args) { + pulumi_wasm_common::setup_logger(); + let request = RegisterResourceRequest { + type_: "plant:tree/v1:Nursery".into(), + name, + object: vec![ + ObjectField { name: "sizes".into(), value: args.sizes }, + ObjectField { name: "varieties".into(), value: args.varieties }, + ], + results: vec![ + ], + }; + + let o = register(&request); + + let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); + + + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs new file mode 100644 index 000000000..9226520df --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs @@ -0,0 +1,41 @@ +use std::collections::HashMap; +use crate::bindings::exports::pulumi::plant::tree_rubber_tree; +use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; +use crate::Component; + +impl tree_rubber_tree::Guest for Component { + fn invoke(name: String, args: tree_rubber_tree::Args) -> tree_rubber_tree::Res { + pulumi_wasm_common::setup_logger(); + let request = RegisterResourceRequest { + type_: "plant:tree/v1:RubberTree".into(), + name, + object: vec![ + ObjectField { name: "container".into(), value: args.container }, + ObjectField { name: "diameter".into(), value: args.diameter }, + ObjectField { name: "farm".into(), value: args.farm }, + ObjectField { name: "size".into(), value: args.size }, + ObjectField { name: "type".into(), value: args.type_ }, + ], + results: vec![ + ResultField { name: "container".into() }, + ResultField { name: "diameter".into() }, + ResultField { name: "farm".into() }, + ResultField { name: "size".into() }, + ResultField { name: "type".into() }, + ], + }; + + let o = register(&request); + + let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); + + tree_rubber_tree::Res { + container: hashmap.remove("container").unwrap(), + diameter: hashmap.remove("diameter").unwrap(), + farm: hashmap.remove("farm").unwrap(), + size: hashmap.remove("size").unwrap(), + type_: hashmap.remove("type").unwrap(), + } + + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/deps/pulumi-wasm.wit b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/deps/pulumi-wasm.wit new file mode 100644 index 000000000..d41010180 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/deps/pulumi-wasm.wit @@ -0,0 +1,59 @@ +package component:pulumi-wasm@0.0.0-DEV; + +interface output-interface { + + resource output { + constructor(value: string); + map: func(function-name: string) -> output; + } + combine: func(outputs: list>) -> output; +} + + +interface register-interface { + use output-interface.{output}; + + record object-field { + name: string, + value: borrow + } + + record result-field { + name: string + } + + record register-resource-result-field { + name: string, + output: output + } + + record register-resource-request { + %type: string, + name: string, + object: list, + results: list + } + + record register-resource-result { + fields: list + } + + register: func(request: register-resource-request) -> register-resource-result; + + record resource-invoke-result-field { + name: string, + output: output + } + + record resource-invoke-request { + token: string, + object: list, + results: list + } + + record resource-invoke-result { + fields: list + } + + invoke: func(request: resource-invoke-request) -> resource-invoke-result; +} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/world.wit b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/world.wit new file mode 100644 index 000000000..6137f6586 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/wit/world.wit @@ -0,0 +1,56 @@ +package pulumi:plant@0.0.1--0.0.0-DEV; + +world plant-pulumi { + import component:pulumi-wasm/register-interface@0.0.0-DEV; + export tree-nursery; + export tree-rubber-tree; +} + +world plant-pulumi-client { + import tree-nursery; + import tree-rubber-tree; +} + +interface tree-nursery { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + sizes: borrow, + varieties: borrow, + } + + + invoke: func( + name: string, + args: args + ); + +} +interface tree-rubber-tree { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + container: borrow, + diameter: borrow, + farm: borrow, + size: borrow, + %type: borrow, + } + + record res { + container: output, + diameter: output, + farm: output, + size: output, + %type: output, + } + + invoke: func( + name: string, + args: args + ) -> res; + +} + diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/rust-toolchain.toml b/pulumi_wasm_generator_lib/tests/output/different-enum/rust-toolchain.toml new file mode 100644 index 000000000..7466ea07d --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.83.0" +targets = ["wasm32-wasip1"] \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/schema.json b/pulumi_wasm_generator_lib/tests/output/different-enum/schema.json new file mode 100644 index 000000000..0ea2429e3 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/schema.json @@ -0,0 +1,267 @@ +{ + "version": "0.0.1", + "name": "plant", + "allowedPackageNames": ["other"], + "resources": { + "plant:tree/v1:Nursery": { + "inputProperties": { + "varieties": { + "type": "array", + "items": { + "$ref": "#/types/plant:tree/v1:RubberTreeVariety" + }, + "description": "The varieties available" + }, + "sizes": { + "type": "object", + "additionalProperties": { + "$ref": "#/types/plant:tree/v1:TreeSize" + }, + "description": "The sizes of trees available" + } + }, + "requiredInputs": ["varieties"] + }, + "plant:tree/v1:RubberTree": { + "inputProperties": { + "container": { + "$ref": "#/types/plant::Container" + }, + "type": { + "$ref": "#/types/plant:tree/v1:RubberTreeVariety", + "default": "Burgundy" + }, + "farm": { + "oneOf": [ + { "$ref": "#/types/plant:tree/v1:Farm" }, + { "type": "string" } + ], + "default": "(unknown)" + }, + "size": { + "$ref": "#/types/plant:tree/v1:TreeSize", + "default": "medium" + }, + "diameter": { + "$ref": "#/types/other:tree/v1:Diameter", + "default": 6 + } + }, + "stateInputs": { + "properties": { + "farm": { + "oneOf": [ + { "$ref": "#/types/plant:tree/v1:Farm" }, + { "type": "string" } + ], + "default": "(unknown)" + } + } + }, + "properties": { + "container": { + "$ref": "#/types/plant::Container" + }, + "type": { + "$ref": "#/types/plant:tree/v1:RubberTreeVariety" + }, + "farm": { + "oneOf": [ + { "$ref": "#/types/plant:tree/v1:Farm" }, + { "type": "string" } + ] + }, + "size": { + "$ref": "#/types/plant:tree/v1:TreeSize", + "default": "medium" + }, + "diameter": { + "$ref": "#/types/other:tree/v1:Diameter", + "default": 6 + } + }, + "required": ["type", "diameter"], + "requiredInputs": ["type", "diameter"] + } + }, + "types": { + "plant::CloudAuditOptionsLogName": { + "description": "The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913", + "type": "string", + "enum": [ + { + "name": "UnspecifiedLogName", + "description": "Default. Should not be used.", + "value": "UNSPECIFIED_LOG_NAME" + }, + { + "name": "AdminActivity", + "description": "Corresponds to \"cloudaudit.googleapis.com/activity\"", + "value": "ADMIN_ACTIVITY" + }, + { + "name": "DataAccess", + "description": "Corresponds to \"cloudaudit.googleapis.com/data_access\"", + "value": "DATA_ACCESS" + }, + { + "name": "Synthetic", + "description": "What if triple quotes \"\"\" are used in the description", + "value": "SYNTHETIC" + } + ] + }, + "plant::Container": { + "type": "object", + "properties": { + "size": { + "$ref": "#/types/plant::ContainerSize" + }, + "material": { + "type": "string" + }, + "color": { + "oneOf": [ + { "$ref": "#/types/plant::ContainerColor" }, + { "type": "string" } + ] + }, + "brightness": { + "$ref": "#/types/plant::ContainerBrightness", + "default": 1.0 + } + }, + "required": ["size"] + }, + "plant::ContainerSize": { + "type": "integer", + "description": "plant container sizes", + "enum": [ + { + "value": 4, + "name": "FourInch" + }, + { + "value": 6, + "name": "SixInch" + }, + { + "value": 8, + "name": "EightInch", + "deprecationMessage": "Eight inch pots are no longer supported." + } + ] + }, + "plant::ContainerColor": { + "type": "string", + "description": "plant container colors", + "enum": [ + { + "value": "red" + }, + { + "value": "blue" + }, + { + "value": "yellow" + } + ] + }, + "plant::ContainerBrightness": { + "type": "number", + "enum": [ + { + "name": "ZeroPointOne", + "value": 0.1 + }, + { + "name": "One", + "value": 1.0 + } + ] + }, + "plant:tree/v1:RubberTreeVariety": { + "type": "string", + "description": "types of rubber trees", + "enum": [ + { + "value": "Burgundy", + "description": "A burgundy rubber tree." + }, + { + "value": "Ruby", + "description": "A ruby rubber tree." + }, + { + "value": "Tineke", + "description": "A tineke rubber tree." + } + ] + }, + "plant:tree/v1:Farm": { + "type": "string", + "enum": [ + { + "value": "Pulumi Planters Inc." + }, + { + "value": "Plants'R'Us" + } + ] + }, + "plant:tree/v1:TreeSize": { + "type": "string", + "enum": [ + { + "value": "small" + }, + { + "value": "medium" + }, + { + "value": "large" + } + ] + }, + "other:tree/v1:Diameter": { + "type": "number", + "enum": [ + { + "name": "sixinch", + "value": 6 + }, + { + "name": "twelveinch", + "value": 12 + } + ] + } + }, + "language": { + "csharp": { + "namespaces": { + "plant": "Plant", + "tree/v1": "Tree.V1" + }, + "packageReferences": { + "Pulumi": "3.12" + } + }, + "go": { + "importBasePath": "different-enum/plant" + }, + "nodejs": { + "dependencies": { + "@pulumi/pulumi": "^3.12" + }, + "devDependencies": { + "typescript": "^3.7.0" + } + }, + "python": { + "moduleNameOverrides": { + "tree/v1": "tree/v1" + } + } + } +} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/pulumi_wasm_generator_lib/tests/test.rs b/pulumi_wasm_generator_lib/tests/test.rs index 2c667a154..df92798d1 100644 --- a/pulumi_wasm_generator_lib/tests/test.rs +++ b/pulumi_wasm_generator_lib/tests/test.rs @@ -6,6 +6,16 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; +#[test] +fn array_of_enum_map() -> Result<()> { + run_pulumi_generator_test("array-of-enum-map", "example") +} + +#[test] +fn different_enum() -> Result<()> { + run_pulumi_generator_test("different-enum", "plant") +} + #[test] fn mini_awsnative() -> Result<()> { run_pulumi_generator_test("mini-awsnative", "aws-native") diff --git a/pulumi_wasm_provider_common/src/lib.rs b/pulumi_wasm_provider_common/src/lib.rs index ba8d4bc89..e60e8a1ea 100644 --- a/pulumi_wasm_provider_common/src/lib.rs +++ b/pulumi_wasm_provider_common/src/lib.rs @@ -8,9 +8,9 @@ macro_rules! generate_string_const { #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] struct $struct_name; impl Default for $struct_name { - fn default() -> Self { - Self {} - } + fn default() -> Self { + Self {} + } } impl serde::Serialize for $struct_name {