Skip to content

Commit ee8097a

Browse files
committed
Merge pull request #1999 from begoldsm/dev
Add new cmdlet
2 parents 7d405d8 + e1e74be commit ee8097a

File tree

13 files changed

+11518
-2665
lines changed

13 files changed

+11518
-2665
lines changed

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics.Test/ScenarioTests/AdlaTests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function Test-DataLakeAnalyticsAccount
102102
$testStoreAdd = Get-AzureRmDataLakeAnalyticsAccount -Name $accountName
103103
Assert-AreEqual 2 $testStoreAdd.Properties.DataLakeStoreAccounts.Count
104104

105+
# get the specific data source added
106+
$adlsAccountInfo = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataLakeStore $secondDataLakeAccountName
107+
Assert-AreEqual $secondDataLakeAccountName $adlsAccountInfo.Name
108+
109+
# get the list of data lakes
110+
$adlsAccountInfos = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataSource DataLakeStore
111+
Assert-AreEqual 2 $adlsAccountInfos.Count
112+
105113
# remove the Data lake storage account
106114
Assert-True {Remove-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataLakeStore $secondDataLakeAccountName -Force -PassThru} "Remove Data Lake Store account failed."
107115

@@ -116,6 +124,14 @@ function Test-DataLakeAnalyticsAccount
116124
$testStoreAdd = Get-AzureRmDataLakeAnalyticsAccount -Name $accountName
117125
Assert-AreEqual 1 $testStoreAdd.Properties.StorageAccounts.Count
118126

127+
# get the specific data source added
128+
$blobAccountInfo = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -Blob $blobAccountName
129+
Assert-AreEqual $blobAccountName $blobAccountInfo.Name
130+
131+
# get the list of blobs
132+
$blobAccountInfos = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataSource Blob
133+
Assert-AreEqual 1 $blobAccountInfos.Count
134+
119135
# remove the blob storage account
120136
Assert-True {Remove-AzureRmDataLakeAnalyticsDataSource -Account $accountName -Blob $blobAccountName -Force -PassThru} "Remove blob Storage account failed."
121137

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics.Test/SessionRecords/Microsoft.Azure.Commands.DataLakeAnalytics.Test.ScenarioTests.AdlaTests/TestAdlaAccount.json

Lines changed: 1108 additions & 604 deletions
Large diffs are not rendered by default.

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics/Commands.DataLakeAnalytics.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
118118
</ItemGroup>
119119
<ItemGroup>
120+
<Compile Include="Commands\GetAzureRmDataLakeAnalyticsDataSource.cs" />
120121
<Compile Include="Commands\RemoveAzureRmDataLakeAnalyticsCatalogSecret.cs" />
121122
<Compile Include="Commands\SetAzureRmDataLakeAnalyticsCatalogSecret.cs" />
122123
<Compile Include="Commands\NewAzureRmDataLakeAnalyticsCatalogSecret.cs" />
@@ -157,6 +158,9 @@
157158
<Link>AzureRM.DataLakeAnalytics.psd1</Link>
158159
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159160
</None>
161+
<None Include="Microsoft.Azure.Commands.DataLakeAnalytics.dll-help.psd1">
162+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
163+
</None>
160164
<None Include="MSSharedLibKey.snk" />
161165
<None Include="packages.config">
162166
<SubType>Designer</SubType>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.DataLakeAnalytics.Models;
18+
using Microsoft.Azure.Management.DataLake.Analytics.Models;
19+
using System.Collections.Generic;
20+
21+
namespace Microsoft.Azure.Commands.DataLakeAnalytics
22+
{
23+
[Cmdlet(VerbsCommon.Get, "AzureRmDataLakeAnalyticsDataSource"), OutputType(typeof(StorageAccountInfo), typeof(DataLakeStoreAccountInfo), typeof(IEnumerable<StorageAccountInfo>), typeof(IEnumerable<DataLakeStoreAccountInfo>))]
24+
public class GetAzureDataLakeAnalyticsDataSource : DataLakeAnalyticsCmdletBase
25+
{
26+
internal const string DataLakeParameterSetName = "Get a Data Lake storage account";
27+
internal const string BlobParameterSetName = "Get a Blob storage account";
28+
internal const string ListStorageParameterSetName = "List a data source";
29+
30+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
31+
ParameterSetName = DataLakeParameterSetName, HelpMessage = "Name of the account to add the data source to.")
32+
]
33+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
34+
ParameterSetName = BlobParameterSetName, HelpMessage = "Name of the account to add the data source to.")]
35+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
36+
ParameterSetName = ListStorageParameterSetName, HelpMessage = "Name of the account to add the data source to.")]
37+
[ValidateNotNullOrEmpty]
38+
[Alias("AccountName")]
39+
public string Account { get; set; }
40+
41+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
42+
ParameterSetName = DataLakeParameterSetName,
43+
HelpMessage = "The name of the Data Lake Storage account to get from the account.")]
44+
[ValidateNotNullOrEmpty]
45+
public string DataLakeStore { get; set; }
46+
47+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
48+
ParameterSetName = BlobParameterSetName, HelpMessage = "The name of the Blob to get from the account.")]
49+
[ValidateNotNullOrEmpty]
50+
[Alias("AzureBlob")]
51+
public string Blob { get; set; }
52+
53+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
54+
ParameterSetName = ListStorageParameterSetName, HelpMessage = "The type of data sources to list.")]
55+
[ValidateNotNullOrEmpty]
56+
public DataLakeAnalyticsEnums.DataSourceType DataSource { get; set; }
57+
58+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 2, Mandatory = false,
59+
ParameterSetName = DataLakeParameterSetName,
60+
HelpMessage =
61+
"Name of resource group under which the Data Lake Analytics account exists to add a data source to.")]
62+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 2, Mandatory = false,
63+
ParameterSetName = BlobParameterSetName,
64+
HelpMessage =
65+
"Name of resource group under which the Data Lake Analytics account exists to add a data source to.")]
66+
[ValidateNotNullOrEmpty]
67+
public string ResourceGroupName { get; set; }
68+
69+
public override void ExecuteCmdlet()
70+
{
71+
if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
72+
{
73+
WriteObject(DataLakeAnalyticsClient.GetStorageAccount(ResourceGroupName, Account, Blob));
74+
}
75+
else if((ParameterSetName.Equals(DataLakeParameterSetName, StringComparison.InvariantCultureIgnoreCase)))
76+
{
77+
WriteObject(DataLakeAnalyticsClient.GetDataLakeStoreAccount(ResourceGroupName, Account, DataLakeStore));
78+
}
79+
else
80+
{
81+
if (DataSource == DataLakeAnalyticsEnums.DataSourceType.DataLakeStore)
82+
{
83+
WriteObject(DataLakeAnalyticsClient.ListDataLakeStoreAccounts(ResourceGroupName, Account), true);
84+
}
85+
else
86+
{
87+
WriteObject(DataLakeAnalyticsClient.ListStorageAccounts(ResourceGroupName, Account), true);
88+
}
89+
}
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)