Skip to content

Commit

Permalink
data: regenerating based on the latest Swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Oct 12, 2023
1 parent ba17495 commit ee6f613
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TerraformResourceDefinition> TerraformResources => new List<TerraformResourceDefinition>
{

new Terraform.DevCenterProjectResource(),
new Terraform.DevCenterResource(),
};
}
Original file line number Diff line number Diff line change
@@ -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<MappingType> Mappings => new List<MappingType>
{
Mapping.FromSchema<DevCenterResourceSchema>(s => s.Name).ToResourceIdSegmentNamed("devCenterName"),
Mapping.FromSchema<DevCenterResourceSchema>(s => s.ResourceGroupName).ToResourceIdSegmentNamed("resourceGroupName"),

Mapping.FromSchema<DevCenterResourceSchema>(s => s.DevCenterUri).ToSdkField<DevCenterPropertiesModel>(m => m.DevCenterUri).Direct(),
Mapping.FromSchema<DevCenterResourceSchema>(s => s.Identity).ToSdkField<DevCenterModel>(m => m.Identity).Direct(),
Mapping.FromSchema<DevCenterResourceSchema>(s => s.Location).ToSdkField<DevCenterModel>(m => m.Location).Direct(),
Mapping.FromSchema<DevCenterResourceSchema>(s => s.Tags).ToSdkField<DevCenterModel>(m => m.Tags).Direct(),
Mapping.FromSchemaModel<DevCenterResourceSchema>().ToSdkField<DevCenterModel>(m => m.Properties).ModelToModel(),
};
}
Original file line number Diff line number Diff line change
@@ -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; }

}
Original file line number Diff line number Diff line change
@@ -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<string, List<string>> OtherTests => new Dictionary<string, List<string>>();
}
Original file line number Diff line number Diff line change
@@ -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,
};
}
Original file line number Diff line number Diff line change
@@ -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<MappingType> Mappings => new List<MappingType>
{
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.Name).ToResourceIdSegmentNamed("projectName"),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.ResourceGroupName).ToResourceIdSegmentNamed("resourceGroupName"),

Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.Description).ToSdkField<ProjectPropertiesModel>(m => m.Description).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.DevCenterId).ToSdkField<ProjectPropertiesModel>(m => m.DevCenterId).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.DevCenterUri).ToSdkField<ProjectPropertiesModel>(m => m.DevCenterUri).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.Location).ToSdkField<ProjectModel>(m => m.Location).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.MaxDevBoxesPerUser).ToSdkField<ProjectPropertiesModel>(m => m.MaxDevBoxesPerUser).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.MaxDevBoxesPerUser).ToSdkField<ProjectUpdatePropertiesModel>(m => m.MaxDevBoxesPerUser).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.Tags).ToSdkField<ProjectModel>(m => m.Tags).Direct(),
Mapping.FromSchema<DevCenterProjectResourceSchema>(s => s.Tags).ToSdkField<ProjectUpdateModel>(m => m.Tags).Direct(),
Mapping.FromSchemaModel<DevCenterProjectResourceSchema>().ToSdkField<ProjectModel>(m => m.Properties).ModelToModel(),
Mapping.FromSchemaModel<DevCenterProjectResourceSchema>().ToSdkField<ProjectUpdateModel>(m => m.Properties).ModelToModel(),
};
}
Original file line number Diff line number Diff line change
@@ -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; }

}
Original file line number Diff line number Diff line change
@@ -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<string, List<string>> OtherTests => new Dictionary<string, List<string>>();
}
Loading

0 comments on commit ee6f613

Please sign in to comment.