Skip to content

Latest commit

 

History

History
131 lines (124 loc) · 3.62 KB

File metadata and controls

131 lines (124 loc) · 3.62 KB
description Automatically generated file. DO NOT MODIFY
// Code snippets are only available for the latest version. Current version is 5.x

// Dependencies
using Microsoft.Graph.Beta.Models;
using Microsoft.Kiota.Abstractions.Serialization;

var requestBody = new TrainingCampaign
{
	DisplayName = "Graph Training Campaign",
	Description = "Graph Training Campaign Description",
	CreatedBy = new EmailIdentity
	{
		Email = "john@contoso.com",
	},
	LastModifiedBy = new EmailIdentity
	{
		Email = "john@contoso.com",
	},
	IncludedAccountTarget = new AccountTargetContent
	{
		Type = AccountTargetContentType.AddressBook,
		AdditionalData = new Dictionary<string, object>
		{
			{
				"accountTargetEmails" , new List<string>
				{
					"john@contoso.com",
				}
			},
		},
	},
	EndUserNotificationSetting = new EndUserNotificationSetting
	{
		NotificationPreference = EndUserNotificationPreference.Microsoft,
		SettingType = EndUserNotificationSettingType.TrainingSelected,
		AdditionalData = new Dictionary<string, object>
		{
			{
				"trainingReminder" , new UntypedObject(new Dictionary<string, UntypedNode>
				{
					{
						"deliveryFrequency", new UntypedString("weekly")
					},
					{
						"endUserNotification@odata.bind", new UntypedString("https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('fe521249-9901-4584-a987-026a9980c58e')")
					},
					{
						"defaultLanguage", new UntypedString("en")
					},
				})
			},
			{
				"trainingAssignment" , new UntypedObject(new Dictionary<string, UntypedNode>
				{
					{
						"endUserNotification@odata.bind", new UntypedString("https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('36fb4dc1-7c37-4b96-9096-12e6d6014fae')")
					},
					{
						"defaultLanguage", new UntypedString("en")
					},
				})
			},
		},
	},
	TrainingSetting = new TrainingSetting
	{
		SettingType = TrainingSettingType.MicrosoftCustom,
		AdditionalData = new Dictionary<string, object>
		{
			{
				"trainingAssignmentMappings" , new List<object>
				{
					new UntypedObject(new Dictionary<string, UntypedNode>
					{
						{
							"assignedTo", new UntypedArray(new List<UntypedNode>
							{
								new UntypedString("allUsers"),
							})
						},
						{
							"training@odata.bind", new UntypedString("https://graph.microsoft.com/beta/security/attackSimulation/trainings('40454905-dc26-4f36-b854-3042a5362cb3')")
						},
					}),
					new UntypedObject(new Dictionary<string, UntypedNode>
					{
						{
							"assignedTo", new UntypedArray(new List<UntypedNode>
							{
								new UntypedString("allUsers"),
							})
						},
						{
							"training@odata.bind", new UntypedString("https://graph.microsoft.com/beta/security/attackSimulation/trainings('ea70ae06-3859-4818-be9d-270ee81d80a4')")
						},
					}),
					new UntypedObject(new Dictionary<string, UntypedNode>
					{
						{
							"assignedTo", new UntypedArray(new List<UntypedNode>
							{
								new UntypedString("allUsers"),
							})
						},
						{
							"training@odata.bind", new UntypedString("https://graph.microsoft.com/beta/security/attackSimulation/trainings('d733d88c-1b5a-48e3-a588-9910e41ac21d')")
						},
					}),
				}
			},
		},
	},
	CampaignSchedule = new CampaignSchedule
	{
		LaunchDateTime = DateTimeOffset.Parse("2024-02-15T07:59:44Z"),
		CompletionDateTime = DateTimeOffset.Parse("2024-02-18T07:59:44Z"),
		Status = CampaignStatus.Scheduled,
	},
};

// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.AttackSimulation.TrainingCampaigns.PostAsync(requestBody);