diff --git a/src/index.ts b/src/index.ts index 736a0fb..f8f2b7d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,4 +12,5 @@ export { GroupPolicyDefinitionValue, Group, DetectedApp, + DeviceManagementConfigurationPolicy, } from '@microsoft/microsoft-graph-types-beta' diff --git a/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.spec.ts b/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.spec.ts new file mode 100644 index 0000000..473a2d4 --- /dev/null +++ b/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.spec.ts @@ -0,0 +1,220 @@ +import { Client } from '@microsoft/microsoft-graph-client' +import { DeviceConfigurationPolicies } from './deviceConfigurationPolicies' +import { mockClient } from '../../../__fixtures__/@microsoft/microsoft-graph-client' + +describe('Device Configuration Policies', () => { + let graphClient: Client + let configurationPolicies: DeviceConfigurationPolicies + + const configurationPolicy = { + name: 'test policy', + '@odata.type': '#microsoft.graph.deviceManagementConfigurationPolicy', + } + + const policyAssignment = { + '@odata.type': '#microsoft.graph.deviceManagementConfigurationPolicyAssignment', + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: '1', + }, + } + + beforeEach(() => { + graphClient = mockClient() as never as Client + configurationPolicies = new DeviceConfigurationPolicies(graphClient) + }) + + it('should list all configuration policies', async () => { + jest.spyOn(graphClient.api(''), 'get').mockResolvedValueOnce({ + value: [configurationPolicy], + '@odata.nextLink': 'next', + }) + jest.spyOn(graphClient.api(''), 'get').mockResolvedValueOnce({ + value: [configurationPolicy], + }) + + const result = await configurationPolicies.list() + expect(result).toEqual([configurationPolicy, configurationPolicy]) + }) + + it('should get a configuration policy', async () => { + jest.spyOn(graphClient.api(''), 'get').mockResolvedValue(configurationPolicy) + const result = await configurationPolicies.get('id') + expect(result).toEqual(configurationPolicy) + }) + + it('should create a configuration policy', async () => { + jest.spyOn(graphClient.api(''), 'post').mockResolvedValue(configurationPolicy) + const result = await configurationPolicies.create(configurationPolicy) + expect(result).toEqual(configurationPolicy) + }) + + it('should update a configuration policy', async () => { + jest.spyOn(graphClient.api(''), 'patch') + const result = await configurationPolicies.update('id', configurationPolicy) + expect(result).toBeUndefined() + }) + + it('should delete a configuration policy', async () => { + jest.spyOn(graphClient.api(''), 'delete') + const result = await configurationPolicies.delete('id') + expect(result).toBeUndefined() + }) + + describe('setAssignments', () => { + it('should assign to all devices with exclusions', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await configurationPolicies.setAssignments('id', { + allDevices: true, + excludeGroups: ['group1', 'group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + }, + }, + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group1', + }, + }, + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group2', + }, + }, + ], + }) + }) + + it('should assign to all licensed users', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await configurationPolicies.setAssignments('id', { + allUsers: true, + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + }, + }, + ], + }) + }) + + it('should assign to specific included groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await configurationPolicies.setAssignments('id', { + includeGroups: ['group1', 'group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group1', + }, + }, + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group2', + }, + }, + ], + }) + }) + + it('should throw error when including groups with allDevices', async () => { + await expect( + configurationPolicies.setAssignments('id', { + allDevices: true, + includeGroups: ['group1'], + }), + ).rejects.toThrow('Cannot include specific groups when allDevices is true') + }) + + it('should support mix of include and exclude groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await configurationPolicies.setAssignments('id', { + includeGroups: ['group1'], + excludeGroups: ['group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group1', + }, + }, + { + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId: 'group2', + }, + }, + ], + }) + }) + }) + + describe('pagination', () => { + it('should handle pagination for list method', async () => { + const firstPage = { + value: [{ ...configurationPolicy, id: '1' }], + '@odata.nextLink': 'https://graph.microsoft.com/beta/next-page', + } + const secondPage = { + value: [{ ...configurationPolicy, id: '2' }], + } + + jest.spyOn(graphClient.api(''), 'get') + .mockResolvedValueOnce(firstPage) + .mockResolvedValueOnce(secondPage) + + const result = await configurationPolicies.list() + + expect(result).toHaveLength(2) + expect(result[0].id).toBe('1') + expect(result[1].id).toBe('2') + }) + }) +}) diff --git a/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.ts b/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.ts new file mode 100644 index 0000000..0ae0215 --- /dev/null +++ b/src/lib/deviceConfigurationPolicies/deviceConfigurationPolicies.ts @@ -0,0 +1,171 @@ +import { Client } from '@microsoft/microsoft-graph-client' +import { DeviceManagementConfigurationPolicy } from '@microsoft/microsoft-graph-types-beta' + +interface AssignmentTarget { + '@odata.type': string + deviceAndAppManagementAssignmentFilterType: 'none' | 'include' | 'exclude' + groupId?: string +} + +interface Assignment { + id?: string + source?: 'direct' + target: AssignmentTarget +} + +interface AssignmentOptions { + includeGroups?: string[] + excludeGroups?: string[] + allDevices?: boolean + allUsers?: boolean +} + +export class DeviceConfigurationPolicies { + constructor(private readonly graphClient: Client) {} + + /** + * List all device management configuration policies + * + * @returns + */ + async list(): Promise { + let res = await this.graphClient.api('/deviceManagement/configurationPolicies').get() + const configurationPolicies: DeviceManagementConfigurationPolicy[] = res.value + + while (res['@odata.nextLink']) { + const nextLink = res['@odata.nextLink'].replace('https://graph.microsoft.com/beta', '') + res = await this.graphClient.api(nextLink).get() + const nextConfigurationPolicies = res.value as DeviceManagementConfigurationPolicy[] + configurationPolicies.push(...nextConfigurationPolicies) + } + + return configurationPolicies + } + + /** + * Get a device management configuration policy + * @param configurationPolicyId + * @returns + */ + async get(configurationPolicyId: string): Promise { + return await this.graphClient + .api(`/deviceManagement/configurationPolicies/${configurationPolicyId}`) + .get() + } + + /** + * Create a device management configuration policy + * @param configurationPolicy + * @returns + */ + async create( + configurationPolicy: DeviceManagementConfigurationPolicy, + ): Promise { + return this.graphClient + .api('/deviceManagement/configurationPolicies') + .post(configurationPolicy) + } + + /** + * Update a device management configuration policy + * @param configurationPolicyId + * @param configurationPolicy + */ + async update( + configurationPolicyId: string, + configurationPolicy: DeviceManagementConfigurationPolicy, + ): Promise { + await this.graphClient + .api(`/deviceManagement/configurationPolicies/${configurationPolicyId}`) + .patch(configurationPolicy) + } + + /** + * Delete a device management configuration policy + * @param configurationPolicyId + */ + async delete(configurationPolicyId: string): Promise { + await this.graphClient + .api(`/deviceManagement/configurationPolicies/${configurationPolicyId}`) + .delete() + } + + /** + * Set assignments for a configuration policy + * + * THIS WILL OVERWRITE ANY EXISTING ASSIGNMENTS! + * @param id - The ID of the configuration policy + * @param options - Assignment options including groups to include/exclude and whether to assign to all devices/users + * @returns Promise + */ + async setAssignments(id: string, options: AssignmentOptions): Promise { + const assignments: Assignment[] = [] + + // Add all devices assignment if specified + if (options.allDevices) { + assignments.push({ + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + }, + }) + + // When all devices is selected, we can only have exclusion groups + if (options.includeGroups?.length) { + throw new Error('Cannot include specific groups when allDevices is true') + } + } + + // Add all licensed users assignment if specified + if (options.allUsers) { + assignments.push({ + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + }, + }) + } + + // Add included groups + if (options.includeGroups?.length) { + assignments.push( + ...options.includeGroups.map( + (groupId): Assignment => ({ + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId, + }, + }), + ), + ) + } + + // Add excluded groups + if (options.excludeGroups?.length) { + assignments.push( + ...options.excludeGroups.map( + (groupId): Assignment => ({ + id: '', + source: 'direct', + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + deviceAndAppManagementAssignmentFilterType: 'none', + groupId, + }, + }), + ), + ) + } + + await this.graphClient + .api(`/deviceManagement/configurationPolicies('${id}')/assign`) + .post({ assignments }) + } +} diff --git a/src/lib/deviceConfigurations/deviceConfigurations.spec.ts b/src/lib/deviceConfigurations/deviceConfigurations.spec.ts index 593aaae..961e765 100644 --- a/src/lib/deviceConfigurations/deviceConfigurations.spec.ts +++ b/src/lib/deviceConfigurations/deviceConfigurations.spec.ts @@ -84,4 +84,140 @@ describe('Device Configurations', () => { const result = await deviceConfigurations.deleteGroupAssignment('id', 'groupId') expect(result).toBeUndefined() }) + + describe('setAssignments', () => { + it('should assign to all devices with exclusions', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceConfigurations.setAssignments('id', { + allDevices: true, + excludeGroups: ['group1'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group1', + }, + }, + ], + }) + }) + + it('should assign to all licensed users', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceConfigurations.setAssignments('id', { + allUsers: true, + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }, + ], + }) + }) + + it('should support combination of all devices and all users with exclusions', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceConfigurations.setAssignments('id', { + allDevices: true, + allUsers: true, + excludeGroups: ['group1'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group1', + }, + }, + ], + }) + }) + + it('should assign to specific included groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceConfigurations.setAssignments('id', { + includeGroups: ['group1', 'group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group1', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group2', + }, + }, + ], + }) + }) + + it('should throw error when including groups with allDevices', async () => { + await expect( + deviceConfigurations.setAssignments('id', { + allDevices: true, + includeGroups: ['group1'], + }), + ).rejects.toThrow('Cannot include specific groups when allDevices is true') + }) + + it('should support mix of include and exclude groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceConfigurations.setAssignments('id', { + includeGroups: ['group1'], + excludeGroups: ['group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group1', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group2', + }, + }, + ], + }) + }) + }) }) diff --git a/src/lib/deviceConfigurations/deviceConfigurations.ts b/src/lib/deviceConfigurations/deviceConfigurations.ts index 8ffe324..759bc3e 100644 --- a/src/lib/deviceConfigurations/deviceConfigurations.ts +++ b/src/lib/deviceConfigurations/deviceConfigurations.ts @@ -1,6 +1,22 @@ import { Client } from '@microsoft/microsoft-graph-client' import { DeviceConfigurationGroupAssignment } from '@microsoft/microsoft-graph-types-beta' import { DeviceConfiguration } from '../types' + +interface AssignmentTarget { + '@odata.type': string + groupId?: string +} + +interface Assignment { + target: AssignmentTarget +} + +interface AssignmentOptions { + includeGroups?: string[] + excludeGroups?: string[] + allDevices?: boolean + allUsers?: boolean +} export class DeviceConfigurations { constructor(private readonly graphClient: Client) {} @@ -43,6 +59,73 @@ export class DeviceConfigurations { .delete() } + /** + * Set assignments for a device configuration + * + * THIS WILL OVERWRITE ANY EXISTING ASSIGNMENTS! + * @param id - The ID of the device configuration + * @param options - Assignment options including groups to include/exclude and whether to assign to all devices/users + * @returns Promise + */ + async setAssignments(id: string, options: AssignmentOptions): Promise { + const assignments: Assignment[] = [] + + // Add all devices assignment if specified + if (options.allDevices) { + assignments.push({ + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }) + + // When all devices is selected, we can only have exclusion groups + if (options.includeGroups?.length) { + throw new Error('Cannot include specific groups when allDevices is true') + } + } + + // Add all licensed users assignment if specified + if (options.allUsers) { + assignments.push({ + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }) + } + + // Add included groups + if (options.includeGroups?.length) { + assignments.push( + ...options.includeGroups.map( + (groupId): Assignment => ({ + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId, + }, + }), + ), + ) + } + + // Add excluded groups + if (options.excludeGroups?.length) { + assignments.push( + ...options.excludeGroups.map( + (groupId): Assignment => ({ + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId, + }, + }), + ), + ) + } + + await this.graphClient + .api(`/deviceManagement/deviceConfigurations/${id}/assign`) + .post({ assignments }) + } + async createGroupAssignment( id: string, groupId: string, diff --git a/src/lib/deviceManagementIntents/deviceManagementIntents.spec.ts b/src/lib/deviceManagementIntents/deviceManagementIntents.spec.ts index 503d581..dcdd6fa 100644 --- a/src/lib/deviceManagementIntents/deviceManagementIntents.spec.ts +++ b/src/lib/deviceManagementIntents/deviceManagementIntents.spec.ts @@ -58,4 +58,140 @@ describe('DeviceManagementIntents', () => { expect(apiSpy).toHaveBeenCalledWith('/deviceManagement/intents') expect(postSpy).toHaveBeenCalledWith(intent) }) + + describe('setAssignments', () => { + it('should assign to all devices with exclusions', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceManagementIntents.setAssignments('id', { + allDevices: true, + excludeGroups: ['group1'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group1', + }, + }, + ], + }) + }) + + it('should assign to all licensed users', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceManagementIntents.setAssignments('id', { + allUsers: true, + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }, + ], + }) + }) + + it('should support combination of all devices and all users with exclusions', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceManagementIntents.setAssignments('id', { + allDevices: true, + allUsers: true, + excludeGroups: ['group1'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group1', + }, + }, + ], + }) + }) + + it('should assign to specific included groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceManagementIntents.setAssignments('id', { + includeGroups: ['group1', 'group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group1', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group2', + }, + }, + ], + }) + }) + + it('should throw error when including groups with allDevices', async () => { + await expect( + deviceManagementIntents.setAssignments('id', { + allDevices: true, + includeGroups: ['group1'], + }), + ).rejects.toThrow('Cannot include specific groups when allDevices is true') + }) + + it('should support mix of include and exclude groups', async () => { + const spy = jest.spyOn(graphClient.api(''), 'post') + + await deviceManagementIntents.setAssignments('id', { + includeGroups: ['group1'], + excludeGroups: ['group2'], + }) + + expect(spy).toHaveBeenCalledWith({ + assignments: [ + { + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId: 'group1', + }, + }, + { + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId: 'group2', + }, + }, + ], + }) + }) + }) }) diff --git a/src/lib/deviceManagementIntents/deviceManagementIntents.ts b/src/lib/deviceManagementIntents/deviceManagementIntents.ts index 5560c82..75eb452 100644 --- a/src/lib/deviceManagementIntents/deviceManagementIntents.ts +++ b/src/lib/deviceManagementIntents/deviceManagementIntents.ts @@ -2,12 +2,29 @@ import { Client } from '@microsoft/microsoft-graph-client' import { Group } from '@microsoft/microsoft-graph-types-beta' import { DeviceManagementIntent } from '../types' +interface AssignmentTarget { + '@odata.type': string + groupId?: string +} + +interface Assignment { + id?: string + target: AssignmentTarget +} + +interface AssignmentOptions { + includeGroups?: string[] + excludeGroups?: string[] + allDevices?: boolean + allUsers?: boolean +} + export class DeviceManagementIntents { constructor(private readonly graphClient: Client) {} async list() { let res = await this.graphClient.api('/deviceManagement/intents').get() - const intents: Group[] = res.value + const intents: DeviceManagementIntent[] = res.value while (res['@odata.nextLink']) { const nextLink = res['@odata.nextLink'].replace('https://graph.microsoft.com/beta', '') res = await this.graphClient.api(nextLink).get() @@ -35,4 +52,69 @@ export class DeviceManagementIntents { async create(intent: DeviceManagementIntent): Promise { return this.graphClient.api('/deviceManagement/intents').post(intent) } + + /** + * Set assignments for an intent + * + * THIS WILL OVERWRITE ANY EXISTING ASSIGNMENTS! + * @param id - The ID of the intent + * @param options - Assignment options including groups to include/exclude and whether to assign to all devices/users + * @returns Promise + */ + async setAssignments(id: string, options: AssignmentOptions): Promise { + const assignments: Assignment[] = [] + + // Add all devices assignment if specified + if (options.allDevices) { + assignments.push({ + target: { + '@odata.type': '#microsoft.graph.allDevicesAssignmentTarget', + }, + }) + + // When all devices is selected, we can only have exclusion groups + if (options.includeGroups?.length) { + throw new Error('Cannot include specific groups when allDevices is true') + } + } + + // Add all licensed users assignment if specified + if (options.allUsers) { + assignments.push({ + target: { + '@odata.type': '#microsoft.graph.allLicensedUsersAssignmentTarget', + }, + }) + } + + // Add included groups + if (options.includeGroups?.length) { + assignments.push( + ...options.includeGroups.map( + (groupId): Assignment => ({ + target: { + '@odata.type': '#microsoft.graph.groupAssignmentTarget', + groupId, + }, + }), + ), + ) + } + + // Add excluded groups + if (options.excludeGroups?.length) { + assignments.push( + ...options.excludeGroups.map( + (groupId): Assignment => ({ + target: { + '@odata.type': '#microsoft.graph.exclusionGroupAssignmentTarget', + groupId, + }, + }), + ), + ) + } + + await this.graphClient.api(`/deviceManagement/intents/${id}/assign`).post({ assignments }) + } } diff --git a/src/lib/intune.spec.ts b/src/lib/intune.spec.ts index 95c4f67..7f26bb5 100644 --- a/src/lib/intune.spec.ts +++ b/src/lib/intune.spec.ts @@ -9,6 +9,7 @@ import { Users } from './users/users' import { DeviceManagementTemplates } from './deviceManagementTemplates/deviceManagementTemplates' import { DeviceManagementIntents } from './deviceManagementIntents/deviceManagementIntents' import { Autopilot } from './autopilot/autopilot' +import { DeviceConfigurationPolicies } from './deviceConfigurationPolicies/deviceConfigurationPolicies' jest.mock('./utils/auth-provider.ts', () => { return { @@ -37,6 +38,7 @@ describe('Intune', () => { expect(intune.deviceManagementTemplates).toBeInstanceOf(DeviceManagementTemplates) expect(intune.deviceManagementIntents).toBeInstanceOf(DeviceManagementIntents) expect(intune.autopilot).toBeInstanceOf(Autopilot) + expect(intune.deviceConfigurationPolicies).toBeInstanceOf(DeviceConfigurationPolicies) }) // Test for the refreshToken getter diff --git a/src/lib/intune.ts b/src/lib/intune.ts index 2f9c35c..5500197 100644 --- a/src/lib/intune.ts +++ b/src/lib/intune.ts @@ -13,6 +13,7 @@ import { DeviceManagementTemplates } from './deviceManagementTemplates/deviceMan import { DeviceManagementIntents } from './deviceManagementIntents/deviceManagementIntents' import { DeviceHealthScripts } from './deviceHealthScripts/deviceHealthScripts' import { AuthProvider } from './utils/auth-provider' +import { DeviceConfigurationPolicies } from './deviceConfigurationPolicies/deviceConfigurationPolicies' require('isomorphic-fetch') export class Intune { @@ -42,6 +43,8 @@ export class Intune { readonly deviceManagementIntents: DeviceManagementIntents + readonly deviceConfigurationPolicies: DeviceConfigurationPolicies + private readonly authProvider: AuthProvider constructor(private readonly config: Config) { @@ -64,6 +67,7 @@ export class Intune { this.deviceManagementTemplates = new DeviceManagementTemplates(this.graphclient) this.deviceManagementIntents = new DeviceManagementIntents(this.graphclient) this.deviceHealthScripts = new DeviceHealthScripts(this.graphclient) + this.deviceConfigurationPolicies = new DeviceConfigurationPolicies(this.graphclient) } /**