创建 sourceSystemDefinition
本文内容
命名空间:microsoft.graph.industryData
重要
Microsoft Graph 中版本下的 /beta
API 可能会更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 在 v1.0 中是否可用,请使用 版本 选择器。
创建新的 sourceSystemDefinition 对象。
权限
调用此 API 需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
IndustryData-SourceSystem.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
IndustryData-SourceSystem.ReadWrite.All
HTTP 请求
POST /external/industryData/sourceSystems
名称
说明
Authorization
持有者 {token}。 必填。
Content-Type
application/json. 必需。
请求正文
在请求正文中,提供 microsoft.graph.industryData.sourceSystemDefinition 对象的 JSON 表示形式。
创建 sourceSystemDefinition 时,可以指定以下属性。
响应
如果成功,此方法在 201 Created
响应正文中返回响应代码和 microsoft.graph.industryData.sourceSystemDefinition 对象。
示例
请求
请求示例如下所示。
POST https://graph.microsoft.com/beta/external/industryData/sourceSystems
Content-Type: application/json
Content-length: 250
{
"displayName": "Rostering source",
"userMatchingSettings": [
{
"matchTarget": {
"code": "userPrincipalName"
},
"priorityOrder": 0,
"roleGroup@odata.bind": "https://graph.microsoft.com/beta/external/industryData/roleGroups/staff",
"sourceIdentifier": {
"code": "username"
}
},
{
"matchTarget": {
"code": "userPrincipalName"
},
"priorityOrder": 1,
"roleGroup@odata.bind": "https://graph.microsoft.com/beta/external/industryData/roleGroups('students')",
"sourceIdentifier": {
"code": "username"
}
}
]
}
// 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.IndustryData.SourceSystemDefinition
{
DisplayName = "Rostering source",
UserMatchingSettings = new List<Microsoft.Graph.Beta.Models.IndustryData.UserMatchingSetting>
{
new Microsoft.Graph.Beta.Models.IndustryData.UserMatchingSetting
{
MatchTarget = new Microsoft.Graph.Beta.Models.IndustryData.UserMatchTargetReferenceValue
{
Code = "userPrincipalName",
},
PriorityOrder = 0,
SourceIdentifier = new Microsoft.Graph.Beta.Models.IndustryData.IdentifierTypeReferenceValue
{
Code = "username",
},
AdditionalData = new Dictionary<string, object>
{
{
"roleGroup@odata.bind" , "https://graph.microsoft.com/beta/external/industryData/roleGroups/staff"
},
},
},
new Microsoft.Graph.Beta.Models.IndustryData.UserMatchingSetting
{
MatchTarget = new Microsoft.Graph.Beta.Models.IndustryData.UserMatchTargetReferenceValue
{
Code = "userPrincipalName",
},
PriorityOrder = 1,
SourceIdentifier = new Microsoft.Graph.Beta.Models.IndustryData.IdentifierTypeReferenceValue
{
Code = "username",
},
AdditionalData = new Dictionary<string, object>
{
{
"roleGroup@odata.bind" , "https://graph.microsoft.com/beta/external/industryData/roleGroups('students')"
},
},
},
},
};
var result = await graphClient.External.IndustryData.SourceSystems.PostAsync(requestBody);
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models//industryData"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewSourceSystemDefinition()
displayName := "Rostering source"
requestBody.SetDisplayName(&displayName)
userMatchingSetting := graphmodels.NewUserMatchingSetting()
matchTarget := graphmodels.NewUserMatchTargetReferenceValue()
code := "userPrincipalName"
matchTarget.SetCode(&code)
userMatchingSetting.SetMatchTarget(matchTarget)
priorityOrder := int32(0)
userMatchingSetting.SetPriorityOrder(&priorityOrder)
sourceIdentifier := graphmodels.NewIdentifierTypeReferenceValue()
code := "username"
sourceIdentifier.SetCode(&code)
userMatchingSetting.SetSourceIdentifier(sourceIdentifier)
additionalData := map[string]interface{}{
"odataBind" : "https://graph.microsoft.com/beta/external/industryData/roleGroups/staff",
}
userMatchingSetting.SetAdditionalData(additionalData)
userMatchingSetting1 := graphmodels.NewUserMatchingSetting()
matchTarget := graphmodels.NewUserMatchTargetReferenceValue()
code := "userPrincipalName"
matchTarget.SetCode(&code)
userMatchingSetting1.SetMatchTarget(matchTarget)
priorityOrder := int32(1)
userMatchingSetting1.SetPriorityOrder(&priorityOrder)
sourceIdentifier := graphmodels.NewIdentifierTypeReferenceValue()
code := "username"
sourceIdentifier.SetCode(&code)
userMatchingSetting1.SetSourceIdentifier(sourceIdentifier)
additionalData := map[string]interface{}{
"odataBind" : "https://graph.microsoft.com/beta/external/industryData/roleGroups('students')",
}
userMatchingSetting1.SetAdditionalData(additionalData)
userMatchingSettings := []graphmodels.UserMatchingSettingable {
userMatchingSetting,
userMatchingSetting1,
}
requestBody.SetUserMatchingSettings(userMatchingSettings)
result, err := graphClient.External().IndustryData().SourceSystems().Post(context.Background(), requestBody, nil)
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SourceSystemDefinition sourceSystemDefinition = new SourceSystemDefinition();
sourceSystemDefinition.displayName = "Rostering source";
LinkedList<UserMatchingSetting> userMatchingSettingsList = new LinkedList<UserMatchingSetting>();
UserMatchingSetting userMatchingSettings = new UserMatchingSetting();
UserMatchTargetReferenceValue matchTarget = new UserMatchTargetReferenceValue();
matchTarget.code = "userPrincipalName";
userMatchingSettings.matchTarget = matchTarget;
userMatchingSettings.priorityOrder = 0;
userMatchingSettings.additionalDataManager().put("roleGroup@odata.bind", new JsonPrimitive("https://graph.microsoft.com/beta/external/industryData/roleGroups/staff"));
IdentifierTypeReferenceValue sourceIdentifier = new IdentifierTypeReferenceValue();
sourceIdentifier.code = "username";
userMatchingSettings.sourceIdentifier = sourceIdentifier;
userMatchingSettingsList.add(userMatchingSettings);
UserMatchingSetting userMatchingSettings1 = new UserMatchingSetting();
UserMatchTargetReferenceValue matchTarget1 = new UserMatchTargetReferenceValue();
matchTarget1.code = "userPrincipalName";
userMatchingSettings1.matchTarget = matchTarget1;
userMatchingSettings1.priorityOrder = 1;
userMatchingSettings1.additionalDataManager().put("roleGroup@odata.bind", new JsonPrimitive("https://graph.microsoft.com/beta/external/industryData/roleGroups('students')"));
IdentifierTypeReferenceValue sourceIdentifier1 = new IdentifierTypeReferenceValue();
sourceIdentifier1.code = "username";
userMatchingSettings1.sourceIdentifier = sourceIdentifier1;
userMatchingSettingsList.add(userMatchingSettings1);
sourceSystemDefinition.userMatchingSettings = userMatchingSettingsList;
graphClient.external().industryData().sourceSystems()
.buildRequest()
.post(sourceSystemDefinition);
const options = {
authProvider,
};
const client = Client.init(options);
const sourceSystemDefinition = {
displayName: 'Rostering source',
userMatchingSettings: [
{
matchTarget: {
code: 'userPrincipalName'
},
priorityOrder: 0,
'roleGroup@odata.bind': 'https://graph.microsoft.com/beta/external/industryData/roleGroups/staff',
sourceIdentifier: {
code: 'username'
}
},
{
matchTarget: {
code: 'userPrincipalName'
},
priorityOrder: 1,
'roleGroup@odata.bind': 'https://graph.microsoft.com/beta/external/industryData/roleGroups(\'students\')',
sourceIdentifier: {
code: 'username'
}
}
]
};
await client.api('/external/industryData/sourceSystems')
.version('beta')
.post(sourceSystemDefinition);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new SourceSystemDefinition();
$requestBody->setDisplayName('Rostering source');
$userMatchingSettingsUserMatchingSetting1 = new UserMatchingSetting();
$userMatchingSettingsUserMatchingSetting1MatchTarget = new UserMatchTargetReferenceValue();
$userMatchingSettingsUserMatchingSetting1MatchTarget->setCode('userPrincipalName');
$userMatchingSettingsUserMatchingSetting1->setMatchTarget($userMatchingSettingsUserMatchingSetting1MatchTarget);
$userMatchingSettingsUserMatchingSetting1->setPriorityOrder(0);
$userMatchingSettingsUserMatchingSetting1SourceIdentifier = new IdentifierTypeReferenceValue();
$userMatchingSettingsUserMatchingSetting1SourceIdentifier->setCode('username');
$userMatchingSettingsUserMatchingSetting1->setSourceIdentifier($userMatchingSettingsUserMatchingSetting1SourceIdentifier);
$additionalData = [
'roleGroup@odata.bind' => 'https://graph.microsoft.com/beta/external/industryData/roleGroups/staff',
];
$userMatchingSettingsUserMatchingSetting1->setAdditionalData($additionalData);
$userMatchingSettingsArray []= $userMatchingSettingsUserMatchingSetting1;
$userMatchingSettingsUserMatchingSetting2 = new UserMatchingSetting();
$userMatchingSettingsUserMatchingSetting2MatchTarget = new UserMatchTargetReferenceValue();
$userMatchingSettingsUserMatchingSetting2MatchTarget->setCode('userPrincipalName');
$userMatchingSettingsUserMatchingSetting2->setMatchTarget($userMatchingSettingsUserMatchingSetting2MatchTarget);
$userMatchingSettingsUserMatchingSetting2->setPriorityOrder(1);
$userMatchingSettingsUserMatchingSetting2SourceIdentifier = new IdentifierTypeReferenceValue();
$userMatchingSettingsUserMatchingSetting2SourceIdentifier->setCode('username');
$userMatchingSettingsUserMatchingSetting2->setSourceIdentifier($userMatchingSettingsUserMatchingSetting2SourceIdentifier);
$additionalData = [
'roleGroup@odata.bind' => 'https://graph.microsoft.com/beta/external/industryData/roleGroups(\'students\')',
];
$userMatchingSettingsUserMatchingSetting2->setAdditionalData($additionalData);
$userMatchingSettingsArray []= $userMatchingSettingsUserMatchingSetting2;
$requestBody->setUserMatchingSettings($userMatchingSettingsArray);
$result = $graphServiceClient->external()->industryData()->sourceSystems()->post($requestBody);
Import-Module Microsoft.Graph.Search
$params = @{
displayName = "Rostering source"
userMatchingSettings = @(
@{
matchTarget = @{
code = "userPrincipalName"
}
priorityOrder = 0
"roleGroup@odata.bind" = "https://graph.microsoft.com/beta/external/industryData/roleGroups/staff"
sourceIdentifier = @{
code = "username"
}
}
@{
matchTarget = @{
code = "userPrincipalName"
}
priorityOrder = 1
"roleGroup@odata.bind" = "https://graph.microsoft.com/beta/external/industryData/roleGroups('students')"
sourceIdentifier = @{
code = "username"
}
}
)
}
New-MgExternalIndustryDataSourceSystem -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#external/industryData/sourceSystems/$entity",
"id": "aa050107-5784-4a8e-1876-08daddab21bc",
"displayName": "Rostering source",
"vendor": null,
"userMatchingSettings": [
{
"priorityOrder": 0,
"sourceIdentifier": {
"code": "username"
},
"matchTarget": {
"code": "userPrincipalName"
}
},
{
"priorityOrder": 1,
"sourceIdentifier": {
"code": "username"
},
"matchTarget": {
"code": "userPrincipalName"
}
}
]
}