From ee6f61390bf095eb09c5749d647c15b3d56010fa Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Thu, 12 Oct 2023 15:11:48 +0000 Subject: [PATCH] data: regenerating based on the latest Swagger --- .../DevCenter/ServiceDefinition.cs | 5 +- .../Terraform/DevCenter-Resource-Mappings.cs | 21 ++++++ .../Terraform/DevCenter-Resource-Schema.cs | 49 +++++++++++++ .../Terraform/DevCenter-Resource-Tests.cs | 67 +++++++++++++++++ .../DevCenter/Terraform/DevCenter-Resource.cs | 60 ++++++++++++++++ .../DevCenterProject-Resource-Mappings.cs | 26 +++++++ .../DevCenterProject-Resource-Schema.cs | 63 ++++++++++++++++ .../DevCenterProject-Resource-Tests.cs | 72 +++++++++++++++++++ .../Terraform/DevCenterProject-Resource.cs | 64 +++++++++++++++++ 9 files changed, 425 insertions(+), 2 deletions(-) create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Mappings.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Schema.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Tests.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Mappings.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Schema.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Tests.cs create mode 100644 data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource.cs diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/ServiceDefinition.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/ServiceDefinition.cs index ee0e5d6e9da..4aab8f77851 100644 --- a/data/Pandora.Definitions.ResourceManager/DevCenter/ServiceDefinition.cs +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/ServiceDefinition.cs @@ -12,10 +12,11 @@ public partial class Service : ServiceDefinition { public string Name => "DevCenter"; public string? ResourceProvider => "Microsoft.DevCenter"; - public string? TerraformPackageName => null; + public string? TerraformPackageName => "devcenter"; public IEnumerable TerraformResources => new List { - + new Terraform.DevCenterProjectResource(), + new Terraform.DevCenterResource(), }; } diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Mappings.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Mappings.cs new file mode 100644 index 00000000000..17017ab6142 --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Mappings.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Pandora.Definitions.Interfaces; +using Pandora.Definitions.Mappings; +using Pandora.Definitions.ResourceManager.DevCenter.v2023_04_01.DevCenters; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterResourceMappings : TerraformMappingDefinition +{ + public List Mappings => new List + { + Mapping.FromSchema(s => s.Name).ToResourceIdSegmentNamed("devCenterName"), + Mapping.FromSchema(s => s.ResourceGroupName).ToResourceIdSegmentNamed("resourceGroupName"), + + Mapping.FromSchema(s => s.DevCenterUri).ToSdkField(m => m.DevCenterUri).Direct(), + Mapping.FromSchema(s => s.Identity).ToSdkField(m => m.Identity).Direct(), + Mapping.FromSchema(s => s.Location).ToSdkField(m => m.Location).Direct(), + Mapping.FromSchema(s => s.Tags).ToSdkField(m => m.Tags).Direct(), + Mapping.FromSchemaModel().ToSdkField(m => m.Properties).ModelToModel(), + }; +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Schema.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Schema.cs new file mode 100644 index 00000000000..ea522698cdd --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Schema.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using Pandora.Definitions.Attributes; +using Pandora.Definitions.Attributes.Validation; +using Pandora.Definitions.CommonSchema; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterResourceSchema +{ + + [Computed] + [Documentation("The URI of the Dev Center.")] + [HclName("dev_center_uri")] + public string DevCenterUri { get; set; } + + + [Documentation("Specifies the Managed Identity which should be assigned to this Dev Center.")] + [HclName("identity")] + [Optional] + public CommonSchema.SystemAndUserAssignedIdentity Identity { get; set; } + + + [Documentation("The Azure Region where the Dev Center should exist.")] + [ForceNew] + [HclName("location")] + [Required] + public CommonSchema.Location Location { get; set; } + + + [Documentation("Specifies the name of this Dev Center.")] + [ForceNew] + [HclName("name")] + [Required] + public string Name { get; set; } + + + [Documentation("Specifies the name of the Resource Group within which this Dev Center should exist.")] + [ForceNew] + [HclName("resource_group_name")] + [Required] + public CommonSchema.ResourceGroupName ResourceGroupName { get; set; } + + + [Documentation("A mapping of tags which should be assigned to the Dev Center.")] + [HclName("tags")] + [Optional] + public CommonSchema.Tags Tags { get; set; } + +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Tests.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Tests.cs new file mode 100644 index 00000000000..083fc5edfbb --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource-Tests.cs @@ -0,0 +1,67 @@ +using System.Collections.Generic; +using Pandora.Definitions.Helpers; +using Pandora.Definitions.Interfaces; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterResourceTests : TerraformResourceTestDefinition +{ + public string BasicTestConfig => @" +provider 'azurerm' { + features {} +} + +resource 'azurerm_dev_center' 'test' { + location = azurerm_resource_group.test.location + name = 'acctestdc-${var.random_string}' + resource_group_name = azurerm_resource_group.test.name +} + ".AsTerraformTestConfig(); + + public string RequiresImportConfig => @" +resource 'azurerm_dev_center' 'import' { + location = azurerm_dev_center.test.location + name = azurerm_dev_center.test.name + resource_group_name = azurerm_dev_center.test.resource_group_name +} + ".AsTerraformTestConfig(); + + public string? CompleteConfig => @" +provider 'azurerm' { + features {} +} + +resource 'azurerm_dev_center' 'test' { + location = azurerm_resource_group.test.location + name = 'acctestdc-${var.random_string}' + resource_group_name = azurerm_resource_group.test.name + tags = { + environment = 'terraform-acctests' + some_key = 'some-value' + } + identity { + type = 'SystemAssigned, UserAssigned' + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} +".AsTerraformTestConfig(); + public string? TemplateConfig => @" +variable 'primary_location' {} +variable 'random_integer' {} +variable 'random_string' {} + +resource 'azurerm_resource_group' 'test' { + name = 'acctestrg-${var.random_integer}' + location = var.primary_location +} + + +resource 'azurerm_user_assigned_identity' 'test' { + name = 'acctest-${var.random_integer}' + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +".AsTerraformTestConfig(); + + public Dictionary> OtherTests => new Dictionary>(); +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource.cs new file mode 100644 index 00000000000..87f8b09033f --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenter-Resource.cs @@ -0,0 +1,60 @@ +using System; +using Pandora.Definitions.Helpers; +using Pandora.Definitions.Interfaces; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterResource : TerraformResourceDefinition +{ + public string DisplayName => "Dev Center"; + public ResourceID ResourceId => new v2023_04_01.DevCenters.DevCenterId(); + public string ResourceLabel => "dev_center"; + public string ResourceCategory => "Dev Center"; + public string ResourceDescription => @"Manages a Dev Center"; + public string ResourceExampleUsage => @"resource 'azurerm_resource_group' 'example' { + name = 'example-resources' + location = 'West Europe' +} +resource 'azurerm_user_assigned_identity' 'example' { + name = 'example' + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location +} +resource 'azurerm_dev_center' 'example' { + location = azurerm_resource_group.example.location + name = 'example' + resource_group_name = azurerm_resource_group.example.name +}".AsTerraformTestConfig(); + public Type? SchemaModel => typeof(DevCenterResourceSchema); + public TerraformMappingDefinition SchemaMappings => new DevCenterResourceMappings(); + public TerraformResourceTestDefinition Tests => new DevCenterResourceTests(); + + public bool GenerateIDValidationFunction => true; + public bool GenerateModel => true; + public bool GenerateSchema => true; + + public MethodDefinition CreateMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.DevCenters.CreateOrUpdateOperation), + TimeoutInMinutes = 30, + }; + public MethodDefinition DeleteMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.DevCenters.DeleteOperation), + TimeoutInMinutes = 30, + }; + public MethodDefinition ReadMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.DevCenters.GetOperation), + TimeoutInMinutes = 5, + }; + public MethodDefinition? UpdateMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.DevCenters.CreateOrUpdateOperation), + TimeoutInMinutes = 30, + }; +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Mappings.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Mappings.cs new file mode 100644 index 00000000000..d609c9cd4c9 --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Mappings.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Pandora.Definitions.Interfaces; +using Pandora.Definitions.Mappings; +using Pandora.Definitions.ResourceManager.DevCenter.v2023_04_01.Projects; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterProjectResourceMappings : TerraformMappingDefinition +{ + public List Mappings => new List + { + Mapping.FromSchema(s => s.Name).ToResourceIdSegmentNamed("projectName"), + Mapping.FromSchema(s => s.ResourceGroupName).ToResourceIdSegmentNamed("resourceGroupName"), + + Mapping.FromSchema(s => s.Description).ToSdkField(m => m.Description).Direct(), + Mapping.FromSchema(s => s.DevCenterId).ToSdkField(m => m.DevCenterId).Direct(), + Mapping.FromSchema(s => s.DevCenterUri).ToSdkField(m => m.DevCenterUri).Direct(), + Mapping.FromSchema(s => s.Location).ToSdkField(m => m.Location).Direct(), + Mapping.FromSchema(s => s.MaxDevBoxesPerUser).ToSdkField(m => m.MaxDevBoxesPerUser).Direct(), + Mapping.FromSchema(s => s.MaxDevBoxesPerUser).ToSdkField(m => m.MaxDevBoxesPerUser).Direct(), + Mapping.FromSchema(s => s.Tags).ToSdkField(m => m.Tags).Direct(), + Mapping.FromSchema(s => s.Tags).ToSdkField(m => m.Tags).Direct(), + Mapping.FromSchemaModel().ToSdkField(m => m.Properties).ModelToModel(), + Mapping.FromSchemaModel().ToSdkField(m => m.Properties).ModelToModel(), + }; +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Schema.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Schema.cs new file mode 100644 index 00000000000..6f829ac6564 --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Schema.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using Pandora.Definitions.Attributes; +using Pandora.Definitions.Attributes.Validation; +using Pandora.Definitions.CommonSchema; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterProjectResourceSchema +{ + + [Documentation("Description of the project.")] + [ForceNew] + [HclName("description")] + [Optional] + public string Description { get; set; } + + + [Documentation("Resource Id of an associated DevCenter.")] + [ForceNew] + [HclName("dev_center_id")] + [Required] + public string DevCenterId { get; set; } + + + [Computed] + [Documentation("The URI of the Dev Center resource this project is associated with.")] + [HclName("dev_center_uri")] + public string DevCenterUri { get; set; } + + + [Documentation("The Azure Region where the Dev Center Project should exist.")] + [ForceNew] + [HclName("location")] + [Required] + public CommonSchema.Location Location { get; set; } + + + [Documentation("When specified, limits the maximum number of Dev Boxes a single user can create across all pools in the project.")] + [HclName("max_dev_boxes_per_user")] + [Optional] + public int MaxDevBoxesPerUser { get; set; } + + + [Documentation("Specifies the name of this Dev Center Project.")] + [ForceNew] + [HclName("name")] + [Required] + public string Name { get; set; } + + + [Documentation("Specifies the name of the Resource Group within which this Dev Center Project should exist.")] + [ForceNew] + [HclName("resource_group_name")] + [Required] + public CommonSchema.ResourceGroupName ResourceGroupName { get; set; } + + + [Documentation("A mapping of tags which should be assigned to the Dev Center Project.")] + [HclName("tags")] + [Optional] + public CommonSchema.Tags Tags { get; set; } + +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Tests.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Tests.cs new file mode 100644 index 00000000000..61b9ada2792 --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource-Tests.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using Pandora.Definitions.Helpers; +using Pandora.Definitions.Interfaces; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterProjectResourceTests : TerraformResourceTestDefinition +{ + public string BasicTestConfig => @" +provider 'azurerm' { + features {} +} + +resource 'azurerm_dev_center_project' 'test' { + dev_center_id = azurerm_dev_center.test.id + location = azurerm_resource_group.test.location + name = 'acctestdcp-${var.random_string}' + resource_group_name = azurerm_resource_group.test.name +} + ".AsTerraformTestConfig(); + + public string RequiresImportConfig => @" +resource 'azurerm_dev_center_project' 'import' { + dev_center_id = azurerm_dev_center_project.test.dev_center_id + location = azurerm_dev_center_project.test.location + name = azurerm_dev_center_project.test.name + resource_group_name = azurerm_dev_center_project.test.resource_group_name +} + ".AsTerraformTestConfig(); + + public string? CompleteConfig => @" +provider 'azurerm' { + features {} +} + +resource 'azurerm_dev_center_project' 'test' { + dev_center_id = azurerm_dev_center.test.id + location = azurerm_resource_group.test.location + name = 'acctestdcp-${var.random_string}' + resource_group_name = azurerm_resource_group.test.name + description = 'Description for the Dev Center Project' + max_dev_boxes_per_user = 21 + tags = { + environment = 'terraform-acctests' + some_key = 'some-value' + } +} +".AsTerraformTestConfig(); + public string? TemplateConfig => @" +variable 'primary_location' {} +variable 'random_integer' {} +variable 'random_string' {} + +resource 'azurerm_dev_center' 'test' { + name = 'acctestdc-${var.random_string}' + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = 'SystemAssigned' + } +} + + +resource 'azurerm_resource_group' 'test' { + name = 'acctestrg-${var.random_integer}' + location = var.primary_location +} +".AsTerraformTestConfig(); + + public Dictionary> OtherTests => new Dictionary>(); +} diff --git a/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource.cs b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource.cs new file mode 100644 index 00000000000..e71840820db --- /dev/null +++ b/data/Pandora.Definitions.ResourceManager/DevCenter/Terraform/DevCenterProject-Resource.cs @@ -0,0 +1,64 @@ +using System; +using Pandora.Definitions.Helpers; +using Pandora.Definitions.Interfaces; + +namespace Pandora.Definitions.ResourceManager.DevCenter.Terraform; + +public class DevCenterProjectResource : TerraformResourceDefinition +{ + public string DisplayName => "Dev Center Project"; + public ResourceID ResourceId => new v2023_04_01.Projects.ProjectId(); + public string ResourceLabel => "dev_center_project"; + public string ResourceCategory => "Dev Center Project"; + public string ResourceDescription => @"Manages a Dev Center Project"; + public string ResourceExampleUsage => @"resource 'azurerm_dev_center' 'example' { + name = 'example' + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + identity { + type = 'example-value' + } +} +resource 'azurerm_resource_group' 'example' { + name = 'example-resources' + location = 'West Europe' +} +resource 'azurerm_dev_center_project' 'example' { + dev_center_id = azurerm_dev_center.example.id + location = azurerm_resource_group.example.location + name = 'example' + resource_group_name = azurerm_resource_group.example.name +}".AsTerraformTestConfig(); + public Type? SchemaModel => typeof(DevCenterProjectResourceSchema); + public TerraformMappingDefinition SchemaMappings => new DevCenterProjectResourceMappings(); + public TerraformResourceTestDefinition Tests => new DevCenterProjectResourceTests(); + + public bool GenerateIDValidationFunction => true; + public bool GenerateModel => true; + public bool GenerateSchema => true; + + public MethodDefinition CreateMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.Projects.CreateOrUpdateOperation), + TimeoutInMinutes = 30, + }; + public MethodDefinition DeleteMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.Projects.DeleteOperation), + TimeoutInMinutes = 30, + }; + public MethodDefinition ReadMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.Projects.GetOperation), + TimeoutInMinutes = 5, + }; + public MethodDefinition? UpdateMethod => new MethodDefinition + { + Generate = true, + Method = typeof(v2023_04_01.Projects.UpdateOperation), + TimeoutInMinutes = 30, + }; +}