12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
+ using BCI = Microsoft . BackupManagementService . CommonInterface ;
16
+ using BMI = Microsoft . BackupManagementService . ManagementInterface ;
17
+ using Microsoft . Azure . Management . BackupServices . Models ;
15
18
using System ;
16
19
using System . Collections . Generic ;
17
20
using System . Linq ;
@@ -29,11 +32,7 @@ public class GetAzureBackupContainer : AzureBackupVaultCmdletBase
29
32
{
30
33
[ Parameter ( Position = 2 , Mandatory = false , HelpMessage = AzureBackupCmdletHelpMessage . ContainerName ) ]
31
34
[ ValidateNotNullOrEmpty ]
32
- public string Name { get ; set ; }
33
-
34
- [ Parameter ( Position = 2 , Mandatory = false , HelpMessage = AzureBackupCmdletHelpMessage . ContainerId ) ]
35
- [ ValidateNotNullOrEmpty ]
36
- public string Id { get ; set ; }
35
+ public string VirtualMachine { get ; set ; }
37
36
38
37
[ Parameter ( Position = 2 , Mandatory = false , HelpMessage = AzureBackupCmdletHelpMessage . ContainerRegistrationStatus ) ]
39
38
[ ValidateNotNullOrEmpty ]
@@ -49,12 +48,75 @@ public override void ExecuteCmdlet()
49
48
50
49
ExecutionBlock ( ( ) =>
51
50
{
52
- IEnumerable < AzureBackupContainer > containers = new List < AzureBackupContainer > ( ) ;
51
+ string queryFilterString = string . Empty ;
52
+ // TODO: Construct query filter string based on input filters.
53
+ //queryFilterString = ConstructQueryFilterString();
53
54
54
- // TODO: Call Hydra
55
+ ListContainerResponse listContainerResponse = AzureBackupClient . Container . ListAsync ( queryFilterString ,
56
+ GetCustomRequestHeaders ( ) , CmdletCancellationToken ) . Result ;
57
+
58
+ IEnumerable < AzureBackupContainer > containers = listContainerResponse . Objects . ToList ( ) . ConvertAll ( containerInfo =>
59
+ {
60
+ return new AzureBackupContainer ( )
61
+ {
62
+ ContainerType = containerInfo . ContainerType ,
63
+ FriendlyName = containerInfo . FriendlyName ,
64
+ HealthStatus = containerInfo . HealthStatus ,
65
+ InstanceId = containerInfo . InstanceId ,
66
+ Name = containerInfo . Name ,
67
+ ParentContainerFriendlyName = containerInfo . ParentContainerFriendlyName ,
68
+ ParentContainerName = containerInfo . ParentContainerName ,
69
+ RegistrationStatus = containerInfo . RegistrationStatus ,
70
+ ResourceGroupName = ResourceGroupName ,
71
+ ResourceName = ResourceName ,
72
+ } ;
73
+ } ) ;
55
74
56
75
WriteObject ( containers ) ;
57
76
} ) ;
58
77
}
78
+
79
+ private string ConstructQueryFilterString ( )
80
+ {
81
+ string queryFilterString = string . Empty ;
82
+ BMI . ContainerQueryObject containerQueryObject = new BMI . ContainerQueryObject ( ) ;
83
+
84
+ if ( Type != null )
85
+ {
86
+ switch ( Type )
87
+ {
88
+ case AzureBackupContainerType . AzureVirtualMachine :
89
+ containerQueryObject . Type = BCI . ContainerType . IaasVMContainer . ToString ( ) ;
90
+ break ;
91
+ default :
92
+ break ;
93
+ }
94
+ }
95
+
96
+ if ( Status != null )
97
+ {
98
+ switch ( Status )
99
+ {
100
+ case AzureBackupContainerStatus . Registered :
101
+ containerQueryObject . Status = BCI . RegistrationStatus . Registered . ToString ( ) ;
102
+ break ;
103
+ case AzureBackupContainerStatus . Registering :
104
+ containerQueryObject . Status = BCI . RegistrationStatus . Registering . ToString ( ) ;
105
+ break ;
106
+ case AzureBackupContainerStatus . NotRegistered :
107
+ containerQueryObject . Status = BCI . RegistrationStatus . NotRegistered . ToString ( ) ;
108
+ break ;
109
+ default :
110
+ break ;
111
+ }
112
+ }
113
+
114
+ if ( VirtualMachine != null )
115
+ {
116
+
117
+ }
118
+
119
+ return queryFilterString ;
120
+ }
59
121
}
60
122
}
0 commit comments