创建 securityAction
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
创建新的 securityAction 对象。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
不支持。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
SecurityActions.ReadWrite.All |
HTTP 请求
POST /security/securityActions
| 名称 |
说明 |
| Authorization |
Bearer {code} |
请求正文
在请求正文中,提供 securityAction 对象的 JSON 表示形式。
响应
如果成功,此方法在 201 Created 响应正文中返回 响应代码和 securityAction 对象。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/security/securityActions
Content-type: application/json
{
"name": "BlockIp",
"actionReason": "Test",
"parameters": [
{
"name": "IP",
"value": "1.2.3.4"
}
],
"vendorInformation": {
"provider": "Windows Defender ATP",
"vendor": "Microsoft"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var securityAction = 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"
}
};
await graphClient.Security.SecurityActions
.Request()
.AddAsync(securityAction);
const options = {
authProvider,
};
const client = Client.init(options);
const securityAction = {
name: 'BlockIp',
actionReason: 'Test',
parameters: [
{
name: 'IP',
value: '1.2.3.4'
}
],
vendorInformation: {
provider: 'Windows Defender ATP',
vendor: 'Microsoft'
}
};
await client.api('/security/securityActions')
.version('beta')
.post(securityAction);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/security/securityActions"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphSecurityAction *securityAction = [[MSGraphSecurityAction alloc] init];
[securityAction setName:@"BlockIp"];
[securityAction setActionReason:@"Test"];
NSMutableArray *parametersList = [[NSMutableArray alloc] init];
MSGraphKeyValuePair *parameters = [[MSGraphKeyValuePair alloc] init];
[parameters setName:@"IP"];
[parameters setValue:@"1.2.3.4"];
[parametersList addObject: parameters];
[securityAction setParameters:parametersList];
MSGraphSecurityVendorInformation *vendorInformation = [[MSGraphSecurityVendorInformation alloc] init];
[vendorInformation setProvider:@"Windows Defender ATP"];
[vendorInformation setVendor:@"Microsoft"];
[securityAction setVendorInformation:vendorInformation];
NSError *error;
NSData *securityActionData = [securityAction getSerializedDataWithError:&error];
[urlRequest setHTTPBody:securityActionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SecurityAction securityAction = new SecurityAction();
securityAction.name = "BlockIp";
securityAction.actionReason = "Test";
LinkedList<KeyValuePair> parametersList = new LinkedList<KeyValuePair>();
KeyValuePair parameters = new KeyValuePair();
parameters.name = "IP";
parameters.value = "1.2.3.4";
parametersList.add(parameters);
securityAction.parameters = parametersList;
SecurityVendorInformation vendorInformation = new SecurityVendorInformation();
vendorInformation.provider = "Windows Defender ATP";
vendorInformation.vendor = "Microsoft";
securityAction.vendorInformation = vendorInformation;
graphClient.security().securityActions()
.buildRequest()
.post(securityAction);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewSecurityAction()
name := "BlockIp"
requestBody.SetName(&name)
actionReason := "Test"
requestBody.SetActionReason(&actionReason)
requestBody.SetParameters( []KeyValuePair {
msgraphsdk.NewKeyValuePair(),
name := "IP"
SetName(&name)
value := "1.2.3.4"
SetValue(&value)
}
vendorInformation := msgraphsdk.NewSecurityVendorInformation()
requestBody.SetVendorInformation(vendorInformation)
provider := "Windows Defender ATP"
vendorInformation.SetProvider(&provider)
vendor := "Microsoft"
vendorInformation.SetVendor(&vendor)
result, err := graphClient.Security().SecurityActions().Post(requestBody)
Import-Module Microsoft.Graph.Security
$params = @{
Name = "BlockIp"
ActionReason = "Test"
Parameters = @(
@{
Name = "IP"
Value = "1.2.3.4"
}
)
VendorInformation = @{
Provider = "Windows Defender ATP"
Vendor = "Microsoft"
}
}
New-MgSecurityAction -BodyParameter $params
响应
下面展示了示例响应。
备注
为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"id" : "1234567890",
"status" : "notStarted",
"createdDateTime": "2019-01-10 12:23:23.33333",
"lastActionDateTime": "2019-01-10 12:23:23.33333",
"name": "blockIp",
"actionReason": "Test",
"errorInfo": null,
"vendorInformation": {
"provider": "Windows Defender ATP",
"providerVersion": null,
"subProvider": null,
"vendor": "Microsoft"
},
"parameters": [
{
"name": "IP",
"value": "1.2.3.4"
}
]
}