Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #69 from JupiterOne/INT-9900-0.6.5
Browse files Browse the repository at this point in the history
Int 9900 0.6.5
  • Loading branch information
Gonzalo-Avalos-Ribas authored Nov 16, 2023
2 parents 5856f61 + fff6741 commit 377a6db
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupiterone/graph-airwatch",
"version": "0.6.4",
"version": "0.6.5",
"description": "A graph conversion tool for https://www.air-watch.com/.",
"repository": {
"type": "git",
Expand Down
14 changes: 14 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
AirWatchOrganizationGroupsResponse,
AirwatchDeviceProfileResponse,
AirwatchProfile,
AirwatchProfileDetails,
AirwatchProfileResponse,
ResourceIteratee,
} from './types';
Expand Down Expand Up @@ -184,6 +185,19 @@ export default class AirWatchClient {
);
return response;
}

public async fetchProfilesDetails(
profileId: string,
): Promise<AirwatchProfileDetails> {
const response: AirwatchProfileDetails =
await this.makeRequest<AirwatchProfileDetails>(
`/mdm/profiles/${profileId}`,
'GET',
undefined,
'4',
);
return response;
}
private async makeRequest<T>(
path: string,
method: string = 'GET',
Expand Down
37 changes: 37 additions & 0 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,40 @@ export interface DeviceProfile {
export interface ID {
Value: number;
}

export interface AirwatchProfileDetails {
general: General;
}

export interface General {
ProfileId: number;
AfwOemSettingsEnabled: boolean;
AfwOemType: number;
Name: string;
Description: string;
ProfileScope: string;
Version: number;
CreateNewVersion: boolean;
AssignmentType: string;
ProfileContext: string;
EnableProvisioning: boolean;
IsActive: boolean;
IsManaged: boolean;
Password: string;
AllowRemoval: string;
AssignedSmartGroups: EdSmartGroup[];
ExcludedSmartGroups: EdSmartGroup[];
ManagedLocationGroupID: number;
AssignedGeofenceArea: number[];
AssignedSchedule: number[];
ExpirationDate: string;
ProfileUuid: string;
IsProvisionedForOobe: boolean;
id: number;
uuid: string;
}

export interface EdSmartGroup {
SmartGroupId: number;
Name: string;
}
29 changes: 17 additions & 12 deletions src/steps/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,38 @@ export async function buildDeviceProfileRelationships({
);
// we don't have a way to test this - I'm using the model provided by the provider
// but its not working. Let's try logging.
logger.info(
{ objectKeys: response.DeviceProfiles?.length },
'TEMP - DeviceProfiles length',
);
for (const profile of response.DeviceProfiles) {
logger.info(
{ objectKeys: Object.keys(profile) },
'TEMP - profileKeys',
);
let profileUUid: string | undefined;
if (profile.Uuid) {
profileUUid = profile.Uuid;
} else if (profile.Id.Value) {
const details = await apiClient.fetchProfilesDetails(
profile.Id.Value?.toString(),
);
logger.info(
{ detailKeys: Object.keys(details.general) },
'TEMP - detail keys.',
);
profileUUid = details.general.uuid;
}
if (
response.DeviceId.Uuid &&
profile.Uuid &&
profileUUid &&
jobState.hasKey(response.DeviceId.Uuid) &&
jobState.hasKey(profile.Uuid)
jobState.hasKey(profileUUid)
) {
await jobState.addRelationship(
createDirectRelationship({
_class: DEVICE_PROFILE_REATIONSHIP_CLASS,
fromKey: response.DeviceId.Uuid,
fromType: DEVICE_ENTITY_TYPE,
toKey: profile.Uuid,
toKey: profileUUid,
toType: PROFILE_ENTITY_TYPE,
}),
);
} else {
logger.info(
{ fromKey: response.DeviceId.Uuid, toKey: profile.Uuid },
{ fromKey: response.DeviceId.Uuid, toKey: profileUUid },
'Could not create a relationship',
);
}
Expand Down

0 comments on commit 377a6db

Please sign in to comment.