// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.WindowsUpdates;
var requestBody = new UpdatePolicy
{
OdataType = "#microsoft.graph.windowsUpdates.updatePolicy",
DeploymentSettings = new DeploymentSettings
{
OdataType = "microsoft.graph.windowsUpdates.deploymentSettings",
Schedule = new ScheduleSettings
{
GradualRollout = new RateDrivenRolloutSettings
{
OdataType = "#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings",
DurationBetweenOffers = TimeSpan.Parse("P1D"),
AdditionalData = new Dictionary<string, object>
{
{
"devicePerOffer" , 1000
},
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Admin.Windows.Updates.UpdatePolicies["{updatePolicy-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.windowsupdates.UpdatePolicy updatePolicy = new com.microsoft.graph.beta.models.windowsupdates.UpdatePolicy();
updatePolicy.setOdataType("#microsoft.graph.windowsUpdates.updatePolicy");
com.microsoft.graph.beta.models.windowsupdates.DeploymentSettings deploymentSettings = new com.microsoft.graph.beta.models.windowsupdates.DeploymentSettings();
deploymentSettings.setOdataType("microsoft.graph.windowsUpdates.deploymentSettings");
com.microsoft.graph.beta.models.windowsupdates.ScheduleSettings schedule = new com.microsoft.graph.beta.models.windowsupdates.ScheduleSettings();
com.microsoft.graph.beta.models.windowsupdates.RateDrivenRolloutSettings gradualRollout = new com.microsoft.graph.beta.models.windowsupdates.RateDrivenRolloutSettings();
gradualRollout.setOdataType("#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings");
PeriodAndDuration durationBetweenOffers = PeriodAndDuration.ofDuration(Duration.parse("P1D"));
gradualRollout.setDurationBetweenOffers(durationBetweenOffers);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("devicePerOffer", 1000);
gradualRollout.setAdditionalData(additionalData);
schedule.setGradualRollout(gradualRollout);
deploymentSettings.setSchedule(schedule);
updatePolicy.setDeploymentSettings(deploymentSettings);
com.microsoft.graph.models.windowsupdates.UpdatePolicy result = graphClient.admin().windows().updates().updatePolicies().byUpdatePolicyId("{updatePolicy-id}").patch(updatePolicy);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.windows_updates.update_policy import UpdatePolicy
from msgraph_beta.generated.models.windows_updates.deployment_settings import DeploymentSettings
from msgraph_beta.generated.models.windows_updates.schedule_settings import ScheduleSettings
from msgraph_beta.generated.models.windows_updates.rate_driven_rollout_settings import RateDrivenRolloutSettings
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UpdatePolicy(
odata_type = "#microsoft.graph.windowsUpdates.updatePolicy",
deployment_settings = DeploymentSettings(
odata_type = "microsoft.graph.windowsUpdates.deploymentSettings",
schedule = ScheduleSettings(
gradual_rollout = RateDrivenRolloutSettings(
odata_type = "#microsoft.graph.windowsUpdates.rateDrivenRolloutSettings",
duration_between_offers = "P1D",
additional_data = {
"device_per_offer" : 1000,
}
),
),
),
)
result = await graph_client.admin.windows.updates.update_policies.by_update_policy_id('updatePolicy-id').patch(request_body)