From 09187cec02c509b3e1065f4248d0c63f336096ba Mon Sep 17 00:00:00 2001 From: Santese Smith <43831817+santese@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:50:53 -0700 Subject: [PATCH] feat: add create software for internal api --- src/index.ts | 39 ++++++++++++++++-- src/types.ts | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 055f06d..64bfd5d 100755 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import got from 'got' import { v4 as uuidv4 } from 'uuid' import { + CreateSoftware, CreateWebContentFilterPayload, CustomFact, CustomProfilePayload, @@ -18,6 +19,7 @@ import { PPPCService, ServiceManagementPayload, ServiceManagementPayloadRule, + Software, SupportedOsVersions, SystemExtensionPayload, WebContentFilterPayload, @@ -487,6 +489,17 @@ export class Addigy { } } + /** + * V1 API - Creates a custom software object in Addigy. + * @param baseIdentifier + * @param version + * @param downloads + * @param installationScript + * @param condition + * @param removeScript + * @param priority + * @returns + */ async createCustomSoftware( baseIdentifier: string, version: string, @@ -523,6 +536,28 @@ export class Addigy { // The following endpoints use Addigy's internal API. Use at your own risk. // + /** + * Internal API - Creates a custom software object in Addigy. This is the internal API, so it is subject to change. + * Different from the V1 API, this allows for things like setting priority. + * @param authObject + * @param software + * @returns + */ + async createSoftwareInternal( + authObject: IAddigyInternalAuthObject, + software: CreateSoftware, + ): Promise { + const res = await this._addigyRequest('https://app.addigy.com/api/software', { + headers: { + Cookie: `auth_token=${authObject.authToken};`, + origin: 'https://app-prod.addigy.com', + }, + method: 'POST', + json: software, + }) + return JSON.parse(res.body) + } + async getUsers(authObject: IAddigyInternalAuthObject): Promise { try { let res = await this._addigyRequest('https://app-prod.addigy.com/api/account', { @@ -1060,12 +1095,10 @@ export class Addigy { } } - /* + /** @param {string} payloadName - Name of the profile @param {string} userDefinedName - Name of the filter to be displayed in the User @param {string} pluginBundleId - Bundle ID of the plugin to be used for filtering - - */ async createWebContentFilterPolicy( authObject: IAddigyInternalAuthObject, diff --git a/src/types.ts b/src/types.ts index bc98269..c3e14cc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -382,3 +382,115 @@ export interface CreateWebContentFilterPayload { requires_device_supervision?: boolean requires_mdm_profile_approved?: boolean } + +export interface Software { + name: string + provider: string + identifier: string + version: string + instruction_id: string + base_identifier: string + public_software_instruction_id: string + fact_identifier: string + run_on_success: boolean + predefined_conditions: PredefinedConditions + condition: string + remove_script: string + policy_restricted: boolean + status_on_skipped: string + user_email: string + label: string + public: boolean + organization_id: string + downloads: any[] + profiles: any[] + installation_script: string + price_per_device: number + priority: number + tcc_version: number + type: string + category: string + software_icon: SoftwareIcon + description: string + archived: boolean +} + +export interface CreateSoftware { + base_identifier: string + version: string + downloads: SoftwareDownload[] + profiles: any[] + installation_script: string + remove_script: string + condition: string + predefined_conditions: PredefinedConditions + public: boolean | null + software_icon: SoftwareIcon + run_on_success: boolean + status_on_skipped: string + priority: number + category: string +} + +export interface PredefinedConditions { + os_version: OSVersion + app_exists: AppExists + file_exists: FileExists + file_not_exists: FileExists + profile_exists: ProfileExists + process_not_running: ProcessNotRunning + required_architecture: RequiredArchitecture +} + +export interface AppExists { + enabled: boolean + operator: string + version: string + path: string + install_if_not_present: boolean +} + +export interface FileExists { + enabled: boolean + path: string +} + +export interface OSVersion { + enabled: boolean + operator: string + version: string +} + +export interface ProcessNotRunning { + enabled: boolean + process_name: string +} + +export interface ProfileExists { + enabled: boolean + profile_id: string +} + +export interface RequiredArchitecture { + enabled: boolean + apple_silicon: boolean +} + +export interface SoftwareIcon { + orgid: string + filename: string + id: string + provider: string +} + +export interface SoftwareDownload { + orgid: string + created: Date + content_type: string + filename: string + id: string + md5_hash: string + provider: string + user_email: string + size: number +}