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

Commit

Permalink
APP-15542 - Update rest of files
Browse files Browse the repository at this point in the history
  • Loading branch information
jzolo22 committed Jul 11, 2024
1 parent 3fe319b commit b16a55b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/steps/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {
ACCOUNT_ORGANIZATION_GROUP_RELATIONSHIP_CLASS,
Entities,
ORGANIZATION_GROUP_ADMIN_RELATIONSHIP_CLASS,
ORGANIZATION_GROUP_ENTITY_TYPE,
ORGANIZATION_GROUP_RELATIONSHIP_CLASS,
Relationships,
STEP_FETCH_ACCOUNT,
STEP_FETCH_ADMINS,
STEP_FETCH_ORGANIZATION_GROUPS,
} from './constants';
import { createAdminEntity, createOrganizationGroupEntity } from './converters';
import { OrganizationGroupEntityMetadata } from '../entities';

export async function fetchOrganizationGroups({
instance,
Expand Down Expand Up @@ -51,7 +51,7 @@ export async function fetchOrganizationGroups({
});

await jobState.iterateEntities(
{ _type: ORGANIZATION_GROUP_ENTITY_TYPE },
{ _type: OrganizationGroupEntityMetadata._type },
async (groupEntity) => {
const groupData = getRawData(groupEntity) as AirWatchOrganizationGroup;
for (const childGroup of groupData?.Children || []) {
Expand All @@ -60,9 +60,9 @@ export async function fetchOrganizationGroups({
await jobState.addRelationship(
createDirectRelationship({
_class: ORGANIZATION_GROUP_RELATIONSHIP_CLASS,
fromType: ORGANIZATION_GROUP_ENTITY_TYPE,
fromType: OrganizationGroupEntityMetadata._type,
fromKey: groupEntity._key,
toType: ORGANIZATION_GROUP_ENTITY_TYPE,
toType: OrganizationGroupEntityMetadata._type,
toKey: childEntityKey,
}),
);
Expand Down
23 changes: 7 additions & 16 deletions src/steps/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import {
} from '@jupiterone/integration-sdk-core';

import { IntegrationConfig } from '../types';
import {
ACCOUNT_ENTITY_CLASS,
ACCOUNT_ENTITY_TYPE,
STEP_FETCH_ACCOUNT,
} from './constants';
import { Entities, STEP_FETCH_ACCOUNT } from './constants';
import { createAccountAssignEntity } from '../entities';

export const ACCOUNT_ENTITY_KEY = 'entity:account';

Expand All @@ -24,13 +21,13 @@ export async function fetchAccountDetails({
host: instance.config.airwatchHost,
username: instance.config.airwatchUsername,
},
assign: {
_class: ACCOUNT_ENTITY_CLASS,
_type: ACCOUNT_ENTITY_TYPE,
assign: createAccountAssignEntity({
_key: `airwatch-${instance.id}`,
name: instance.config.airwatchHost,
displayName: instance.config.airwatchHost,
webLink: `https://${instance.config.airwatchHost}`,
},
vendor: 'AirWatch',
}),
},
}),
);
Expand All @@ -42,13 +39,7 @@ export const accountSteps: IntegrationStep<IntegrationConfig>[] = [
{
id: STEP_FETCH_ACCOUNT,
name: 'Fetch Account Details',
entities: [
{
resourceName: 'Account',
_type: ACCOUNT_ENTITY_TYPE,
_class: ACCOUNT_ENTITY_CLASS,
},
],
entities: [Entities.ACCOUNT],
relationships: [],
dependsOn: [],
executionHandler: fetchAccountDetails,
Expand Down
26 changes: 11 additions & 15 deletions src/steps/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import {

import { IntegrationConfig } from '../types';
import {
DEVICE_ENTITY_TYPE,
DEVICE_PROFILE_REATIONSHIP_CLASS,
ORGANIZATION_GROUP_ENTITY_TYPE,
PROFILE_ENTITY_CLASS,
PROFILE_ENTITY_TYPE,
Entities,
Relationships,
STEP_BUILD_PROFILE_TO_DEVICE,
STEP_FETCH_DEVICES,
Expand All @@ -19,6 +16,11 @@ import {
} from './constants';
import { createAPIClient } from '../client';
import { createProfileEntity } from './converters';
import {
OrganizationGroupEntityMetadata,
ProfileEntityMetadata,
UserEndpointEntityMetadata,
} from '../entities';

export async function fetchProfiles({
instance,
Expand All @@ -27,7 +29,7 @@ export async function fetchProfiles({
}: IntegrationStepExecutionContext<IntegrationConfig>) {
const apiClient = createAPIClient(instance.config);
await jobState.iterateEntities(
{ _type: ORGANIZATION_GROUP_ENTITY_TYPE },
{ _type: OrganizationGroupEntityMetadata._type },
async (groupEntity) => {
await apiClient.iterateOrganizationGroupProfiles(async (profile) => {
const profileEntity = createProfileEntity(apiClient.host, profile);
Expand All @@ -51,7 +53,7 @@ export async function buildDeviceProfileRelationships({
}: IntegrationStepExecutionContext<IntegrationConfig>) {
const apiClient = createAPIClient(instance.config);
await jobState.iterateEntities(
{ _type: PROFILE_ENTITY_TYPE },
{ _type: ProfileEntityMetadata._type },
async (profileEntity) => {
try {
const response = await apiClient.fetchDevicesForProfile(
Expand All @@ -70,9 +72,9 @@ export async function buildDeviceProfileRelationships({
createDirectRelationship({
_class: DEVICE_PROFILE_REATIONSHIP_CLASS,
fromKey: device.uuid,
fromType: DEVICE_ENTITY_TYPE,
fromType: UserEndpointEntityMetadata._type,
toKey: profileEntity._key,
toType: PROFILE_ENTITY_TYPE,
toType: ProfileEntityMetadata._type,
}),
);
} else {
Expand All @@ -96,13 +98,7 @@ export const profileSteps: IntegrationStep<IntegrationConfig>[] = [
{
id: STEP_FETCH_PROFILES,
name: 'Fetch Profile Details',
entities: [
{
resourceName: 'Profile',
_type: PROFILE_ENTITY_TYPE,
_class: PROFILE_ENTITY_CLASS,
},
],
entities: [Entities.PROFILE],
relationships: [],
dependsOn: [STEP_FETCH_ORGANIZATION_GROUPS],
executionHandler: fetchProfiles,
Expand Down

0 comments on commit b16a55b

Please sign in to comment.