命名空间:microsoft.graph
更新指定 schemaExtension 定义中的属性。 仅当扩展处于 InDevelopment 或 Available 状态时,才能对扩展进行累加更新。 这意味着无法从定义中删除自定义属性或目标资源类型,但可以添加新的自定义属性并更改扩展的说明。
此更新适用于扩展的 targetTypes 属性中包含的所有资源。 这些资源是 支持的资源类型之一。
对于委托流,只要该扩展的 owner 属性设置为已登录用户拥有的应用程序的 appId ,登录用户就可以更新架构扩展。 该应用程序可以是最初创建扩展的应用程序,也可以是登录用户拥有的其他应用程序。
所有者属性的此条件允许已登录用户通过他们不拥有的其他应用程序(如 Microsoft Graph 资源管理器)进行更新。 使用 Graph 资源管理器更新 schemaExtension 资源时,请在 PATCH 请求正文中包含 owner 属性。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
✅ |
✅ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
Application.ReadWrite.All |
不可用。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
Application.ReadWrite.All and Directory.ReadWrite.All |
不可用。 |
HTTP 请求
PATCH /schemaExtensions/{id}
| 名称 |
说明 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
请求正文
在请求正文中,提供应更新的相关字段的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了实现最佳性能,不得添加未变化的现有值。
| 属性 |
类型 |
说明 |
| 说明 |
String |
架构扩展的说明。 |
| properties |
extensionSchemaProperty 集合 |
构成架构扩展定义的属性名称和类型的集合。 仅允许累加更改。 |
| status |
String |
架构扩展的生命周期状态。 创建时的初始状态为 InDevelopment。 可能的状态转换是从 InDevelopment 到 Available 和 Available 到 Deprecated。 |
| targetTypes |
String collection |
架构扩展适用的支持扩展的 Microsoft Graph 类型集。 仅允许累加更改。 |
响应
如果成功,此方法返回 204 No Content 响应代码。 尝试从你不拥有 (的应用程序运行此请求,并且未将 owner 属性设置为你拥有的应用程序的 appId ,) 将 403 Forbidden 返回响应代码。
示例
请求
以下示例显示了一个请求。 如果从你不拥有的应用程序运行请求,则必须包含 owner 属性。 在这种情况下,请将 owner 属性设置为你拥有的应用程序的 appId 。
PATCH https://graph.microsoft.com/v1.0/schemaExtensions/exto6x7sfft_courses
Content-type: application/json
{
"owner": "ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa",
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
},
{
"name": "courseSupervisors",
"type": "String"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SchemaExtension
{
Owner = "ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa",
Properties = new List<ExtensionSchemaProperty>
{
new ExtensionSchemaProperty
{
Name = "courseId",
Type = "Integer",
},
new ExtensionSchemaProperty
{
Name = "courseName",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseType",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseSupervisors",
Type = "String",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions["{schemaExtension-id}"].PatchAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchemaExtension()
owner := "ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa"
requestBody.SetOwner(&owner)
extensionSchemaProperty := graphmodels.NewExtensionSchemaProperty()
name := "courseId"
extensionSchemaProperty.SetName(&name)
type := "Integer"
extensionSchemaProperty.SetType(&type)
extensionSchemaProperty1 := graphmodels.NewExtensionSchemaProperty()
name := "courseName"
extensionSchemaProperty1.SetName(&name)
type := "String"
extensionSchemaProperty1.SetType(&type)
extensionSchemaProperty2 := graphmodels.NewExtensionSchemaProperty()
name := "courseType"
extensionSchemaProperty2.SetName(&name)
type := "String"
extensionSchemaProperty2.SetType(&type)
extensionSchemaProperty3 := graphmodels.NewExtensionSchemaProperty()
name := "courseSupervisors"
extensionSchemaProperty3.SetName(&name)
type := "String"
extensionSchemaProperty3.SetType(&type)
properties := []graphmodels.ExtensionSchemaPropertyable {
extensionSchemaProperty,
extensionSchemaProperty1,
extensionSchemaProperty2,
extensionSchemaProperty3,
}
requestBody.SetProperties(properties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().BySchemaExtensionId("schemaExtension-id").Patch(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtension schemaExtension = new SchemaExtension();
schemaExtension.setOwner("ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa");
LinkedList<ExtensionSchemaProperty> properties = new LinkedList<ExtensionSchemaProperty>();
ExtensionSchemaProperty extensionSchemaProperty = new ExtensionSchemaProperty();
extensionSchemaProperty.setName("courseId");
extensionSchemaProperty.setType("Integer");
properties.add(extensionSchemaProperty);
ExtensionSchemaProperty extensionSchemaProperty1 = new ExtensionSchemaProperty();
extensionSchemaProperty1.setName("courseName");
extensionSchemaProperty1.setType("String");
properties.add(extensionSchemaProperty1);
ExtensionSchemaProperty extensionSchemaProperty2 = new ExtensionSchemaProperty();
extensionSchemaProperty2.setName("courseType");
extensionSchemaProperty2.setType("String");
properties.add(extensionSchemaProperty2);
ExtensionSchemaProperty extensionSchemaProperty3 = new ExtensionSchemaProperty();
extensionSchemaProperty3.setName("courseSupervisors");
extensionSchemaProperty3.setType("String");
properties.add(extensionSchemaProperty3);
schemaExtension.setProperties(properties);
SchemaExtension result = graphClient.schemaExtensions().bySchemaExtensionId("{schemaExtension-id}").patch(schemaExtension);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const schemaExtension = {
owner: 'ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa',
properties: [
{
name: 'courseId',
type: 'Integer'
},
{
name: 'courseName',
type: 'String'
},
{
name: 'courseType',
type: 'String'
},
{
name: 'courseSupervisors',
type: 'String'
}
]
};
await client.api('/schemaExtensions/exto6x7sfft_courses')
.update(schemaExtension);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SchemaExtension;
use Microsoft\Graph\Generated\Models\ExtensionSchemaProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SchemaExtension();
$requestBody->setOwner('ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa');
$propertiesExtensionSchemaProperty1 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty1->setName('courseId');
$propertiesExtensionSchemaProperty1->setType('Integer');
$propertiesArray []= $propertiesExtensionSchemaProperty1;
$propertiesExtensionSchemaProperty2 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty2->setName('courseName');
$propertiesExtensionSchemaProperty2->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty2;
$propertiesExtensionSchemaProperty3 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty3->setName('courseType');
$propertiesExtensionSchemaProperty3->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty3;
$propertiesExtensionSchemaProperty4 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty4->setName('courseSupervisors');
$propertiesExtensionSchemaProperty4->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty4;
$requestBody->setProperties($propertiesArray);
$result = $graphServiceClient->schemaExtensions()->bySchemaExtensionId('schemaExtension-id')->patch($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.SchemaExtensions
$params = @{
owner = "ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa"
properties = @(
@{
name = "courseId"
type = "Integer"
}
@{
name = "courseName"
type = "String"
}
@{
name = "courseType"
type = "String"
}
@{
name = "courseSupervisors"
type = "String"
}
)
}
Update-MgSchemaExtension -SchemaExtensionId $schemaExtensionId -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schema_extension import SchemaExtension
from msgraph.generated.models.extension_schema_property import ExtensionSchemaProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SchemaExtension(
owner = "ef4cb9a8-97c3-4ca7-854b-5cb5ced376fa",
properties = [
ExtensionSchemaProperty(
name = "courseId",
type = "Integer",
),
ExtensionSchemaProperty(
name = "courseName",
type = "String",
),
ExtensionSchemaProperty(
name = "courseType",
type = "String",
),
ExtensionSchemaProperty(
name = "courseSupervisors",
type = "String",
),
],
)
result = await graph_client.schema_extensions.by_schema_extension_id('schemaExtension-id').patch(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
HTTP/1.1 204 No Content
相关内容