Пространство имен: microsoft.graph
Важно!
API версии /beta
в Microsoft Graph могут быть изменены. Использование этих API в производственных приложениях не поддерживается. Чтобы определить, доступен ли API в версии 1.0, используйте селектор версий.
Создайте новый объект securityAction .
Этот API доступен в следующих национальных облачных развертываниях.
Глобальная служба |
Правительство США L4 |
Правительство США L5 (DOD) |
Китай управляется 21Vianet |
✅ |
❌ |
❌ |
❌ |
Разрешения
Выберите разрешение или разрешения, помеченные как наименее привилегированные для этого API. Используйте более привилегированное разрешение или разрешения только в том случае, если это требуется приложению. Дополнительные сведения о делегированных разрешениях и разрешениях приложений см. в разделе Типы разрешений. Дополнительные сведения об этих разрешениях см. в справочнике по разрешениям.
Тип разрешения |
Разрешения с наименьшими привилегиями |
Более высокие привилегированные разрешения |
Делегированные (рабочая или учебная учетная запись) |
Не поддерживается. |
Не поддерживается. |
Делегированные (личная учетная запись Майкрософт) |
Не поддерживается. |
Не поддерживается. |
Приложение |
SecurityActions.ReadWrite.All |
Недоступно. |
HTTP-запрос
POST /security/securityActions
Текст запроса
В тексте запроса укажите представление объекта 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"
}
}
// 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);
mgc-beta security security-actions create --body '{\
"name": "BlockIp",\
"actionReason": "Test",\
"parameters": [\
{\
"name": "IP",\
"value": "1.2.3.4"\
}\
],\
"vendorInformation": {\
"provider": "Windows Defender ATP",\
"vendor": "Microsoft"\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSecurityAction()
name := "BlockIp"
requestBody.SetName(&name)
actionReason := "Test"
requestBody.SetActionReason(&actionReason)
keyValuePair := graphmodels.NewKeyValuePair()
name := "IP"
keyValuePair.SetName(&name)
value := "1.2.3.4"
keyValuePair.SetValue(&value)
parameters := []graphmodels.KeyValuePairable {
keyValuePair,
}
requestBody.SetParameters(parameters)
vendorInformation := graphmodels.NewSecurityVendorInformation()
provider := "Windows Defender ATP"
vendorInformation.SetProvider(&provider)
vendor := "Microsoft"
vendorInformation.SetVendor(&vendor)
requestBody.SetVendorInformation(vendorInformation)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
securityActions, err := graphClient.Security().SecurityActions().Post(context.Background(), requestBody, nil)
// 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);
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);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\SecurityAction;
use Microsoft\Graph\Beta\Generated\Models\KeyValuePair;
use Microsoft\Graph\Beta\Generated\Models\SecurityVendorInformation;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SecurityAction();
$requestBody->setName('BlockIp');
$requestBody->setActionReason('Test');
$parametersKeyValuePair1 = new KeyValuePair();
$parametersKeyValuePair1->setName('IP');
$parametersKeyValuePair1->setValue('1.2.3.4');
$parametersArray []= $parametersKeyValuePair1;
$requestBody->setParameters($parametersArray);
$vendorInformation = new SecurityVendorInformation();
$vendorInformation->setProvider('Windows Defender ATP');
$vendorInformation->setVendor('Microsoft');
$requestBody->setVendorInformation($vendorInformation);
$result = $graphServiceClient->security()->securityActions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Security
$params = @{
name = "BlockIp"
actionReason = "Test"
parameters = @(
@{
name = "IP"
value = "1.2.3.4"
}
)
vendorInformation = @{
provider = "Windows Defender ATP"
vendor = "Microsoft"
}
}
New-MgBetaSecurityAction -BodyParameter $params
# 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)
Отклик
Ниже показан пример отклика.
Примечание. Объект отклика, показанный здесь, может быть сокращен для удобочитаемости.
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"
}
]
}