Skip to content

Commit

Permalink
Merge pull request #9106 from Azure/o365actionsadd
Browse files Browse the repository at this point in the history
addition of two new actions in o365
  • Loading branch information
manishkumar1991 authored Sep 27, 2023
2 parents 4c247f6 + edda132 commit ed2c885
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$flag = 0
# Write to the Azure Functions log stream.
Write-Host "Fetching list of Malware policies"

$Mailbox = $Request.Body.Mailbox
# Interact with query parameters or the body of the request.

try{
if($Mailbox)
{
$Result = Get-InboxRule -Mailbox "$Mailbox"
if($?){Write-Host "Successfully fetched list of Inbox Rules"
$flag = 1
}
else
{Write-Host "Failed to fetch list of Inbox Rules"}

}else
{Write-Host "Mailbox not provided : Failed to fetch list of Inbox Rules"}
}

catch{
Write-Host "$_.Exception"
$Result = "$_.Exception"
}

finally{
if($flag){
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Result
})}else{

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::NotFound
Body = $Result
})
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$flag = 0
# Write to the Azure Functions log stream.
Write-Host "Proceeding with delete of Inbox Rule"

$Mailbox = $Request.Body.Mailbox
$Identity = $Request.Body.Identity
# Interact with query parameters or the body of the request.

try{
if($Mailbox -AND $Identity)
{
$Result = Remove-InboxRule -Mailbox "$Mailbox" -Identity "$Identity" -Confirm:$false
if($?){Write-Host "Successfully Deleted the rule"
$flag = 1
}
else
{Write-Host "Failed to delete Inbox Rules"}

}else
{Write-Host "Mailbox or Identity not provided : Failed to delete Inbox Rules"}
}

catch{
Write-Host "$_.Exception"
$Result = "$_.Exception"
}

finally{
if($flag){
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Result
})}else{

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::NotFound
Body = $Result
})
}
}

0 comments on commit ed2c885

Please sign in to comment.