Skip to content

Commit

Permalink
⭐add IDENTITY_OBJECT_CONFIG as an importable object from SP-Config
Browse files Browse the repository at this point in the history
  • Loading branch information
yannick-beot-sp committed Feb 28, 2024
1 parent 83fa257 commit 01e34e0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
14 changes: 2 additions & 12 deletions src/commands/spconfig-import/SPConfigImporter.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import * as vscode from 'vscode';
import { IdentityNowClient } from '../../services/IdentityNowClient';
import { delay } from '../../utils';
import { OBJECT_TYPE_ITEMS } from '../../models/ObjectTypeQuickPickItem';
import { IMPORTABLE_OBJECT_TYPE_ITEMS } from '../../models/ObjectTypeQuickPickItem';
import { ImportOptionsBeta, SpConfigJobBetaStatusEnum } from 'sailpoint-api-client';
import { ImportJobResults } from '../../models/JobStatus';

const ALL: vscode.QuickPickItem = {
label: "Import everything",
picked: true
};

const PICK_AND_CHOOSE: vscode.QuickPickItem = {
label: "Choose what to import"
};


/**
* Base class for all importer
*/
Expand Down Expand Up @@ -103,7 +93,7 @@ export class SPConfigImporter {
}

private mapObjectTypeToLabel(objectType: string): string {
return OBJECT_TYPE_ITEMS.find(x => x.objectType === objectType)?.label ?? "UNKOWN";
return IMPORTABLE_OBJECT_TYPE_ITEMS.find(x => x.objectType === objectType)?.label ?? "UNKOWN";
}


Expand Down
6 changes: 3 additions & 3 deletions src/commands/spconfig-import/WizardBasedImporterCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { OBJECT_TYPE_ITEMS } from '../../models/ObjectTypeQuickPickItem';
import { IMPORTABLE_OBJECT_TYPE_ITEMS } from '../../models/ObjectTypeQuickPickItem';
import { SPConfigImporter } from './SPConfigImporter';
import { askChosenItems, askSelectObjectTypes } from '../../utils/vsCodeHelpers';
import { ImportOptionsBeta, ImportOptionsBetaIncludeTypesEnum } from 'sailpoint-api-client';
Expand Down Expand Up @@ -81,7 +81,7 @@ export abstract class WizardBasedImporterCommand {
// Ask the user to choose which object types
//
// List of ObjectTypeItems based on object types present in the SP Config
const availableObjectTypeItems = OBJECT_TYPE_ITEMS
const availableObjectTypeItems = IMPORTABLE_OBJECT_TYPE_ITEMS
.filter(x => objectTypes.has(x.objectType));
const requestedObjectTypes = await askSelectObjectTypes("Object type to import", availableObjectTypeItems);
if (requestedObjectTypes === undefined) { return; }
Expand All @@ -107,7 +107,7 @@ export abstract class WizardBasedImporterCommand {

if (includeIds === undefined) { continue; }
const includeType: ImportOptionsBetaIncludeTypesEnum = <ImportOptionsBetaIncludeTypesEnum>requestedObjectType.objectType;
options.includeTypes?.push(includeType);
options.includeTypes.push(includeType);

if (pickItems.length !== includeIds.length) {
options.objectOptions[requestedObjectType.objectType] = {
Expand Down
35 changes: 7 additions & 28 deletions src/models/ObjectTypeQuickPickItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface ObjectTypeQuickPickItem extends QuickPickItem {
}

export const EXPORTABLE_OBJECT_TYPE_ITEMS: ObjectTypeQuickPickItem[] = [

{ objectType: ExportPayloadBetaIncludeTypesEnum.AccessProfile, label: "Access Profiles", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.AccessRequestConfig, label: "Access Request Configuration", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.AttrSyncSourceConfig, label: "Attribute Sync Source Configuration", picked: true },
Expand All @@ -33,31 +32,11 @@ export const EXPORTABLE_OBJECT_TYPE_ITEMS: ObjectTypeQuickPickItem[] = [
{ objectType: ExportPayloadBetaIncludeTypesEnum.Workflow, label: "Workflows", picked: true },
]

export const OBJECT_TYPE_ITEMS: ObjectTypeQuickPickItem[] = [

{
objectType: ExportPayloadBetaIncludeTypesEnum.Source,
label: "Sources",
picked: true
},
{
objectType: ExportPayloadBetaIncludeTypesEnum.TriggerSubscription,
label: "Trigger subscriptions",
picked: true
},
{
objectType: ExportPayloadBetaIncludeTypesEnum.IdentityProfile,
label: "Identity profiles",
picked: true
},
{
objectType: ExportPayloadBetaIncludeTypesEnum.Transform,
label: "Transforms",
picked: true
},
{
objectType: ExportPayloadBetaIncludeTypesEnum.Rule,
label: "Rules",
picked: true
}
export const IMPORTABLE_OBJECT_TYPE_ITEMS: ObjectTypeQuickPickItem[] = [
{ objectType: ExportPayloadBetaIncludeTypesEnum.TriggerSubscription, label: "Event Trigger subscriptions", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.IdentityObjectConfig, label: "Identity Object Configuration", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.IdentityProfile, label: "Identity Profiles", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.Rule, label: "Rules", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.Source, label: "Sources", picked: true },
{ objectType: ExportPayloadBetaIncludeTypesEnum.Transform, label: "Transforms", picked: true },
];
4 changes: 2 additions & 2 deletions src/utils/vsCodeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TenantInfoQuickPickItem } from "../models/TenantInfoQuickPickItem";
import { compareByName } from "../utils";
import { isBlank, isEmpty } from "./stringUtils";
import { ObjectPickItem } from "../models/ObjectPickItem";
import { OBJECT_TYPE_ITEMS, ObjectTypeQuickPickItem } from "../models/ObjectTypeQuickPickItem";
import { IMPORTABLE_OBJECT_TYPE_ITEMS, ObjectTypeQuickPickItem } from "../models/ObjectTypeQuickPickItem";

export async function chooseTenant(tenantService: TenantService, title: string): Promise<TenantInfo | undefined> {
console.log("> chooseTenant");
Expand Down Expand Up @@ -244,7 +244,7 @@ export async function askChosenItems(title: string,
* @param objectTypes List of object types to choose from
* @returns
*/
export async function askSelectObjectTypes(title: string, objectTypeItems: Array<ObjectTypeQuickPickItem> = OBJECT_TYPE_ITEMS): Promise<Array<ObjectTypeQuickPickItem> | undefined> {
export async function askSelectObjectTypes(title: string, objectTypeItems: Array<ObjectTypeQuickPickItem> = IMPORTABLE_OBJECT_TYPE_ITEMS): Promise<Array<ObjectTypeQuickPickItem> | undefined> {
const sortedObjectTypeItems = objectTypeItems
.sort(((a, b) => (a.label > b.label) ? 1 : -1));

Expand Down

0 comments on commit 01e34e0

Please sign in to comment.