APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Compliance changes like content approvals which result in the automatic creation of deployments using the audience and deploymentSettings of the policy.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Beta.Models.WindowsUpdates.UpdatePolicy
{
OdataType = "#microsoft.graph.windowsUpdates.updatePolicy",
Audience = new Microsoft.Graph.Beta.Models.WindowsUpdates.DeploymentAudience
{
Id = "8c4eb1eb-d7a3-4633-8e2f-f926e82df08e",
},
ComplianceChanges = new List<Microsoft.Graph.Beta.Models.WindowsUpdates.ComplianceChange>
{
new Microsoft.Graph.Beta.Models.WindowsUpdates.ComplianceChange
{
OdataType = "#microsoft.graph.windowsUpdates.contentApproval",
},
},
ComplianceChangeRules = new List<Microsoft.Graph.Beta.Models.WindowsUpdates.ComplianceChangeRule>
{
new Microsoft.Graph.Beta.Models.WindowsUpdates.ComplianceChangeRule
{
OdataType = "#microsoft.graph.windowsUpdates.contentApprovalRule",
AdditionalData = new Dictionary<string, object>
{
{
"contentFilter" , new
{
OdataType = "#microsoft.graph.windowsUpdates.driverUpdateFilter",
}
},
{
"durationBeforeDeploymentStart" , "P7D"
},
},
},
},
DeploymentSettings = new Microsoft.Graph.Beta.Models.WindowsUpdates.DeploymentSettings
{
OdataType = "microsoft.graph.windowsUpdates.deploymentSettings",
Schedule = new Microsoft.Graph.Beta.Models.WindowsUpdates.ScheduleSettings
{
GradualRollout = new Microsoft.Graph.Beta.Models.WindowsUpdates.GradualRolloutSettings
{
OdataType = "#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings",
DurationBetweenOffers = TimeSpan.Parse("P1D"),
AdditionalData = new Dictionary<string, object>
{
{
"devicePerOffer" , 1000
},
},
},
},
},
};
var result = await graphClient.Admin.Windows.Updates.UpdatePolicies.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UpdatePolicy updatePolicy = new UpdatePolicy();
DeploymentAudience audience = new DeploymentAudience();
audience.id = "8c4eb1eb-d7a3-4633-8e2f-f926e82df08e";
updatePolicy.audience = audience;
LinkedList<ComplianceChange> complianceChangesList = new LinkedList<ComplianceChange>();
ContentApproval complianceChanges = new ContentApproval();
complianceChangesList.add(complianceChanges);
ComplianceChangeCollectionResponse complianceChangeCollectionResponse = new ComplianceChangeCollectionResponse();
complianceChangeCollectionResponse.value = complianceChangesList;
ComplianceChangeCollectionPage complianceChangeCollectionPage = new ComplianceChangeCollectionPage(complianceChangeCollectionResponse, null);
updatePolicy.complianceChanges = complianceChangeCollectionPage;
LinkedList<ComplianceChangeRule> complianceChangeRulesList = new LinkedList<ComplianceChangeRule>();
ContentApprovalRule complianceChangeRules = new ContentApprovalRule();
DriverUpdateFilter contentFilter = new DriverUpdateFilter();
complianceChangeRules.contentFilter = contentFilter;
complianceChangeRules.durationBeforeDeploymentStart = DatatypeFactory.newInstance().newDuration("P7D");
complianceChangeRulesList.add(complianceChangeRules);
updatePolicy.complianceChangeRules = complianceChangeRulesList;
DeploymentSettings deploymentSettings = new DeploymentSettings();
ScheduleSettings schedule = new ScheduleSettings();
RateDrivenRolloutSettings gradualRollout = new RateDrivenRolloutSettings();
gradualRollout.durationBetweenOffers = DatatypeFactory.newInstance().newDuration("P1D");
gradualRollout.devicePerOffer = 1000;
schedule.gradualRollout = gradualRollout;
deploymentSettings.schedule = schedule;
updatePolicy.deploymentSettings = deploymentSettings;
graphClient.admin().windows().updates().updatePolicies()
.buildRequest()
.post(updatePolicy);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new UpdatePolicy();
$requestBody->set@odatatype('#microsoft.graph.windowsUpdates.updatePolicy');
$audience = new DeploymentAudience();
$audience->setId('8c4eb1eb-d7a3-4633-8e2f-f926e82df08e');
$requestBody->setAudience($audience);
$complianceChangesComplianceChange1 = new ComplianceChange();
$complianceChangesComplianceChange1->set@odatatype('#microsoft.graph.windowsUpdates.contentApproval');
$complianceChangesArray []= $complianceChangesComplianceChange1;
$requestBody->setComplianceChanges($complianceChangesArray);
$complianceChangeRulesComplianceChangeRule1 = new ComplianceChangeRule();
$complianceChangeRulesComplianceChangeRule1->set@odatatype('#microsoft.graph.windowsUpdates.contentApprovalRule');
$additionalData = [
'contentFilter' => $complianceChangeRulesComplianceChangeRule1 = new ContentFilter();
$ complianceChangeRulesComplianceChangeRule1->set@odatatype('#microsoft.graph.windowsUpdates.driverUpdateFilter');
$complianceChangeRulesComplianceChangeRule1->setContentFilter($contentFilter);
'durationBeforeDeploymentStart' => 'P7D',
];
$complianceChangeRulesComplianceChangeRule1->setAdditionalData($additionalData);
$complianceChangeRulesArray []= $complianceChangeRulesComplianceChangeRule1;
$requestBody->setComplianceChangeRules($complianceChangeRulesArray);
$deploymentSettings = new DeploymentSettings();
$deploymentSettings->set@odatatype('microsoft.graph.windowsUpdates.deploymentSettings');
$deploymentSettingsSchedule = new ScheduleSettings();
$deploymentSettingsScheduleGradualRollout = new GradualRolloutSettings();
$deploymentSettingsScheduleGradualRollout->set@odatatype('#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings');
$deploymentSettingsScheduleGradualRollout->setDurationBetweenOffers(new \DateInterval('P1D'));
$additionalData = [
'devicePerOffer' => 1000,
];
$deploymentSettingsScheduleGradualRollout->setAdditionalData($additionalData);
$deploymentSettingsSchedule->setGradualRollout($deploymentSettingsScheduleGradualRollout);
$deploymentSettings->setSchedule($deploymentSettingsSchedule);
$requestBody->setDeploymentSettings($deploymentSettings);
$result = $graphServiceClient->admin()->windows()->updates()->updatePolicies()->post($requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.