// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceManagementPartner
{
OdataType = "#microsoft.graph.deviceManagementPartner",
LastHeartbeatDateTime = DateTimeOffset.Parse("2016-12-31T23:59:37.9174975-08:00"),
PartnerState = DeviceManagementPartnerTenantState.Unavailable,
PartnerAppType = DeviceManagementPartnerAppType.SingleTenantApp,
SingleTenantAppId = "Single Tenant App Id value",
DisplayName = "Display Name value",
IsConfigured = true,
WhenPartnerDevicesWillBeRemovedDateTime = DateTimeOffset.Parse("2016-12-31T23:56:38.2655023-08:00"),
WhenPartnerDevicesWillBeMarkedAsNonCompliantDateTime = DateTimeOffset.Parse("2016-12-31T23:58:42.2131231-08:00"),
GroupsRequiringPartnerEnrollment = new List<DeviceManagementPartnerAssignment>
{
new DeviceManagementPartnerAssignment
{
OdataType = "microsoft.graph.deviceManagementPartnerAssignment",
Target = new ConfigurationManagerCollectionAssignmentTarget
{
OdataType = "microsoft.graph.configurationManagerCollectionAssignmentTarget",
CollectionId = "Collection Id value",
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.DeviceManagementPartners.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceManagementPartner deviceManagementPartner = new DeviceManagementPartner();
deviceManagementPartner.setOdataType("#microsoft.graph.deviceManagementPartner");
OffsetDateTime lastHeartbeatDateTime = OffsetDateTime.parse("2016-12-31T23:59:37.9174975-08:00");
deviceManagementPartner.setLastHeartbeatDateTime(lastHeartbeatDateTime);
deviceManagementPartner.setPartnerState(DeviceManagementPartnerTenantState.Unavailable);
deviceManagementPartner.setPartnerAppType(DeviceManagementPartnerAppType.SingleTenantApp);
deviceManagementPartner.setSingleTenantAppId("Single Tenant App Id value");
deviceManagementPartner.setDisplayName("Display Name value");
deviceManagementPartner.setIsConfigured(true);
OffsetDateTime whenPartnerDevicesWillBeRemovedDateTime = OffsetDateTime.parse("2016-12-31T23:56:38.2655023-08:00");
deviceManagementPartner.setWhenPartnerDevicesWillBeRemovedDateTime(whenPartnerDevicesWillBeRemovedDateTime);
OffsetDateTime whenPartnerDevicesWillBeMarkedAsNonCompliantDateTime = OffsetDateTime.parse("2016-12-31T23:58:42.2131231-08:00");
deviceManagementPartner.setWhenPartnerDevicesWillBeMarkedAsNonCompliantDateTime(whenPartnerDevicesWillBeMarkedAsNonCompliantDateTime);
LinkedList<DeviceManagementPartnerAssignment> groupsRequiringPartnerEnrollment = new LinkedList<DeviceManagementPartnerAssignment>();
DeviceManagementPartnerAssignment deviceManagementPartnerAssignment = new DeviceManagementPartnerAssignment();
deviceManagementPartnerAssignment.setOdataType("microsoft.graph.deviceManagementPartnerAssignment");
ConfigurationManagerCollectionAssignmentTarget target = new ConfigurationManagerCollectionAssignmentTarget();
target.setOdataType("microsoft.graph.configurationManagerCollectionAssignmentTarget");
target.setCollectionId("Collection Id value");
deviceManagementPartnerAssignment.setTarget(target);
groupsRequiringPartnerEnrollment.add(deviceManagementPartnerAssignment);
deviceManagementPartner.setGroupsRequiringPartnerEnrollment(groupsRequiringPartnerEnrollment);
DeviceManagementPartner result = graphClient.deviceManagement().deviceManagementPartners().post(deviceManagementPartner);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DeviceManagementPartner;
use Microsoft\Graph\Generated\Models\DeviceManagementPartnerTenantState;
use Microsoft\Graph\Generated\Models\DeviceManagementPartnerAppType;
use Microsoft\Graph\Generated\Models\DeviceManagementPartnerAssignment;
use Microsoft\Graph\Generated\Models\ConfigurationManagerCollectionAssignmentTarget;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceManagementPartner();
$requestBody->setOdataType('#microsoft.graph.deviceManagementPartner');
$requestBody->setLastHeartbeatDateTime(new \DateTime('2016-12-31T23:59:37.9174975-08:00'));
$requestBody->setPartnerState(new DeviceManagementPartnerTenantState('unavailable'));
$requestBody->setPartnerAppType(new DeviceManagementPartnerAppType('singleTenantApp'));
$requestBody->setSingleTenantAppId('Single Tenant App Id value');
$requestBody->setDisplayName('Display Name value');
$requestBody->setIsConfigured(true);
$requestBody->setWhenPartnerDevicesWillBeRemovedDateTime(new \DateTime('2016-12-31T23:56:38.2655023-08:00'));
$requestBody->setWhenPartnerDevicesWillBeMarkedAsNonCompliantDateTime(new \DateTime('2016-12-31T23:58:42.2131231-08:00'));
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1 = new DeviceManagementPartnerAssignment();
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1->setOdataType('microsoft.graph.deviceManagementPartnerAssignment');
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1Target = new ConfigurationManagerCollectionAssignmentTarget();
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1Target->setOdataType('microsoft.graph.configurationManagerCollectionAssignmentTarget');
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1Target->setCollectionId('Collection Id value');
$groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1->setTarget($groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1Target);
$groupsRequiringPartnerEnrollmentArray []= $groupsRequiringPartnerEnrollmentDeviceManagementPartnerAssignment1;
$requestBody->setGroupsRequiringPartnerEnrollment($groupsRequiringPartnerEnrollmentArray);
$result = $graphServiceClient->deviceManagement()->deviceManagementPartners()->post($requestBody)->wait();
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.