import { ITGlueClient } from '../client'; import { QueryUtilOptions, QueryParams, BaseListResponse, BaseItemResponse, PlatformResource } from '../types'; /** * Platforms resource module for IT Glue API * * Provides methods to interact with the /platforms endpoint. * Platforms represent operating system platforms and hardware/software platform types * used as reference data throughout IT Glue. They define the foundational platform * categories such as Windows, Linux, macOS, VMware, Hyper-V, and other technology * platforms that configurations and assets can be associated with. * * **Note: This is a read-only resource.** Platforms cannot be created, updated, or deleted * through the API as they are maintained as system reference data by IT Glue. * * ## Related Resources * Platforms are commonly used with: * - {@link OperatingSystems} - Operating systems that run on specific platforms * - {@link Configurations} - IT assets and systems associated with platforms * - {@link ConfigurationTypes} - Hardware and software categories that use platforms * - {@link Models} - Hardware and software models that support specific platforms * - {@link Manufacturers} - Companies that produce platform-compatible products * - {@link Organizations} - Organizations that deploy and manage platform-based systems * - {@link FlexibleAssets} - Custom tracking of platform-specific licenses and compatibility * - {@link Documents} - Technical documentation and guides for platforms * - {@link RelatedItems} - Create relationships between platforms and other resources * - {@link Tags} - Categorize resources by platform type or compatibility * - {@link Attachments} - Store platform documentation and compatibility guides * * @see {@link OperatingSystems#list} for retrieving operating systems by platform * @see {@link Configurations#list} for retrieving configurations by platform * @see {@link ConfigurationTypes#list} for retrieving configuration types * @see {@link Models#list} for retrieving platform-compatible models * * @example * import { ITGlueClient } from '../client'; * import { Platforms } from './resources/platforms'; * * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const platforms = new Platforms(client); * * // List platforms * const list = await platforms.list(); * * // Get a single platform * const platform = await platforms.get('1'); * * // List platforms with filtering * const filtered = await platforms.list({ * filter: { name: 'Windows' } * }); * * @category Reference Data */ export declare class Platforms { private client; private basePath; private paginationUtil; /** * Create a Platforms resource instance * @param {ITGlueClient} client - ITGlueClient instance */ constructor(client: ITGlueClient); /** * List all platforms * * Retrieves a list of all available platforms in IT Glue. Platforms are system-maintained * reference data representing operating system and technology platform categories. * This read-only data is used throughout IT Glue for categorizing configurations and assets. * * @param {QueryUtilOptions} [options] - Optional query parameters (filter, sort, page, etc.) * @param {boolean} [allPages=false] - If true, fetches all pages automatically * @returns {Promise>} List of platforms and pagination metadata * @example * // Basic usage - get first page of platforms * const results = await client.platforms.list(); * console.log(`Found ${results.data.length} platforms`); * console.log('Total pages:', results.meta.pagination.total_pages); * * @example * // Advanced usage with pagination and sorting * const results = await client.platforms.list({ * page: { number: 2, size: 50 }, * sort: 'name' // Sort alphabetically * }); * * // Access platform information * results.data.forEach(platform => { * console.log(`Platform: ${platform.attributes.name}`); * console.log(`Type: ${platform.attributes.platform_type || 'N/A'}`); * }); * * @example * // Filtering platforms by name pattern * const windowsPlatforms = await client.platforms.list({ * filter: { * name: 'Windows' * }, * sort: 'name' * }); * * console.log(`Found ${windowsPlatforms.data.length} Windows platforms`); * * @example * // Get all platforms for technology categorization * const allPlatforms = await client.platforms.list({}, true); // allPages = true * console.log(`Retrieved all ${allPlatforms.data.length} platforms`); * * // Create platform lookup map for configuration management * const platformLookup = {}; * allPlatforms.data.forEach(platform => { * platformLookup[platform.id] = { * name: platform.attributes.name, * type: platform.attributes.platform_type, * category: platform.attributes.category * }; * }); * * // Group platforms by category for reporting * const platformsByCategory = { * operatingSystems: [], * virtualization: [], * cloud: [], * hardware: [], * other: [] * }; * * allPlatforms.data.forEach(platform => { * const name = platform.attributes.name.toLowerCase(); * if (name.includes('windows') || name.includes('linux') || name.includes('macos')) { * platformsByCategory.operatingSystems.push(platform.attributes.name); * } else if (name.includes('vmware') || name.includes('hyper-v') || name.includes('virtualbox')) { * platformsByCategory.virtualization.push(platform.attributes.name); * } else if (name.includes('aws') || name.includes('azure') || name.includes('gcp')) { * platformsByCategory.cloud.push(platform.attributes.name); * } else if (name.includes('intel') || name.includes('amd') || name.includes('arm')) { * platformsByCategory.hardware.push(platform.attributes.name); * } else { * platformsByCategory.other.push(platform.attributes.name); * } * }); * * @example * // Manual pagination for large platform datasets * async function getAllPlatformsWithDetails() { * let page = 1; * let allPlatforms = []; * let hasMore = true; * * while (hasMore) { * const response = await client.platforms.list({ * page: { number: page, size: 100 }, * sort: 'name' * }); * * allPlatforms = [...allPlatforms, ...response.data]; * hasMore = response.meta.pagination.total_pages > page; * page++; * } * * return allPlatforms; * } * * @example * // Error handling for list operations * try { * const results = await client.platforms.list({ * filter: { invalid_field: 'value' } * }); * } catch (error) { * if (error.response?.status === 400) { * console.log('Invalid filter parameters:', error.response.data.errors); * } else if (error.response?.status === 401) { * console.log('Authentication failed - check your API key'); * } else if (error.response?.status === 403) { * console.log('Access denied - insufficient permissions to list platforms'); * } else { * console.log('Request failed:', error.message); * } * } */ list(options?: QueryUtilOptions, allPages?: boolean): Promise>; /** * Get a single platform by ID * * Retrieves detailed information about a specific platform. Platforms are read-only * reference data that provide foundational categorization for operating systems, * configurations, and assets within IT Glue. * * @param {string} id - Platform ID * @param {QueryParams} [params] - Optional query parameters * @returns {Promise>} Platform resource * @throws {Error} When platform not found (404) * @example * // Basic usage - get platform by ID * const platform = await client.platforms.get('1'); * console.log('Platform name:', platform.data.attributes.name); * console.log('Platform type:', platform.data.attributes.platform_type); * console.log('Category:', platform.data.attributes.category); * * @example * // Get platform with related operating systems included * const platformWithOS = await client.platforms.get('1', { * include: ['operating_systems'] * }); * * // Access included data * const included = platformWithOS.included || []; * const operatingSystems = included.filter(item => item.type === 'operating_systems'); * * console.log(`Platform: ${platformWithOS.data.attributes.name}`); * console.log(`Operating Systems: ${operatingSystems.length} available`); * operatingSystems.forEach(os => { * console.log(`- ${os.attributes.name} (${os.attributes.version || 'N/A'})`); * }); * * @example * // Error handling for get operations * try { * const platform = await client.platforms.get('invalid-id'); * } catch (error) { * if (error.response?.status === 404) { * console.log('Platform not found'); * } else if (error.response?.status === 403) { * console.log('Access denied - insufficient permissions'); * } else { * console.log('Error retrieving platform:', error.message); * } * } * * @example * // Safe get with existence check for configuration validation * async function safeGetPlatform(id) { * try { * const platform = await client.platforms.get(id); * return { * id: platform.data.id, * name: platform.data.attributes.name, * type: platform.data.attributes.platform_type, * category: platform.data.attributes.category * }; * } catch (error) { * if (error.response?.status === 404) { * return null; // Platform doesn't exist * } * throw error; // Re-throw other errors * } * } * * @example * // Validate platform compatibility for configuration assignment * async function validatePlatformCompatibility(platformId, configType) { * try { * const platform = await client.platforms.get(platformId); * const platformName = platform.data.attributes.name.toLowerCase(); * * // Check compatibility based on platform and configuration type * const compatibility = { * platform: platform.data.attributes.name, * compatible: false, * reason: '' * }; * * if (configType === 'server' && (platformName.includes('windows') || platformName.includes('linux'))) { * compatibility.compatible = true; * compatibility.reason = 'Server configurations supported on this platform'; * } else if (configType === 'workstation' && (platformName.includes('windows') || platformName.includes('macos'))) { * compatibility.compatible = true; * compatibility.reason = 'Workstation configurations supported on this platform'; * } else if (configType === 'virtual' && platformName.includes('vmware')) { * compatibility.compatible = true; * compatibility.reason = 'Virtual configurations supported on this platform'; * } else { * compatibility.reason = `${configType} configurations not typically supported on ${platform.data.attributes.name}`; * } * * return compatibility; * } catch (error) { * return { * platform: 'Unknown', * compatible: false, * reason: error.response?.status === 404 ? 'Platform not found' : error.message * }; * } * } */ get(id: string, params?: QueryParams): Promise>; }