Skip to content

Commit ea79a0b

Browse files
author
Maddie Clayton
authored
Merge pull request #7779 from cle5eland/clthomps/iotcentral-backlog
Added Tabular Format to output and sudomain checking
2 parents d7dc565 + 96196cf commit ea79a0b

File tree

9 files changed

+802
-397
lines changed

9 files changed

+802
-397
lines changed

src/ResourceManager/IotCentral/Commands.IotCentral.Test/SessionRecords/Microsoft.Azure.Commands.IotCentral.Test.ScenarioTests.IotCentralTests/TestIotCentralAppLifecycleManagement.json

Lines changed: 674 additions & 386 deletions
Large diffs are not rendered by default.

src/ResourceManager/IotCentral/Commands.IotCentral/AzureRM.IotCentral.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ RequiredAssemblies = '.\Microsoft.Azure.Management.IotCentral.dll'
6363
# TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
66-
# FormatsToProcess = @()
66+
FormatsToProcess = '.\Microsoft.Azure.Commands.IotCentral.generated.format.ps1xml'
6767

6868
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6969
NestedModules = @('.\Microsoft.Azure.Commands.IotCentral.dll')

src/ResourceManager/IotCentral/Commands.IotCentral/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121

2222
## Version 1.0.0
2323
* Preview Release
24+
* Added Tabular Output Format
25+
* Added Subdomain Checking in New-AzureRmIotCentralApp

src/ResourceManager/IotCentral/Commands.IotCentral/Commands.IotCentral.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
<None Include="help\New-AzureRmIotCentralApp.md" />
7171
<None Include="help\Remove-AzureRmIotCentralApp.md" />
7272
<None Include="help\Set-AzureRmIotCentralApp.md" />
73+
<None Include="Microsoft.Azure.Commands.IotCentral.generated.format.ps1xml">
74+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
75+
</None>
7376
<None Include="MSSharedLibKey.snk" />
7477
<None Include="packages.config">
7578
<SubType>Designer</SubType>

src/ResourceManager/IotCentral/Commands.IotCentral/Common/IotCentralBaseCmdlet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public abstract class IotCentralBaseCmdlet : AzureRMCmdlet
3232
protected const string ResourceIdParameterSet = "ResourceIdParameterSet";
3333
protected const string InputObjectParameterSet = "InputObjectParameterSet";
3434

