Skip to content

Add Red Button commands for AzureDataTransfer #28372

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion src/DataTransfer/DataTransfer.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ directive:
# - remove-operation: Pipelines_ListBySubscription
- remove-operation: Operations_List
- remove-operation: ListFlowsByPipeline_List
- remove-operation: Pipelines_ExecuteAction
# - remove-operation: Pipelines_ExecuteAction

- where:
parameter-name: Pipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<#
.SYNOPSIS
Disables Azure Data Transfer connections.

.DESCRIPTION
The Disable-AzDataTransferConnection cmdlet disables Azure Data Transfer connections.
This prevents data transfer operations on the connections and disables all flows within them.

.PARAMETER PipelineName
The name of the pipeline containing the connections.

.PARAMETER ResourceGroupName
The name of the resource group containing the pipeline.

.PARAMETER ConnectionId
One or more connection resource IDs to disable. These should be full ARM resource IDs.

.PARAMETER SubscriptionId
The ID of the target subscription. If not specified, uses the current context subscription.

.PARAMETER Justification
Business justification for disabling the connections.

.PARAMETER DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

.PARAMETER AsJob
Run the command as a job.

.PARAMETER NoWait
Run the command asynchronously.

.EXAMPLE
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Private.AzureDataTransfer/connections/Connection01"

Disables a single connection.

.EXAMPLE
$connectionIds = @(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Private.AzureDataTransfer/connections/Connection01",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Private.AzureDataTransfer/connections/Connection02"
)
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionIds

Disables multiple connections.

.EXAMPLE
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionId -Justification "Security incident response"

Disables a connection with a business justification.

.EXAMPLE
Disable-AzDataTransferConnection -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -ConnectionId $connectionId -WhatIf

Shows what would happen if the connection was disabled without actually disabling it.

