import { ITGlueClient } from '../client'; import { QueryUtilOptions, QueryParams, RequestBody, BaseListResponse, BaseItemResponse, ConfigurationInterfaceResource } from '../types'; /** * ConfigurationInterfaces resource module for IT Glue API * * Provides methods to interact with the /configuration_interfaces endpoint. * Configuration interfaces represent network interfaces, connections, and endpoints * associated with configurations. They track IP addresses, hostnames, ports, and * other network-related information for IT assets. * * ## Related Resources * Configuration interfaces are commonly used with: * - {@link Configurations} - Parent IT assets that own these network interfaces * - {@link ConfigurationTypes} - Types of configurations that have interfaces * - {@link ConfigurationStatuses} - Status information inherited from parent configurations * - {@link Organizations} - Organizations that own configurations with interfaces * - {@link Locations} - Physical locations where networked configurations are deployed * - {@link Documents} - Network documentation and configuration guides * - {@link Passwords} - Network credentials and access information * - {@link FlexibleAssets} - Custom network tracking and IP address management * - {@link RelatedItems} - Relationships between interfaces and other network components * - {@link Tags} - Categorization of interfaces by purpose or network segment * - {@link Manufacturers} - Hardware manufacturers of network equipment * - {@link Models} - Specific models of network devices and equipment * * @see {@link Configurations#list} for retrieving parent configurations * @see {@link ConfigurationTypes#list} for retrieving configuration types * @see {@link Organizations#list} for retrieving organizations with network assets * @see {@link Locations#list} for retrieving deployment locations * * @example * import { ITGlueClient } from '../client'; * import { ConfigurationInterfaces } from './resources/configuration-interfaces'; * * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const configInterfaces = new ConfigurationInterfaces(client); * * // List configuration interfaces * const list = await configInterfaces.list(); * * // Get a single configuration interface * const iface = await configInterfaces.get('123'); * * // Create a configuration interface * const created = await configInterfaces.create({ * data: { * type: 'configuration_interfaces', * attributes: { 'ip-address': '192.168.1.100' } * } * }); * * // Update a configuration interface * const updated = await configInterfaces.update('123', { * data: { * type: 'configuration_interfaces', * attributes: { hostname: 'server01.company.com' } * } * }); * * // Delete a configuration interface * await configInterfaces.delete('123'); * * @category Configurations */ export declare class ConfigurationInterfaces { private client; private basePath; private paginationUtil; /** * Create a ConfigurationInterfaces resource instance * @param {ITGlueClient} client - ITGlueClient instance */ constructor(client: ITGlueClient); /** * List all configuration interfaces * @param {QueryUtilOptions} [options] - Optional query parameters (filter, sort, page, etc.) * @param {boolean} [allPages=false] - If true, fetches all pages automatically * @returns {Promise>} List of configuration interfaces and pagination metadata * @example * // Basic usage - get first page of configuration interfaces * const results = await client.configurationInterfaces.list(); * console.log(`Found ${results.data.length} configuration interfaces`); * console.log('Total pages:', results.meta.pagination.total_pages); * * @example * // Advanced usage with pagination and sorting * const results = await client.configurationInterfaces.list({ * page: { number: 2, size: 50 }, * sort: 'ip-address', // Sort by IP address * include: ['configuration'] // Include parent configuration data * }); * * // Access interface information * results.data.forEach(iface => { * console.log(`Interface: ${iface.attributes['ip-address']}`); * console.log(`Hostname: ${iface.attributes.hostname || 'N/A'}`); * console.log(`Port: ${iface.attributes.port || 'N/A'}`); * console.log(`Type: ${iface.attributes['interface-type'] || 'N/A'}`); * }); * * @example * // Filtering interfaces by configuration and IP range * const serverInterfaces = await client.configurationInterfaces.list({ * filter: { * configuration_id: '456', * 'ip-address': '192.168.1.*' * }, * sort: 'ip-address' * }); * * console.log(`Found ${serverInterfaces.data.length} interfaces for configuration 456`); * * @example * // Get all interfaces for network inventory * const allInterfaces = await client.configurationInterfaces.list({}, true); // allPages = true * console.log(`Retrieved all ${allInterfaces.data.length} configuration interfaces`); * * // Create network inventory map * const networkInventory = {}; * allInterfaces.data.forEach(iface => { * const ip = iface.attributes['ip-address']; * if (ip) { * networkInventory[ip] = { * hostname: iface.attributes.hostname, * port: iface.attributes.port, * type: iface.attributes['interface-type'], * configurationId: iface.relationships?.configuration?.data?.id * }; * } * }); * * // Group interfaces by subnet for network analysis * const subnetGroups = {}; * allInterfaces.data.forEach(iface => { * const ip = iface.attributes['ip-address']; * if (ip) { * const subnet = ip.split('.').slice(0, 3).join('.') + '.0/24'; * if (!subnetGroups[subnet]) { * subnetGroups[subnet] = []; * } * subnetGroups[subnet].push({ * ip: ip, * hostname: iface.attributes.hostname, * configId: iface.relationships?.configuration?.data?.id * }); * } * }); * * @example * // Manual pagination for large interface datasets * async function getAllInterfacesWithConfigs() { * let page = 1; * let allInterfaces = []; * let hasMore = true; * * while (hasMore) { * const response = await client.configurationInterfaces.list({ * page: { number: page, size: 100 }, * sort: 'ip-address', * include: ['configuration'] * }); * * allInterfaces = [...allInterfaces, ...response.data]; * hasMore = response.meta.pagination.total_pages > page; * page++; * } * * return allInterfaces; * } * * @example * // Error handling for list operations * try { * const results = await client.configurationInterfaces.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 interfaces'); * } else { * console.log('Request failed:', error.message); * } * } */ list(options?: QueryUtilOptions, allPages?: boolean): Promise>; /** * Get a single configuration interface by ID * @param {string} id - Configuration interface ID * @param {QueryParams} [params] - Optional query parameters * @returns {Promise>} Configuration interface resource * @example * // Basic usage - get interface by ID * const iface = await client.configurationInterfaces.get('123'); * console.log('IP Address:', iface.data.attributes['ip-address']); * console.log('Hostname:', iface.data.attributes.hostname); * console.log('Port:', iface.data.attributes.port); * console.log('Interface Type:', iface.data.attributes['interface-type']); * * @example * // Get interface with related configuration data * const ifaceWithConfig = await client.configurationInterfaces.get('123', { * include: ['configuration'] * }); * * // Access included data * const included = ifaceWithConfig.included || []; * const configuration = included.find(item => item.type === 'configurations'); * * console.log(`Interface: ${ifaceWithConfig.data.attributes['ip-address']}`); * console.log(`Hostname: ${ifaceWithConfig.data.attributes.hostname}`); * if (configuration) { * console.log(`Configuration: ${configuration.attributes.name}`); * console.log(`Config Type: ${configuration.attributes['configuration-type-name']}`); * } * * @example * // Error handling for get operations * try { * const iface = await client.configurationInterfaces.get('invalid-id'); * } catch (error) { * if (error.response?.status === 404) { * console.log('Configuration interface not found'); * } else if (error.response?.status === 403) { * console.log('Access denied - insufficient permissions'); * } else { * console.log('Error retrieving interface:', error.message); * } * } * * @example * // Safe get with existence check for network validation * async function safeGetInterface(id) { * try { * const iface = await client.configurationInterfaces.get(id); * return { * id: iface.data.id, * ipAddress: iface.data.attributes['ip-address'], * hostname: iface.data.attributes.hostname, * port: iface.data.attributes.port, * type: iface.data.attributes['interface-type'], * macAddress: iface.data.attributes['mac-address'] * }; * } catch (error) { * if (error.response?.status === 404) { * return null; // Interface doesn't exist * } * throw error; // Re-throw other errors * } * } */ get(id: string, params?: QueryParams): Promise>; /** * Create a new configuration interface * @param {RequestBody} data - Configuration interface data (must be formatted according to JSON:API spec) * @returns {Promise>} Created configuration interface resource * @example * const created = await configInterfaces.create({ * data: { * type: 'configuration_interfaces', * attributes: { * 'ip-address': '192.168.1.100', * hostname: 'web01.company.com', * port: 80 * }, * relationships: { * configuration: { * data: { type: 'configurations', id: '456' } * } * } * } * }); * @example * // Create interface with network details * const created = await configInterfaces.create({ * data: { * type: 'configuration_interfaces', * attributes: { * 'ip-address': '10.0.1.50', * 'mac-address': '00:1B:44:11:3A:B7', * 'interface-type': 'Ethernet', * notes: 'Primary network interface' * } * } * }); */ create(data: RequestBody): Promise>; /** * Update a configuration interface by ID * @param {string} id - Configuration interface ID * @param {RequestBody} data - Updated configuration interface data (must be formatted according to JSON:API spec) * @returns {Promise>} Updated configuration interface resource * @example * const updated = await configInterfaces.update('123', { * data: { * type: 'configuration_interfaces', * attributes: { * hostname: 'server01.company.com', * port: 443 * } * } * }); * @example * // Update interface network configuration * const updated = await configInterfaces.update('123', { * data: { * type: 'configuration_interfaces', * attributes: { * 'ip-address': '192.168.1.101', * 'subnet-mask': '255.255.255.0', * 'default-gateway': '192.168.1.1' * } * } * }); */ update(id: string, data: RequestBody): Promise>; /** * Delete a configuration interface by ID * @param {string} id - Configuration interface ID * @returns {Promise} * @example * await configInterfaces.delete('123'); */ delete(id: string): Promise; }