更新部署
命名空间:microsoft.graph.windowsUpdates
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 部署对象的属性 。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
WindowsUpdates.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
WindowsUpdates.ReadWrite.All |
HTTP 请求
PATCH /admin/windows/updates/deployments/{deploymentId}
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供部署对象的 JSON 表示 形式。
下表显示更新部署时可以设置 的属性。
响应
如果成功,此方法在响应 202 Accepted 正文中返回 响应代码和更新的部署对象。
示例
示例:暂停部署
在此例中,部署通过更新 部署 requestedValue 暂停 state 。
请求
PATCH https://graph.microsoft.com/beta/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
"state": {
"@odata.type": "microsoft.graph.windowsUpdates.deploymentState",
"requestedValue": "paused"
},
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var deployment = new Microsoft.Graph.WindowsUpdates.Deployment
{
State = new DeploymentState
{
RequestedValue = Microsoft.Graph.WindowsUpdates.RequestedDeploymentStateValue.Paused
}
};
await graphClient.Admin.Windows.Updates.Deployments["{windowsUpdates.deployment-id}"]
.Request()
.UpdateAsync(deployment);
const options = {
authProvider,
};
const client = Client.init(options);
const deployment = {
'@odata.type': '#microsoft.graph.windowsUpdates.deployment',
state: {
'@odata.type': 'microsoft.graph.windowsUpdates.deploymentState',
requestedValue: 'paused'
},
};
await client.api('/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5')
.version('beta')
.update(deployment);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphWindowsUpdatesDeployment *deployment = [[MSGraphWindowsUpdatesDeployment alloc] init];
MSGraphWindowsUpdatesDeploymentState *state = [[MSGraphWindowsUpdatesDeploymentState alloc] init];
[state setRequestedValue: [MSGraphWindowsUpdatesRequestedDeploymentStateValue paused]];
[deployment setState:state];
NSError *error;
NSData *deploymentData = [deployment getSerializedDataWithError:&error];
[urlRequest setHTTPBody:deploymentData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Deployment deployment = new Deployment();
DeploymentState state = new DeploymentState();
state.requestedValue = RequestedDeploymentStateValue.PAUSED;
deployment.state = state;
graphClient.admin().windows().updates().deployments("b5171742-1742-b517-4217-17b5421717b5")
.buildRequest()
.patch(deployment);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewDeployment()
state := msgraphsdk.NewDeploymentState()
requestBody.SetState(state)
requestedValue := "paused"
state.SetRequestedValue(&requestedValue)
state.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.windowsUpdates.deploymentState",
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
}
deploymentId := "deployment-id"
graphClient.Admin().Windows().Updates().DeploymentsById(&deploymentId).Patch(requestBody)
Import-Module Microsoft.Graph.WindowsUpdates
$params = @{
"@odata.type" = "#microsoft.graph.windowsUpdates.deployment"
State = @{
"@odata.type" = "microsoft.graph.windowsUpdates.deploymentState"
RequestedValue = "paused"
}
}
Update-MgWindowsUpdatesDeployment -DeploymentId $deploymentId -BodyParameter $params
响应
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
"id": "b5171742-1742-b517-4217-17b5421717b5",
"state": {
"@odata.type": "microsoft.graph.windowsUpdates.deploymentState",
"reasons": [
{
"@odata.type": "microsoft.graph.windowsUpdates.deploymentStateReason",
"value": "pausedByRequest"
}
],
"requestedValue": "paused",
"value": "paused"
},
"content": {
"@odata.type": "microsoft.graph.windowsUpdates.featureUpdateReference",
"version": "20H2"
},
"settings": null,
"createdDateTime": "String (timestamp)",
"lastModifiedDateTime": "String (timestamp)"
}
示例:更新部署设置以添加监视规则
此示例更新 settings 了部署的 属性以添加监视规则。
请求
PATCH https://graph.microsoft.com/beta/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
"settings": {
"@odata.type": "microsoft.graph.windowsUpdates.windowsDeploymentSettings",
"monitoring": {
"monitoringRules": [
{
"signal": "rollback",
"threshold": 5,
"action": "pauseDeployment"
}
]
}
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var deployment = new Microsoft.Graph.WindowsUpdates.Deployment
{
Settings = new WindowsDeploymentSettings
{
Monitoring = new Microsoft.Graph.WindowsUpdates.MonitoringSettings
{
MonitoringRules = new List<Microsoft.Graph.WindowsUpdates.MonitoringRule>()
{
new Microsoft.Graph.WindowsUpdates.MonitoringRule
{
Signal = Microsoft.Graph.WindowsUpdates.MonitoringSignal.Rollback,
Threshold = 5,
Action = Microsoft.Graph.WindowsUpdates.MonitoringAction.PauseDeployment
}
}
}
}
};
await graphClient.Admin.Windows.Updates.Deployments["{windowsUpdates.deployment-id}"]
.Request()
.UpdateAsync(deployment);
const options = {
authProvider,
};
const client = Client.init(options);
const deployment = {
'@odata.type': '#microsoft.graph.windowsUpdates.deployment',
settings: {
'@odata.type': 'microsoft.graph.windowsUpdates.windowsDeploymentSettings',
monitoring: {
monitoringRules: [
{
signal: 'rollback',
threshold: 5,
action: 'pauseDeployment'
}
]
}
}
};
await client.api('/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5')
.version('beta')
.update(deployment);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/admin/windows/updates/deployments/b5171742-1742-b517-4217-17b5421717b5"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphWindowsUpdatesDeployment *deployment = [[MSGraphWindowsUpdatesDeployment alloc] init];
MSGraphWindowsUpdatesDeploymentSettings *settings = [[MSGraphWindowsUpdatesDeploymentSettings alloc] init];
MSGraphWindowsUpdatesMonitoringSettings *monitoring = [[MSGraphWindowsUpdatesMonitoringSettings alloc] init];
NSMutableArray *monitoringRulesList = [[NSMutableArray alloc] init];
MSGraphWindowsUpdatesMonitoringRule *monitoringRules = [[MSGraphWindowsUpdatesMonitoringRule alloc] init];
[monitoringRules setSignal: [MSGraphWindowsUpdatesMonitoringSignal rollback]];
[monitoringRules setThreshold: 5];
[monitoringRules setAction: [MSGraphWindowsUpdatesMonitoringAction pauseDeployment]];
[monitoringRulesList addObject: monitoringRules];
[monitoring setMonitoringRules:monitoringRulesList];
[settings setMonitoring:monitoring];
[deployment setSettings:settings];
NSError *error;
NSData *deploymentData = [deployment getSerializedDataWithError:&error];
[urlRequest setHTTPBody:deploymentData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Deployment deployment = new Deployment();
WindowsDeploymentSettings settings = new WindowsDeploymentSettings();
MonitoringSettings monitoring = new MonitoringSettings();
LinkedList<MonitoringRule> monitoringRulesList = new LinkedList<MonitoringRule>();
MonitoringRule monitoringRules = new MonitoringRule();
monitoringRules.signal = MonitoringSignal.ROLLBACK;
monitoringRules.threshold = 5;
monitoringRules.action = MonitoringAction.PAUSE_DEPLOYMENT;
monitoringRulesList.add(monitoringRules);
monitoring.monitoringRules = monitoringRulesList;
settings.monitoring = monitoring;
deployment.settings = settings;
graphClient.admin().windows().updates().deployments("b5171742-1742-b517-4217-17b5421717b5")
.buildRequest()
.patch(deployment);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewDeployment()
settings := msgraphsdk.NewDeploymentSettings()
requestBody.SetSettings(settings)
monitoring := msgraphsdk.NewMonitoringSettings()
settings.SetMonitoring(monitoring)
monitoring.SetMonitoringRules( []MonitoringRule {
msgraphsdk.NewMonitoringRule(),
signal := "rollback"
SetSignal(&signal)
threshold := int32(5)
SetThreshold(&threshold)
action := "pauseDeployment"
SetAction(&action)
}
settings.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.windowsUpdates.windowsDeploymentSettings",
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
}
deploymentId := "deployment-id"
graphClient.Admin().Windows().Updates().DeploymentsById(&deploymentId).Patch(requestBody)
Import-Module Microsoft.Graph.WindowsUpdates
$params = @{
"@odata.type" = "#microsoft.graph.windowsUpdates.deployment"
Settings = @{
"@odata.type" = "microsoft.graph.windowsUpdates.windowsDeploymentSettings"
Monitoring = @{
MonitoringRules = @(
@{
Signal = "rollback"
Threshold = 5
Action = "pauseDeployment"
}
)
}
}
}
Update-MgWindowsUpdatesDeployment -DeploymentId $deploymentId -BodyParameter $params
响应
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.windowsUpdates.deployment",
"id": "b5171742-1742-b517-4217-17b5421717b5",
"state": {
"@odata.type": "microsoft.graph.windowsUpdates.deploymentState",
"reasons": [
{
"@odata.type": "microsoft.graph.windowsUpdates.deploymentStateReason",
"value": "offeringByRequest"
}
],
"requestedValue": "none",
"value": "offering"
},
"content": {
"@odata.type": "microsoft.graph.windowsUpdates.featureUpdateReference",
"version": "20H2"
},
"settings": {
"@odata.type": "microsoft.graph.windowsUpdates.windowsDeploymentSettings",
"monitoring": {
"monitoringRules": [
{
"signal": "rollback",
"threshold": 5,
"action": "pauseDeployment"
}
]
}
},
"createdDateTime": "String (timestamp)",
"lastModifiedDateTime": "String (timestamp)"
}