.NOTES
This is a wrapper around Invoke-AzDataTransferExecutePipelineAction with ActionType "ForceDisable" and TargetType "Connection".
This action will also disable all flows within the specified connections.
#>
function Disable-AzDataTransferConnection {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline containing the connections")]
[ValidateNotNullOrEmpty()]
[string]$PipelineName,

[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName,

[Parameter(Mandatory=$true, HelpMessage="One or more connection resource IDs to disable")]
[ValidateNotNullOrEmpty()]
[string[]]$ConnectionId,

[Parameter(HelpMessage="The ID of the target subscription")]
[string]$SubscriptionId,

[Parameter(HelpMessage="Business justification for disabling the connections")]
[string]$Justification,

[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
[PSObject]$DefaultProfile,

[Parameter(HelpMessage="Run the command as a job")]
[switch]$AsJob,

[Parameter(HelpMessage="Run the command asynchronously")]
[switch]$NoWait
)

begin {
Write-Verbose "Disabling $($ConnectionId.Count) connection(s) in pipeline: $PipelineName"
Write-Warning "This action will disable the specified connections and all flows within them."
}

process {
$connectionList = $ConnectionId -join ", "
if ($PSCmdlet.ShouldProcess($connectionList, "Disable Azure Data Transfer Connection(s)")) {
try {
# Prepare parameters for the underlying command
$invokeParams = @{
PipelineName = $PipelineName
ResourceGroupName = $ResourceGroupName
ActionType = "ForceDisable"
Target = $ConnectionId
TargetType = "Connection"
}

# Add optional parameters if provided
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
if ($Justification) { $invokeParams.Justification = $Justification }
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
if ($AsJob) { $invokeParams.AsJob = $AsJob }
if ($NoWait) { $invokeParams.NoWait = $NoWait }

# Call the underlying command
Invoke-AzDataTransferExecutePipelineAction @invokeParams
}
catch {
$PSCmdlet.ThrowTerminatingError($_)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<#
.SYNOPSIS
Disables Azure Data Transfer flow types.

.DESCRIPTION
The Disable-AzDataTransferFlowType cmdlet disables flow types within an Azure Data Transfer pipeline.
This prevents new flows of the specified types from being created and disables existing flows of those types.

.PARAMETER PipelineName
The name of the pipeline containing the flow types.

.PARAMETER ResourceGroupName
The name of the resource group containing the pipeline.

.PARAMETER FlowType
One or more flow type names to disable (e.g., "FlowType01", "FlowType02").

.PARAMETER SubscriptionId
The ID of the target subscription. If not specified, uses the current context subscription.

.PARAMETER Justification
Business justification for disabling the flow types.

.PARAMETER DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

.PARAMETER AsJob
Run the command as a job.

.PARAMETER NoWait
Run the command asynchronously.

.EXAMPLE
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01"

Disables the "FlowType01" flow type.

.EXAMPLE
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType @("FlowType01", "FlowType02")

Disables both "FlowType01" and "FlowType02" flow types.

.EXAMPLE
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01" -Justification "Security incident response"

Disables a flow type with a business justification.

.EXAMPLE
Disable-AzDataTransferFlowType -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -FlowType "FlowType01" -WhatIf

Shows what would happen if the flow type was disabled without actually disabling it.

.NOTES
This is a wrapper around Invoke-AzDataTransferExecutePipelineAction with ActionType "ForceDisable" and TargetType "FlowType".
This action will disable all flows of the specified types across all connections in the pipeline.
#>
function Disable-AzDataTransferFlowType {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline containing the flow types")]
[ValidateNotNullOrEmpty()]
[string]$PipelineName,

[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName,

[Parameter(Mandatory=$true, HelpMessage="One or more flow type names to disable")]
[ValidateNotNullOrEmpty()]
[string[]]$FlowType,

[Parameter(HelpMessage="The ID of the target subscription")]
[string]$SubscriptionId,

[Parameter(HelpMessage="Business justification for disabling the flow types")]
[string]$Justification,

[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
[PSObject]$DefaultProfile,

[Parameter(HelpMessage="Run the command as a job")]
[switch]$AsJob,

[Parameter(HelpMessage="Run the command asynchronously")]
[switch]$NoWait
)

begin {
Write-Verbose "Disabling flow type(s): $($FlowType -join ', ') in pipeline: $PipelineName"
Write-Warning "This action will disable all flows of the specified types across all connections in the pipeline."

# Validate flow type names (basic validation - actual valid values depend on the service)
foreach ($type in $FlowType) {
if ([string]::IsNullOrWhiteSpace($type)) {
throw "Flow type cannot be null or empty"
}
}
}

process {
$flowTypeList = $FlowType -join ", "
if ($PSCmdlet.ShouldProcess($flowTypeList, "Disable Azure Data Transfer Flow Type(s)")) {
try {
# Prepare parameters for the underlying command
$invokeParams = @{
PipelineName = $PipelineName
ResourceGroupName = $ResourceGroupName
ActionType = "ForceDisable"
Target = $FlowType
TargetType = "FlowType"
}

# Add optional parameters if provided
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
if ($Justification) { $invokeParams.Justification = $Justification }
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
if ($AsJob) { $invokeParams.AsJob = $AsJob }
if ($NoWait) { $invokeParams.NoWait = $NoWait }

# Call the underlying command
Invoke-AzDataTransferExecutePipelineAction @invokeParams
}
catch {
$PSCmdlet.ThrowTerminatingError($_)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<#
.SYNOPSIS
Disables an Azure Data Transfer pipeline.

.DESCRIPTION
The Disable-AzDataTransferPipeline cmdlet disables an Azure Data Transfer pipeline.
This prevents new connections and flows from being created within the pipeline and disables existing resources.

.PARAMETER PipelineName
The name of the pipeline to disable.

.PARAMETER ResourceGroupName
The name of the resource group containing the pipeline.

.PARAMETER SubscriptionId
The ID of the target subscription. If not specified, uses the current context subscription.

.PARAMETER Justification
Business justification for disabling the pipeline.

.PARAMETER DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

.PARAMETER AsJob
Run the command as a job.

.PARAMETER NoWait
Run the command asynchronously.

.EXAMPLE
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01"

Disables the pipeline named "Pipeline01" in the "ResourceGroup01" resource group.

.EXAMPLE
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -Justification "Emergency shutdown for security review"

Disables the pipeline with a business justification.

.EXAMPLE
Disable-AzDataTransferPipeline -PipelineName "Pipeline01" -ResourceGroupName "ResourceGroup01" -WhatIf

Shows what would happen if the pipeline was disabled without actually disabling it.

.NOTES
This is a wrapper around Invoke-AzDataTransferExecutePipelineAction with ActionType "ForceDisable" and TargetType "Pipeline".
#>
function Disable-AzDataTransferPipeline {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, HelpMessage="The name of the pipeline to disable")]
[ValidateNotNullOrEmpty()]
[string]$PipelineName,

[Parameter(Mandatory=$true, HelpMessage="The name of the resource group")]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName,

[Parameter(HelpMessage="The ID of the target subscription")]
[string]$SubscriptionId,

[Parameter(HelpMessage="Business justification for disabling the pipeline")]
[string]$Justification,

[Parameter(HelpMessage="The credentials, account, tenant, and subscription used for communication with Azure")]
[PSObject]$DefaultProfile,

[Parameter(HelpMessage="Run the command as a job")]
[switch]$AsJob,

[Parameter(HelpMessage="Run the command asynchronously")]
[switch]$NoWait
)

begin {
Write-Verbose "Disabling pipeline: $PipelineName"
Write-Warning "This action will disable the entire pipeline and all its connections and flows."
}

process {
if ($PSCmdlet.ShouldProcess($PipelineName, "Disable Azure Data Transfer Pipeline")) {
try {
# Prepare parameters for the underlying command
$invokeParams = @{
PipelineName = $PipelineName
ResourceGroupName = $ResourceGroupName
ActionType = "ForceDisable"
Target = @()
TargetType = "Pipeline"
}

# Add optional parameters if provided
if ($SubscriptionId) { $invokeParams.SubscriptionId = $SubscriptionId }
if ($Justification) { $invokeParams.Justification = $Justification }
if ($DefaultProfile) { $invokeParams.DefaultProfile = $DefaultProfile }
if ($AsJob) { $invokeParams.AsJob = $AsJob }
if ($NoWait) { $invokeParams.NoWait = $NoWait }

# Call the underlying command
Invoke-AzDataTransferExecutePipelineAction @invokeParams
}
catch {
$PSCmdlet.ThrowTerminatingError($_)
}
}
}
}
Loading