// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new SecurityAction
{
Name = "BlockIp",
ActionReason = "Test",
Parameters = new List<KeyValuePair>
{
new KeyValuePair
{
Name = "IP",
Value = "1.2.3.4",
},
},
VendorInformation = new SecurityVendorInformation
{
Provider = "Windows Defender ATP",
Vendor = "Microsoft",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.SecurityActions.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SecurityAction securityAction = new SecurityAction();
securityAction.setName("BlockIp");
securityAction.setActionReason("Test");
LinkedList<KeyValuePair> parameters = new LinkedList<KeyValuePair>();
KeyValuePair keyValuePair = new KeyValuePair();
keyValuePair.setName("IP");
keyValuePair.setValue("1.2.3.4");
parameters.add(keyValuePair);
securityAction.setParameters(parameters);
SecurityVendorInformation vendorInformation = new SecurityVendorInformation();
vendorInformation.setProvider("Windows Defender ATP");
vendorInformation.setVendor("Microsoft");
securityAction.setVendorInformation(vendorInformation);
SecurityAction result = graphClient.security().securityActions().post(securityAction);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.security_action import SecurityAction
from msgraph_beta.generated.models.key_value_pair import KeyValuePair
from msgraph_beta.generated.models.security_vendor_information import SecurityVendorInformation
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SecurityAction(
name = "BlockIp",
action_reason = "Test",
parameters = [
KeyValuePair(
name = "IP",
value = "1.2.3.4",
),
],
vendor_information = SecurityVendorInformation(
provider = "Windows Defender ATP",
vendor = "Microsoft",
),
)
result = await graph_client.security.security_actions.post(request_body)