Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez un objet securityAction .
Cette API est disponible dans les déploiements de cloud national suivants.
| Service global |
Gouvernement des États-Unis L4 |
Us Government L5 (DOD) |
Chine gérée par 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme moins privilégiées pour cette API. Utilisez une autorisation ou des autorisations privilégiées plus élevées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, consultez Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez les informations de référence sur les autorisations.
| Type d’autorisation |
Autorisations avec privilèges minimum |
Autorisations privilégiées plus élevées |
| Déléguée (compte professionnel ou scolaire) |
Non prise en charge. |
Non prise en charge. |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
SecurityActions.ReadWrite.All |
Non disponible. |
Requête HTTP
POST /security/securityActions
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON d’un objet securityAction .
Réponse
Si elle réussit, cette méthode renvoie un 201 Created code de réponse et un objet securityAction dans le corps de la réponse.
Exemples
Demande
L’exemple suivant illustre une demande.
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);
// 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)
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ici peut être raccourci pour plus de lisibilité.
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"
}
]
}