Skip to content

Commit 0a2cced

Browse files
fzkhanFaizan Uddin Fahad Khan
andauthored
Add Red Button commands for AzureDataTransfer (#28372)
Co-authored-by: Faizan Uddin Fahad Khan <[email protected]>
1 parent 228e6bc commit 0a2cced

File tree

45 files changed

+4715
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4715
-20
lines changed

src/DataTransfer/DataTransfer.Autorest/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ directive:
117117
# - remove-operation: Pipelines_ListBySubscription
118118
- remove-operation: Operations_List
119119
- remove-operation: ListFlowsByPipeline_List
120-
- remove-operation: Pipelines_ExecuteAction
120+
# - remove-operation: Pipelines_ExecuteAction
121121

122122
- where:
123123
parameter-name: Pipeline
@@ -244,4 +244,10 @@ directive:
244244
subject: ^ListPendingFlow
245245
set:
246246
subject: PendingFlow
247+
248+
## Hide execute action cmdlet. This is exposed by custom commands
249+
- where:
250+
verb: Invoke
251+
subject: ^ExecutePipelineAction
252+
hide: true
247253
```
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<#
2+
.SYNOPSIS
3+
Disables Azure Data Transfer connections.
4+
5+
.DESCRIPTION
6+
The Disable-AzDataTransferConnection cmdlet disables Azure Data Transfer connections.
7+
This prevents data transfer operations on the connections and disables all flows within them.
8+
9+
.PARAMETER PipelineName
10+
The name of the pipeline containing the connections.
11+
12+
.PARAMETER ResourceGroupName
13+
The name of the resource group containing the pipeline.
14+
15+
.PARAMETER ConnectionId
16+
One or more connection resource IDs to disable. These should be full ARM resource IDs.
17+
18+
.PARAMETER SubscriptionId
19+
The ID of the target subscription. If not specified, uses the current context subscription.
20+
21+
.PARAMETER Justification
22+
Business justification for disabling the connections.
23+
24+
.PARAMETER DefaultProfile
25+
The credentials, account, tenant, and subscription used for communication with Azure.
26+
27+
.PARAMETER AsJob
28+
Run the command as a job.
29+
30+
.PARAMETER NoWait
31+
Run the command asynchronously.
32+
33+
.EXAMPLE
34+
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection01"
35+
36+
Disables a single connection.
37+
38+
.EXAMPLE
39+
$connectionIds = @(
40+
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection01",
41+
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.AzureDataTransfer/connections/Connection02"
42+
)
43+
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionIds
44+
45+
Disables multiple connections.
46+
47+
.EXAMPLE
48+
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionId -Justification "Security incident response"
49+
50+
Disables a connection with a business justification.
51+
52+
.EXAMPLE
53+
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionId -WhatIf
54+
55+
Shows what would happen if the connection was disabled without actually disabling it.
56+
57+
.NOTES
58+
This action will also disable all flows within the specified connections.
59+
#>
60+
function Disable-AzDataTransferConnection {
61+
[OutputType([ADT.Models.IPipeline])]
62+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='High')]
63+
param(
64+
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline containing the connections")]
65+
[ValidateNotNullOrEmpty()]
66+
[string]$PipelineName,
67+
68+
[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
69+
[ValidateNotNullOrEmpty()]
70+
[string]$ResourceGroupName,
71+
72+
[Parameter(Mandatory=$true, HelpMessage="One or more connection resource IDs to disable")]
73+
[ValidateNotNullOrEmpty()]
74+
[string[]]$ConnectionId,
75+
76+
[Parameter(HelpMessage="The ID of the target subscription")]
77+
[string]$SubscriptionId,
78+
79+
[Parameter(HelpMessage="Business justification for disabling the connections")]
80+
[string]$Justification,
81+
82+
[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
83+
[PSObject]$DefaultProfile,
84+
85+
[Parameter(HelpMessage="Run the command as a job")]
86+
[switch]$AsJob,
87+
88+
[Parameter(HelpMessage="Run the command asynchronously")]
89+
[switch]$NoWait
90+
)
91+
92+
begin {
93+
Write-Verbose "Disabling $($ConnectionId.Count) connection(s) in pipeline: $PipelineName"
94+
Write-Warning "This action will disable the specified connections and all flows within them."
95+
}
96+
97+
process {
98+
$connectionList = $ConnectionId -join ", "
99+
if ($PSCmdlet.ShouldProcess($connectionList, "Disable Azure Data Transfer Connection(s)")) {
100+
try {
101+
# Prepare parameters for the underlying command
102+
$invokeParams = @{
103+
PipelineName = $PipelineName
104+
ResourceGroupName = $ResourceGroupName
105+
ActionType = "ForceDisable"
106+
Target = $ConnectionId
107+
TargetType = "Connection"
108+
}
109+
110+
# Add optional parameters if provided
111+
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
112+
if ($Justification) { $invokeParams.Justification = $Justification }
113+
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
114+
if ($AsJob) { $invokeParams.AsJob = $AsJob }
115+
if ($NoWait) { $invokeParams.NoWait = $NoWait }
116+
117+
# Call the underlying command and return the result
118+
$result = Invoke-AzDataTransferExecutePipelineAction @invokeParams
119+
return $result
120+
}
121+
catch {
122+
$PSCmdlet.ThrowTerminatingError($_)
123+
}
124+
}
125+
}
126+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<#
2+
.SYNOPSIS
3+
Disables Azure Data Transfer flow types.
4+
5+
.DESCRIPTION
6+
The Disable-AzDataTransferFlowType cmdlet disables flow types within an Azure Data Transfer pipeline.
7+
This prevents new flows of the specified types from being created and disables existing flows of those types.
8+
9+
.PARAMETER PipelineName
10+
The name of the pipeline containing the flow types.
11+
12+
.PARAMETER ResourceGroupName
13+
The name of the resource group containing the pipeline.
14+
15+
.PARAMETER FlowType
16+
One or more flow type names to disable (e.g., "FlowType01", "FlowType02").
17+
18+
.PARAMETER SubscriptionId
19+
The ID of the target subscription. If not specified, uses the current context subscription.
20+
21+
.PARAMETER Justification
22+
Business justification for disabling the flow types.
23+
24+
.PARAMETER DefaultProfile
25+
The credentials, account, tenant, and subscription used for communication with Azure.
26+
27+
.PARAMETER AsJob
28+
Run the command as a job.
29+
30+
.PARAMETER NoWait
31+
Run the command asynchronously.
32+
33+
.EXAMPLE
34+
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01"
35+
36+
Disables the "FlowType01" flow type.
37+
38+
.EXAMPLE
39+
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType @("FlowType01", "FlowType02")
40+
41+
Disables both "FlowType01" and "FlowType02" flow types.
42+
43+
.EXAMPLE
44+
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01" -Justification "Security incident response"
45+
46+
Disables a flow type with a business justification.
47+
48+
.EXAMPLE
49+
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01" -WhatIf
50+
51+
Shows what would happen if the flow type was disabled without actually disabling it.
52+
53+
.NOTES
54+
This action will disable all flows of the specified types across all connections in the pipeline.
55+
#>
56+
function Disable-AzDataTransferFlowType {
57+
[OutputType([ADT.Models.IPipeline])]
58+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='High')]
59+
param(
60+
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline containing the flow types")]
61+
[ValidateNotNullOrEmpty()]
62+
[string]$PipelineName,
63+
64+
[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
65+
[ValidateNotNullOrEmpty()]
66+
[string]$ResourceGroupName,
67+
68+
[Parameter(Mandatory=$true, HelpMessage="One or more flow type names to disable")]
69+
[ValidateNotNullOrEmpty()]
70+
[string[]]$FlowType,
71+
72+
[Parameter(HelpMessage="The ID of the target subscription")]
73+
[string]$SubscriptionId,
74+
75+
[Parameter(HelpMessage="Business justification for disabling the flow types")]
76+
[string]$Justification,
77+
78+
[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
79+
[PSObject]$DefaultProfile,
80+
81+
[Parameter(HelpMessage="Run the command as a job")]
82+
[switch]$AsJob,
83+
84+
[Parameter(HelpMessage="Run the command asynchronously")]
85+
[switch]$NoWait
86+
)
87+
88+
begin {
89+
Write-Verbose "Disabling flow type(s): $($FlowType -join ', ') in pipeline: $PipelineName"
90+
Write-Warning "This action will disable all flows of the specified types across all connections in the pipeline."
91+
92+
# Validate flow type names (basic validation - actual valid values depend on the service)
93+
foreach ($type in $FlowType) {
94+
if ([string]::IsNullOrWhiteSpace($type)) {
95+
throw "Flow type cannot be null or empty"
96+
}
97+
}
98+
}
99+
100+
process {
101+
$flowTypeList = $FlowType -join ", "
102+
if ($PSCmdlet.ShouldProcess($flowTypeList, "Disable Azure Data Transfer Flow Type(s)")) {
103+
try {
104+
# Prepare parameters for the underlying command
105+
$invokeParams = @{
106+
PipelineName = $PipelineName
107+
ResourceGroupName = $ResourceGroupName
108+
ActionType = "ForceDisable"
109+
Target = $FlowType
110+
TargetType = "FlowType"
111+
}
112+
113+
# Add optional parameters if provided
114+
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
115+
if ($Justification) { $invokeParams.Justification = $Justification }
116+
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
117+
if ($AsJob) { $invokeParams.AsJob = $AsJob }
118+
if ($NoWait) { $invokeParams.NoWait = $NoWait }
119+
120+
# Call the underlying command and return the result
121+
$result = Invoke-AzDataTransferExecutePipelineAction @invokeParams
122+
return $result
123+
}
124+
catch {
125+
$PSCmdlet.ThrowTerminatingError($_)
126+
}
127+
}
128+
}
129+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<#
2+
.SYNOPSIS
3+
Disables an Azure Data Transfer pipeline.
4+
5+
.DESCRIPTION
6+
The Disable-AzDataTransferPipeline cmdlet disables an Azure Data Transfer pipeline.
7+
This prevents new connections and flows from being created within the pipeline and disables existing resources.
8+
9+
.PARAMETER PipelineName
10+
The name of the pipeline to disable.
11+
12+
.PARAMETER ResourceGroupName
13+
The name of the resource group containing the pipeline.
14+
15+
.PARAMETER SubscriptionId
16+
The ID of the target subscription. If not specified, uses the current context subscription.
17+
18+
.PARAMETER Justification
19+
Business justification for disabling the pipeline.
20+
21+
.PARAMETER DefaultProfile
22+
The credentials, account, tenant, and subscription used for communication with Azure.
23+
24+
.PARAMETER AsJob
25+
Run the command as a job.
26+
27+
.PARAMETER NoWait
28+
Run the command asynchronously.
29+
30+
.EXAMPLE
31+
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01"
32+
33+
Disables the pipeline named "Pipeline01" in the "ResourceGroup01" resource group.
34+
35+
.EXAMPLE
36+
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -Justification "Emergency shutdown for security review"
37+
38+
Disables the pipeline with a business justification.
39+
40+
.EXAMPLE
41+
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -WhatIf
42+
43+
Shows what would happen if the pipeline was disabled without actually disabling it.
44+
#>
45+
function Disable-AzDataTransferPipeline {
46+
[OutputType([ADT.Models.IPipeline])]
47+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='High')]
48+
param(
49+
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline to disable")]
50+
[ValidateNotNullOrEmpty()]
51+
[string]$PipelineName,
52+
53+
[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
54+
[ValidateNotNullOrEmpty()]
55+
[string]$ResourceGroupName,
56+
57+
[Parameter(HelpMessage="The ID of the target subscription")]
58+
[string]$SubscriptionId,
59+
60+
[Parameter(HelpMessage="Business justification for disabling the pipeline")]
61+
[string]$Justification,
62+
63+
[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
64+
[PSObject]$DefaultProfile,
65+
66+
[Parameter(HelpMessage="Run the command as a job")]
67+
[switch]$AsJob,
68+
69+
[Parameter(HelpMessage="Run the command asynchronously")]
70+
[switch]$NoWait
71+
)
72+
73+
begin {
74+
Write-Verbose "Disabling pipeline: $PipelineName"
75+
Write-Warning "This action will disable the entire pipeline and all its connections and flows."
76+
}
77+
78+
process {
79+
if ($PSCmdlet.ShouldProcess($PipelineName, "Disable Azure Data Transfer Pipeline")) {
80+
try {
81+
# Prepare parameters for the underlying command
82+
$invokeParams = @{
83+
PipelineName = $PipelineName
84+
ResourceGroupName = $ResourceGroupName
85+
ActionType = "ForceDisable"
86+
Target = @()
87+
TargetType = "Pipeline"
88+
}
89+
90+
# Add optional parameters if provided
91+
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
92+
if ($Justification) { $invokeParams.Justification = $Justification }
93+
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
94+
if ($AsJob) { $invokeParams.AsJob = $AsJob }
95+
if ($NoWait) { $invokeParams.NoWait = $NoWait }
96+
97+
# Call the underlying command and return the result
98+
$result = Invoke-AzDataTransferExecutePipelineAction @invokeParams
99+
return $result
100+
}
101+
catch {
102+
$PSCmdlet.ThrowTerminatingError($_)
103+
}
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)