35+
protected const string resourceType = "IoTApps";
36+
3537
[Parameter(
3638
Mandatory = true,
3739
Position = 0,

src/ResourceManager/IotCentral/Commands.IotCentral/Common/IotCentralUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public static AppPatch CreateAppPatch(App iotCentralApp)
3737
var copiedIotCenralApp = new AppPatch()
3838
{
3939
DisplayName = iotCentralApp.DisplayName,
40-
Tags = iotCentralApp.Tags
40+
Tags = iotCentralApp.Tags,
41+
Subdomain = iotCentralApp.Subdomain
4142
};
4243
return copiedIotCenralApp;
4344
}

src/ResourceManager/IotCentral/Commands.IotCentral/IotCentral/NewAzureRmIotCentralApp.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@ public override void ExecuteCmdlet()
8383
{
8484
if (ShouldProcess(Name, ResourceProperties.Resources.NewIotCentralApp))
8585
{
86-
var inputs = new OperationInputs(this.Name, "IotApps");
87-
var availabilityInfo = this.IotCentralClient.Apps.CheckNameAvailability(inputs);
88-
if (!(availabilityInfo.NameAvailable == true))
89-
{
90-
throw new PSArgumentException(availabilityInfo.Message);
91-
}
86+
this.EnsureNameAvailabilityOrThrow();
87+
this.EnsureSubdomainAvailabilityOrThrow();
88+
9289
var iotCentralApp = new App()
9390
{
9491
DisplayName = this.GetDisplayName(),
@@ -106,6 +103,28 @@ public override void ExecuteCmdlet()
106103

107104
}
108105

106+
private void EnsureNameAvailabilityOrThrow()
107+
{
108+
var checkNameInputs = new OperationInputs(this.Name, resourceType);
109+
var nameAvailabilityInfo = this.IotCentralClient.Apps.CheckNameAvailability(checkNameInputs);
110+
this.EnsureAvailabilityOrThrow(nameAvailabilityInfo);
111+
}
112+
113+
private void EnsureSubdomainAvailabilityOrThrow()
114+
{
115+
var checkSubdomainInputs = new OperationInputs(this.Subdomain, resourceType);
116+
var subdomainAvailabilityInfo = this.IotCentralClient.Apps.CheckSubdomainAvailability(checkSubdomainInputs);
117+
this.EnsureAvailabilityOrThrow(subdomainAvailabilityInfo);
118+
}
119+
120+
private void EnsureAvailabilityOrThrow(AppAvailabilityInfo availabilityInfo)
121+
{
122+
if (availabilityInfo.NameAvailable != true)
123+
{
124+
throw new PSArgumentException(availabilityInfo.Message);
125+
}
126+
}
127+
109128
private IDictionary<string, string> GetTags()
110129
{
111130
if (this.Tag != null)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0"?>
2+
<Configuration>
3+
<ViewDefinitions>
4+
<View>
5+
<Name>Microsoft.Azure.Commands.IotCentral.Models.PSIotCentralApp</Name>
6+
<ViewSelectedBy>
7+
<TypeName>Microsoft.Azure.Commands.IotCentral.Models.PSIotCentralApp</TypeName>
8+
</ViewSelectedBy>
9+
<TableControl>
10+
<TableHeaders>
11+
<TableColumnHeader>
12+
<Alignment>Left</Alignment>
13+
<Label>Resource Name</Label>
14+
</TableColumnHeader>
15+
<TableColumnHeader>
16+
<Alignment>Left</Alignment>
17+
<Label>Subdomain</Label>
18+
</TableColumnHeader>
19+
<TableColumnHeader>
20+
<Alignment>Left</Alignment>
21+
<Label>Display Name</Label>
22+
</TableColumnHeader>
23+
<TableColumnHeader>
24+
<Alignment>Left</Alignment>
25+
<Label>Location</Label>
26+
</TableColumnHeader>
27+
<TableColumnHeader>
28+
<Alignment>Left</Alignment>
29+
<Label>Template</Label>
30+
</TableColumnHeader>
31+
<TableColumnHeader>
32+
<Alignment>Left</Alignment>
33+
<Label>Tags</Label>
34+
</TableColumnHeader>
35+
<TableColumnHeader>
36+
<Alignment>Left</Alignment>
37+
<Label>Sku Name</Label>
38+
</TableColumnHeader>
39+
<TableColumnHeader>
40+
<Alignment>Left</Alignment>
41+
<Label>Resource Group Name</Label>
42+
</TableColumnHeader>
43+
<TableColumnHeader>
44+
<Alignment>Left</Alignment>
45+
<Label>Application Id</Label>
46+
</TableColumnHeader>
47+
</TableHeaders>
48+
<TableRowEntries>
49+
<TableRowEntry>
50+
<TableColumnItems>
51+
<TableColumnItem>
52+
<Alignment>Left</Alignment>
53+
<PropertyName>Name</PropertyName>
54+
</TableColumnItem>
55+
<TableColumnItem>
56+
<Alignment>Left</Alignment>
57+
<PropertyName>Subdomain</PropertyName>
58+
</TableColumnItem>
59+
<TableColumnItem>
60+
<Alignment>Left</Alignment>
61+
<PropertyName>DisplayName</PropertyName>
62+
</TableColumnItem>
63+
<TableColumnItem>
64+
<Alignment>Left</Alignment>
65+
<PropertyName>Location</PropertyName>
66+
</TableColumnItem>
67+
<TableColumnItem>
68+
<Alignment>Left</Alignment>
69+
<PropertyName>Template</PropertyName>
70+
</TableColumnItem>
71+
<TableColumnItem>
72+
<Alignment>Left</Alignment>
73+
<PropertyName>Tag</PropertyName>
74+
</TableColumnItem>
75+
<TableColumnItem>
76+
<Alignment>Left</Alignment>
77+
<ScriptBlock>$_.Sku.Name</ScriptBlock>
78+
</TableColumnItem>
79+
<TableColumnItem>
80+
<Alignment>Left</Alignment>
81+
<PropertyName>ResourceGroupName</PropertyName>
82+
</TableColumnItem>
83+
<TableColumnItem>
84+
<Alignment>Left</Alignment>
85+
<PropertyName>ApplicationId</PropertyName>
86+
</TableColumnItem>
87+
</TableColumnItems>
88+
</TableRowEntry>
89+
</TableRowEntries>
90+
</TableControl>
91+
</View>
92+
</ViewDefinitions>
93+
</Configuration>

src/ResourceManager/IotCentral/Commands.IotCentral/Models/PSIotCentralApp.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,11 @@ public PSIotCentralApp(App iotCentralApp){
101101
/// <summary>
102102
/// The Resource type.
103103
/// </summary>
104-
[Ps1Xml(Label = "Type", Target = ViewControl.Table)]
105104
public string Type { get; private set; }
106105

107106
/// <summary>
108107
/// The subscription identifier.
109108
/// </summary>
110-
[Ps1Xml(Label = "Subscription Id", Target = ViewControl.Table)]
111109
public string SubscriptionId
112110
{
113111
get
@@ -131,7 +129,6 @@ public string ResourceGroupName
131129
/// <summary>
132130
/// The Resource Id.
133131
/// </summary>
134-
[Ps1Xml(Label = "Resource Id", Target = ViewControl.Table)]
135132
public string ResourceId { get; private set; }
136133

137134
/// <summary>

0 commit comments

Comments
 (0)