Skip to content

Add new cmdlet #1999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ function Test-DataLakeAnalyticsAccount
$testStoreAdd = Get-AzureRmDataLakeAnalyticsAccount -Name $accountName
Assert-AreEqual 2 $testStoreAdd.Properties.DataLakeStoreAccounts.Count

# get the specific data source added
$adlsAccountInfo = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataLakeStore $secondDataLakeAccountName
Assert-AreEqual $secondDataLakeAccountName $adlsAccountInfo.Name

# get the list of data lakes
$adlsAccountInfos = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataSource DataLakeStore
Assert-AreEqual 2 $adlsAccountInfos.Count

# remove the Data lake storage account
Assert-True {Remove-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataLakeStore $secondDataLakeAccountName -Force -PassThru} "Remove Data Lake Store account failed."

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

# get the specific data source added
$blobAccountInfo = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -Blob $blobAccountName
Assert-AreEqual $blobAccountName $blobAccountInfo.Name

# get the list of blobs
$blobAccountInfos = Get-AzureRmDataLakeAnalyticsDataSource -Account $accountName -DataSource Blob
Assert-AreEqual 1 $blobAccountInfos.Count

# remove the blob storage account
Assert-True {Remove-AzureRmDataLakeAnalyticsDataSource -Account $accountName -Blob $blobAccountName -Force -PassThru} "Remove blob Storage account failed."

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\GetAzureRmDataLakeAnalyticsDataSource.cs" />
<Compile Include="Commands\RemoveAzureRmDataLakeAnalyticsCatalogSecret.cs" />
<Compile Include="Commands\SetAzureRmDataLakeAnalyticsCatalogSecret.cs" />
<Compile Include="Commands\NewAzureRmDataLakeAnalyticsCatalogSecret.cs" />
Expand Down Expand Up @@ -157,6 +158,9 @@
<Link>AzureRM.DataLakeAnalytics.psd1</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Microsoft.Azure.Commands.DataLakeAnalytics.dll-help.psd1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config">
<SubType>Designer</SubType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.DataLakeAnalytics.Models;
using Microsoft.Azure.Management.DataLake.Analytics.Models;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.DataLakeAnalytics
{
[Cmdlet(VerbsCommon.Get, "AzureRmDataLakeAnalyticsDataSource"), OutputType(typeof(StorageAccountInfo), typeof(DataLakeStoreAccountInfo), typeof(IEnumerable<StorageAccountInfo>), typeof(IEnumerable<DataLakeStoreAccountInfo>))]
public class GetAzureDataLakeAnalyticsDataSource : DataLakeAnalyticsCmdletBase
{
internal const string DataLakeParameterSetName = "Get a Data Lake storage account";
internal const string BlobParameterSetName = "Get a Blob storage account";
internal const string ListStorageParameterSetName = "List a data source";

[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
ParameterSetName = DataLakeParameterSetName, HelpMessage = "Name of the account to add the data source to.")
]
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
ParameterSetName = BlobParameterSetName, HelpMessage = "Name of the account to add the data source to.")]
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
ParameterSetName = ListStorageParameterSetName, HelpMessage = "Name of the account to add the data source to.")]
[ValidateNotNullOrEmpty]
[Alias("AccountName")]
public string Account { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
ParameterSetName = DataLakeParameterSetName,
HelpMessage = "The name of the Data Lake Storage account to get from the account.")]
[ValidateNotNullOrEmpty]
public string DataLakeStore { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
ParameterSetName = BlobParameterSetName, HelpMessage = "The name of the Blob to get from the account.")]
[ValidateNotNullOrEmpty]
[Alias("AzureBlob")]
public string Blob { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Position = 1, Mandatory = true,
ParameterSetName = ListStorageParameterSetName, HelpMessage = "The type of data sources to list.")]
[ValidateNotNullOrEmpty]
public DataLakeAnalyticsEnums.DataSourceType DataSource { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Position = 2, Mandatory = false,
ParameterSetName = DataLakeParameterSetName,
HelpMessage =
"Name of resource group under which the Data Lake Analytics account exists to add a data source to.")]
[Parameter(ValueFromPipelineByPropertyName = true, Position = 2, Mandatory = false,
ParameterSetName = BlobParameterSetName,
HelpMessage =
"Name of resource group under which the Data Lake Analytics account exists to add a data source to.")]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

public override void ExecuteCmdlet()
{
if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
{
WriteObject(DataLakeAnalyticsClient.GetStorageAccount(ResourceGroupName, Account, Blob));
}
else if((ParameterSetName.Equals(DataLakeParameterSetName, StringComparison.InvariantCultureIgnoreCase)))
{
WriteObject(DataLakeAnalyticsClient.GetDataLakeStoreAccount(ResourceGroupName, Account, DataLakeStore));
}
else
{
if (DataSource == DataLakeAnalyticsEnums.DataSourceType.DataLakeStore)
{
WriteObject(DataLakeAnalyticsClient.ListDataLakeStoreAccounts(ResourceGroupName, Account), true);
}
else
{
WriteObject(DataLakeAnalyticsClient.ListStorageAccounts(ResourceGroupName, Account), true);
}
}
}
}
}
Binary file not shown.
Loading