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