Skip to content

Commit

Permalink
[Resources] Address API View comments (#27580)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhou-msft authored Mar 25, 2022
1 parent 4615b2d commit 8ff4a9f
Show file tree
Hide file tree
Showing 175 changed files with 3,056 additions and 2,885 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ Now that we have the resource group created, we can manage the application defin

```C# Snippet:Managing_ApplicationDefinitions_CreateAnApplicationDefinition
// First we need to get the application definition collection from the resource group
ApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetApplicationDefinitions();
ArmApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetArmApplicationDefinitions();
// Use the same location as the resource group
string applicationDefinitionName = "myApplicationDefinition";
var input = new ApplicationDefinitionData(resourceGroup.Data.Location, ApplicationLockLevel.None)
var input = new ArmApplicationDefinitionData(resourceGroup.Data.Location, ArmApplicationLockLevel.None)
{
DisplayName = applicationDefinitionName,
Description = $"{applicationDefinitionName} description",
PackageFileUri = new Uri("https://raw.githubusercontent.com/Azure/azure-managedapp-samples/master/Managed%20Application%20Sample%20Packages/201-managed-storage-account/managedstorage.zip")
};
ArmOperation<ApplicationDefinitionResource> lro = await applicationDefinitionCollection.CreateOrUpdateAsync(WaitUntil.Completed, applicationDefinitionName, input);
ApplicationDefinitionResource applicationDefinition = lro.Value;
ArmOperation<ArmApplicationDefinitionResource> lro = await applicationDefinitionCollection.CreateOrUpdateAsync(WaitUntil.Completed, applicationDefinitionName, input);
ArmApplicationDefinitionResource applicationDefinition = lro.Value;
```

***List all application definitions***

```C# Snippet:Managing_ApplicationDefinitions_ListAllApplicationDefinitions
// First we need to get the application definition collection from the resource group
ApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetApplicationDefinitions();
ArmApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetArmApplicationDefinitions();
// With GetAllAsync(), we can get a list of the application definitions in the collection
AsyncPageable<ApplicationDefinitionResource> response = applicationDefinitionCollection.GetAllAsync();
await foreach (ApplicationDefinitionResource applicationDefinition in response)
AsyncPageable<ArmApplicationDefinitionResource> response = applicationDefinitionCollection.GetAllAsync();
await foreach (ArmApplicationDefinitionResource applicationDefinition in response)
{
Console.WriteLine(applicationDefinition.Data.Name);
}
Expand All @@ -66,9 +66,9 @@ await foreach (ApplicationDefinitionResource applicationDefinition in response)

```C# Snippet:Managing_ApplicationDefinitions_DeleteAnApplicationDefinition
// First we need to get the application definition collection from the resource group
ApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetApplicationDefinitions();
ArmApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetArmApplicationDefinitions();
// Now we can get the application definition with GetAsync()
ApplicationDefinitionResource applicationDefinition = await applicationDefinitionCollection.GetAsync("myApplicationDefinition");
ArmApplicationDefinitionResource applicationDefinition = await applicationDefinitionCollection.GetAsync("myApplicationDefinition");
// With DeleteAsync(), we can delete the application definition
await applicationDefinition.DeleteAsync(WaitUntil.Completed);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Now that we have the resource group created, we can manage the deployments insid

```C# Snippet:Managing_Deployments_CreateADeployment
// First we need to get the deployment collection from the resource group
DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
ArmDeploymentCollection ArmDeploymentCollection = resourceGroup.GetArmDeployments();
// Use the same location as the resource group
string deploymentName = "myDeployment";
var input = new DeploymentInput(new DeploymentProperties(DeploymentMode.Incremental)
var input = new ArmDeploymentInput(new ArmDeploymentProperties(ArmDeploymentMode.Incremental)
{
TemplateLink = new TemplateLink()
{
Expand All @@ -58,59 +58,59 @@ var input = new DeploymentInput(new DeploymentProperties(DeploymentMode.Incremen
}
}
});
ArmOperation<DeploymentResource> lro = await deploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
DeploymentResource deployment = lro.Value;
ArmOperation<ArmDeploymentResource> lro = await ArmDeploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
ArmDeploymentResource deployment = lro.Value;
```

***Create a deployment using string***

```C# Snippet:Managing_Deployments_CreateADeploymentUsingString
// First we need to get the deployment collection from the resource group
DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
ArmDeploymentCollection ArmDeploymentCollection = resourceGroup.GetArmDeployments();
// Use the same location as the resource group
string deploymentName = "myDeployment";
// Passing string to template and parameters
var input = new DeploymentInput(new DeploymentProperties(DeploymentMode.Incremental)
var input = new ArmDeploymentInput(new ArmDeploymentProperties(ArmDeploymentMode.Incremental)
{
Template = File.ReadAllText("storage-template.json"),
Parameters = File.ReadAllText("storage-parameters.json")
});
ArmOperation<DeploymentResource> lro = await deploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
DeploymentResource deployment = lro.Value;
ArmOperation<ArmDeploymentResource> lro = await ArmDeploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
ArmDeploymentResource deployment = lro.Value;
```

***Create a deployment using JsonElement***

```C# Snippet:Managing_Deployments_CreateADeploymentUsingJsonElement
// First we need to get the deployment collection from the resource group
DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
ArmDeploymentCollection ArmDeploymentCollection = resourceGroup.GetArmDeployments();
// Use the same location as the resource group
string deploymentName = "myDeployment";
// Create a parameter object
var parametersObject = new { storageAccountType = new { value = "Standard_GRS" } };
//convert this object to JsonElement
var parametersString = JsonSerializer.Serialize(parametersObject);
var parameters = JsonDocument.Parse(parametersString).RootElement;
var input = new DeploymentInput(new DeploymentProperties(DeploymentMode.Incremental)
var input = new ArmDeploymentInput(new ArmDeploymentProperties(ArmDeploymentMode.Incremental)
{
TemplateLink = new TemplateLink()
{
Uri = new Uri("https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json")
},
Parameters = parameters
});
ArmOperation<DeploymentResource> lro = await deploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
DeploymentResource deployment = lro.Value;
ArmOperation<ArmDeploymentResource> lro = await ArmDeploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
ArmDeploymentResource deployment = lro.Value;
```

***List all deployments***

```C# Snippet:Managing_Deployments_ListAllDeployments
// First we need to get the deployment collection from the resource group
DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
ArmDeploymentCollection ArmDeploymentCollection = resourceGroup.GetArmDeployments();
// With GetAllAsync(), we can get a list of the deployments in the collection
AsyncPageable<DeploymentResource> response = deploymentCollection.GetAllAsync();
await foreach (DeploymentResource deployment in response)
AsyncPageable<ArmDeploymentResource> response = ArmDeploymentCollection.GetAllAsync();
await foreach (ArmDeploymentResource deployment in response)
{
Console.WriteLine(deployment.Data.Name);
}
Expand All @@ -120,9 +120,9 @@ await foreach (DeploymentResource deployment in response)

```C# Snippet:Managing_Deployments_DeleteADeployment
// First we need to get the deployment collection from the resource group
DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
ArmDeploymentCollection ArmDeploymentCollection = resourceGroup.GetArmDeployments();
// Now we can get the deployment with GetAsync()
DeploymentResource deployment = await deploymentCollection.GetAsync("myDeployment");
ArmDeploymentResource deployment = await ArmDeploymentCollection.GetAsync("myDeployment");
// With DeleteAsync(), we can delete the deployment
await deployment.DeleteAsync(WaitUntil.Completed);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Azure.ResourceManager.Resources.Models
{
public partial class DeploymentProperties : IUtf8JsonSerializable
public partial class ArmDeploymentProperties : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
namespace Azure.ResourceManager.Resources.Models
{
/// <summary> Deployment properties. </summary>
public partial class DeploymentProperties
public partial class ArmDeploymentProperties
{
/// <summary> Initializes a new instance of DeploymentProperties. </summary>
/// <summary> Initializes a new instance of ArmDeploymentProperties. </summary>
/// <param name="mode"> The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. </param>
public DeploymentProperties(DeploymentMode mode)
public ArmDeploymentProperties(ArmDeploymentMode mode)
{
Mode = mode;
}
Expand All @@ -26,7 +26,7 @@ public DeploymentProperties(DeploymentMode mode)
/// <summary> The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. </summary>
public ParametersLink ParametersLink { get; set; }
/// <summary> The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. </summary>
public DeploymentMode Mode { get; }
public ArmDeploymentMode Mode { get; }
/// <summary> The debug setting of the deployment. </summary>
internal DebugSetting DebugSetting { get; set; }
/// <summary> Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@

namespace Azure.ResourceManager.Resources.Models
{
public partial class DeploymentPropertiesExtended
public partial class ArmDeploymentPropertiesExtended
{
internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExtended(JsonElement element)
internal static ArmDeploymentPropertiesExtended DeserializeArmDeploymentPropertiesExtended(JsonElement element)
{
Optional<ProvisioningState> provisioningState = default;
Optional<ResourcesProvisioningState> provisioningState = default;
Optional<string> correlationId = default;
Optional<DateTimeOffset> timestamp = default;
Optional<TimeSpan> duration = default;
Optional<BinaryData> outputs = default;
Optional<IReadOnlyList<ResourceProviderData>> providers = default;
Optional<IReadOnlyList<Dependency>> dependencies = default;
Optional<IReadOnlyList<ArmDependency>> dependencies = default;
Optional<TemplateLink> templateLink = default;
Optional<BinaryData> parameters = default;
Optional<ParametersLink> parametersLink = default;
Optional<DeploymentMode> mode = default;
Optional<ArmDeploymentMode> mode = default;
Optional<DebugSetting> debugSetting = default;
Optional<OnErrorDeploymentExtended> onErrorDeployment = default;
Optional<string> templateHash = default;
Expand All @@ -44,7 +44,7 @@ internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExte
property.ThrowNonNullablePropertyIsNull();
continue;
}
provisioningState = new ProvisioningState(property.Value.GetString());
provisioningState = new ResourcesProvisioningState(property.Value.GetString());
continue;
}
if (property.NameEquals("correlationId"))
Expand Down Expand Up @@ -104,10 +104,10 @@ internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExte
property.ThrowNonNullablePropertyIsNull();
continue;
}
List<Dependency> array = new List<Dependency>();
List<ArmDependency> array = new List<ArmDependency>();
foreach (var item in property.Value.EnumerateArray())
{
array.Add(Dependency.DeserializeDependency(item));
array.Add(ArmDependency.DeserializeArmDependency(item));
}
dependencies = array;
continue;
Expand Down Expand Up @@ -149,7 +149,7 @@ internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExte
property.ThrowNonNullablePropertyIsNull();
continue;
}
mode = new DeploymentMode(property.Value.GetString());
mode = property.Value.GetString().ToArmDeploymentMode();
continue;
}
if (property.NameEquals("debugSetting"))
Expand Down Expand Up @@ -218,7 +218,7 @@ internal static DeploymentPropertiesExtended DeserializeDeploymentPropertiesExte
continue;
}
}
return new DeploymentPropertiesExtended(Optional.ToNullable(provisioningState), correlationId.Value, Optional.ToNullable(timestamp), Optional.ToNullable(duration), outputs.Value, Optional.ToList(providers), Optional.ToList(dependencies), templateLink.Value, parameters.Value, parametersLink.Value, Optional.ToNullable(mode), debugSetting.Value, onErrorDeployment.Value, templateHash.Value, Optional.ToList(outputResources), Optional.ToList(validatedResources), error);
return new ArmDeploymentPropertiesExtended(Optional.ToNullable(provisioningState), correlationId.Value, Optional.ToNullable(timestamp), Optional.ToNullable(duration), outputs.Value, Optional.ToList(providers), Optional.ToList(dependencies), templateLink.Value, parameters.Value, parametersLink.Value, Optional.ToNullable(mode), debugSetting.Value, onErrorDeployment.Value, templateHash.Value, Optional.ToList(outputResources), Optional.ToList(validatedResources), error);
}
}
}
Loading

0 comments on commit 8ff4a9f

Please sign in to comment.