创建 workforceIntegration
本文内容
命名空间:microsoft.graph
创建新的 workforceIntegration 对象。
可以设置要接收班次同步更改通知的实体,并设置实体以按WFM规则的资格(包括交换请求)配置筛选。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
❌
❌
❌
权限
为此 API 选择标记为最低特权的权限。 只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
WorkforceIntegration.ReadWrite.All
不可用。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
不支持。
不支持。
注意 :此 API 支持管理员权限。 全局管理员可以访问他们不是其成员的组。
HTTP 请求
POST /teamwork/workforceIntegrations
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
Content-type
application/json. 必需。
MS-APP-ACTS-AS
GUID) (用户 ID。 仅当授权令牌是应用程序令牌时才需要;否则为可选。
请求正文
在请求正文中,提供 workforceIntegration 对象的 JSON 表示形式。
响应
如果成功,此方法在响应正文中返回响应 201 Created
代码和新的 workforceIntegration 对象。
示例
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/v1.0/teamwork/workforceIntegrations
Content-type: application/json
{
"displayName": "displayName-value",
"apiVersion": 99,
"encryption": {
"protocol": "protocol-value",
"secret": "secret-value"
},
"isActive": true,
"url": "url-value",
"supportedEntities": "supportedEntities-value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new WorkforceIntegration
{
DisplayName = "displayName-value",
ApiVersion = 99,
Encryption = new WorkforceIntegrationEncryption
{
Protocol = WorkforceIntegrationEncryptionProtocol.SharedSecret,
Secret = "secret-value",
},
IsActive = true,
Url = "url-value",
SupportedEntities = WorkforceIntegrationSupportedEntities.None,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teamwork.WorkforceIntegrations.PostAsync(requestBody);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc teamwork workforce-integrations create --body '{\
"displayName": "displayName-value",\
"apiVersion": 99,\
"encryption": {\
"protocol": "protocol-value",\
"secret": "secret-value"\
},\
"isActive": true,\
"url": "url-value",\
"supportedEntities": "supportedEntities-value"\
}\
'
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewWorkforceIntegration()
displayName := "displayName-value"
requestBody.SetDisplayName(&displayName)
apiVersion := int32(99)
requestBody.SetApiVersion(&apiVersion)
encryption := graphmodels.NewWorkforceIntegrationEncryption()
protocol := graphmodels.PROTOCOL-VALUE_WORKFORCEINTEGRATIONENCRYPTIONPROTOCOL
encryption.SetProtocol(&protocol)
secret := "secret-value"
encryption.SetSecret(&secret)
requestBody.SetEncryption(encryption)
isActive := true
requestBody.SetIsActive(&isActive)
url := "url-value"
requestBody.SetUrl(&url)
supportedEntities := graphmodels.SUPPORTEDENTITIES-VALUE_WORKFORCEINTEGRATIONSUPPORTEDENTITIES
requestBody.SetSupportedEntities(&supportedEntities)
workforceIntegrations, err := graphClient.Teamwork().WorkforceIntegrations().Post(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);
WorkforceIntegration workforceIntegration = new WorkforceIntegration();
workforceIntegration.setDisplayName("displayName-value");
workforceIntegration.setApiVersion(99);
WorkforceIntegrationEncryption encryption = new WorkforceIntegrationEncryption();
encryption.setProtocol(WorkforceIntegrationEncryptionProtocol.SharedSecret);
encryption.setSecret("secret-value");
workforceIntegration.setEncryption(encryption);
workforceIntegration.setIsActive(true);
workforceIntegration.setUrl("url-value");
workforceIntegration.setSupportedEntities(EnumSet.of(WorkforceIntegrationSupportedEntities.None));
WorkforceIntegration result = graphClient.teamwork().workforceIntegrations().post(workforceIntegration);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const workforceIntegration = {
displayName: 'displayName-value',
apiVersion: 99,
encryption: {
protocol: 'protocol-value',
secret: 'secret-value'
},
isActive: true,
url: 'url-value',
supportedEntities: 'supportedEntities-value'
};
await client.api('/teamwork/workforceIntegrations')
.post(workforceIntegration);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\WorkforceIntegration;
use Microsoft\Graph\Generated\Models\WorkforceIntegrationEncryption;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new WorkforceIntegration();
$requestBody->setDisplayName('displayName-value');
$requestBody->setApiVersion(99);
$encryption = new WorkforceIntegrationEncryption();
$encryption->setProtocol(new WorkforceIntegrationEncryptionProtocol('protocol-value'));
$encryption->setSecret('secret-value');
$requestBody->setEncryption($encryption);
$requestBody->setIsActive(true);
$requestBody->setUrl('url-value');
$requestBody->setSupportedEntities(new WorkforceIntegrationSupportedEntities('supportedEntities-value'));
$result = $graphServiceClient->teamwork()->workforceIntegrations()->post($requestBody)->wait();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Teams
$params = @{
displayName = "displayName-value"
apiVersion = 99
encryption = @{
protocol = "protocol-value"
secret = "secret-value"
}
isActive = $true
url = "url-value"
supportedEntities = "supportedEntities-value"
}
New-MgTeamworkWorkforceIntegration -BodyParameter $params
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
from msgraph import GraphServiceClient
from msgraph.generated.models.workforce_integration import WorkforceIntegration
from msgraph.generated.models.workforce_integration_encryption import WorkforceIntegrationEncryption
graph_client = GraphServiceClient(credentials, scopes)
request_body = WorkforceIntegration(
display_name = "displayName-value",
api_version = 99,
encryption = WorkforceIntegrationEncryption(
protocol = WorkforceIntegrationEncryptionProtocol.SharedSecret,
secret = "secret-value",
),
is_active = True,
url = "url-value",
supported_entities = WorkforceIntegrationSupportedEntities.None,
)
result = await graph_client.teamwork.workforce_integrations.post(request_body)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
响应
以下示例显示了相应的响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"displayName": "displayName-value",
"apiVersion": 99,
"encryption": {
"protocol": "protocol-value",
"secret": "secret-value"
},
"isActive": true,
"url": "url-value",
"supportedEntities": "supportedEntities-value"
}
用于按WFM规则资格进行筛选的 WorkforceIntegration 实体用例的示例
用例:创建新的 WorkforceIntegration,并为资格筛选启用了 SwapRequest
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/v1.0/teamwork/workforceIntegrations/
{
"displayName": "ABCWorkforceIntegration",
"apiVersion": 1,
"isActive": true,
"encryption": {
"protocol": "sharedSecret",
"secret": "My Secret"
},
"url": "https://ABCWorkforceIntegration.com/Contoso/",
"supports": "Shift,SwapRequest",
"eligibilityFilteringEnabledEntities": "SwapRequest"
}
Authorization: Bearer {token}
Content-type: application/json
响应
以下示例显示了相应的响应。
HTTP/1.1 200 OK
{
"id": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"displayName": "ABCWorkforceIntegration",
"apiVersion": 1,
"isActive": true,
"encryption": {
"protocol": "sharedSecret",
"secret": null
},
"url": "https://abcWorkforceIntegration.com/Contoso/",
"supports": "Shift,SwapRequest",
"eligibilityFilteringEnabledEntities": "SwapRequest"
}
若要了解如何在启用了 SwapRequest 的资格筛选的情况下更新现有劳动力集成,请参阅 更新 。
当 SwapRequest 包含在 eligibilityFilteringEnabledEntities 中时提取合格班次的示例
排班应用与劳动力集成终结点之间的交互将遵循现有模式。
请求
以下示例显示了排班人向劳动力集成终结点发出的请求,请求提取交换请求的合格班次。
POST https://abcWorkforceIntegration.com/Contoso/{apiVersion}/team/{teamId}/read
Accept-Language: en-us
{
"requests": [
{
"id": "{shiftId}",
"method": "GET”,
"url": “/shifts/{shiftId}/requestableShifts?requestType={requestType}&startDateTime={startDateTime}&endDateTime={endDateTime}”
}]
}
响应
下面是来自劳动力集成服务的响应示例。
HTTP/1.1 200 OK
{
"responses": [
{
"body": {
"SHFT_6548f642-cbc1-4228-8621-054327576457",
"SHFT_6548f642-cbc1-4228-8621-054327571234"
}
"id": "{shiftId}",
"status: 200,
"body": {
"data": [{ShiftId}, {ShiftId}...]
"error": null
}
]
}