Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add create software for internal api #106

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import got from 'got'
import { v4 as uuidv4 } from 'uuid'
import {
CreateSoftware,
CreateWebContentFilterPayload,
CustomFact,
CustomProfilePayload,
Expand All @@ -18,6 +19,7 @@ import {
PPPCService,
ServiceManagementPayload,
ServiceManagementPayloadRule,
Software,
SupportedOsVersions,
SystemExtensionPayload,
WebContentFilterPayload,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<Software> {
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<object[]> {
try {
let res = await this._addigyRequest('https://app-prod.addigy.com/api/account', {
Expand Down Expand Up @@ -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,
Expand Down
112 changes: 112 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}