import { ITGlueClient } from '../client'; import { QueryUtilOptions, BaseListResponse, DomainResource } from '../types'; /** * Domains resource module for IT Glue API * * Provides methods to interact with the /domains endpoint. * Domains represent DNS domain names and web domains associated with organizations * in IT Glue. They provide reference data for tracking domain ownership, DNS * configurations, SSL certificates, and web services. Examples include company * websites, email domains, and application-specific domains. * * **Note: This is a read-only resource.** Domains cannot be created, updated, or deleted * through the API as they are typically managed through domain registrars and DNS * providers, with IT Glue serving as a reference and documentation system. * * ## Related Resources * Domains are commonly used with: * - {@link Organizations} - Organizations that own and manage domains * - {@link Configurations} - Web servers, DNS servers, and email systems using domains * - {@link ConfigurationTypes} - Types of systems that utilize domains (web servers, mail servers) * - {@link Contacts} - People responsible for domain management and registration * - {@link Locations} - Physical locations where domain services are hosted * - {@link Documents} - DNS configuration documentation and domain certificates * - {@link FlexibleAssets} - Custom tracking of SSL certificates and domain renewals * - {@link Passwords} - Domain registrar and DNS management credentials * - {@link Expirations} - Track domain registration and certificate expiration dates * - {@link Tags} - Categorize domains by purpose, environment, or owner * - {@link Attachments} - Store SSL certificates and domain configuration files * - {@link RelatedItems} - Create relationships between domains and hosting infrastructure * * @see {@link Organizations#list} for retrieving domain owners * @see {@link Configurations#list} for retrieving domain-related infrastructure * @see {@link Expirations#list} for retrieving domain and certificate expiration tracking * @see {@link Documents#list} for retrieving domain configuration documentation * * @example * import { ITGlueClient } from '../client'; * import { Domains } from './resources/domains'; * * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const domains = new Domains(client); * * // List domains * const list = await domains.list(); * * // List domains for a specific organization * const filtered = await domains.list({ * filter: { organization_id: '123' } * }); * * @category Reference Data */ export declare class Domains { private client; private basePath; private paginationUtil; /** * Create a Domains resource instance * @param {ITGlueClient} client - ITGlueClient instance */ constructor(client: ITGlueClient); /** * List all domains * * Retrieves a list of domains tracked in IT Glue. Domains are read-only reference * data representing DNS domain names and web domains associated with organizations. * This information is typically used for documentation, SSL certificate tracking, * and network infrastructure management. * * @param {QueryUtilOptions} [options] - Optional query parameters (filter, sort, page, etc.) * @param {boolean} [allPages=false] - If true, fetches all pages automatically * @returns {Promise>} List of domains and pagination metadata * @example * // Basic usage - get first page of domains * const results = await client.domains.list(); * console.log(`Found ${results.data.length} domains`); * console.log('Total pages:', results.meta.pagination.total_pages); * * @example * // Advanced usage with pagination and sorting * const results = await client.domains.list({ * page: { number: 2, size: 50 }, * sort: 'name', // Sort domains alphabetically * include: ['organization'] // Include organization data * }); * * // Access domain information * results.data.forEach(domain => { * console.log(`Domain: ${domain.attributes.name}`); * console.log(`Organization ID: ${domain.relationships?.organization?.data?.id}`); * }); * * @example * // Filtering domains by organization * const companyDomains = await client.domains.list({ * filter: { * organization_id: '123' * }, * sort: 'name' * }); * * console.log(`Found ${companyDomains.data.length} domains for organization`); * * @example * // Get all domains across multiple pages for domain inventory * const allDomains = await client.domains.list({}, true); // allPages = true * console.log(`Retrieved all ${allDomains.data.length} domains`); * * // Group domains by organization * const domainsByOrg = {}; * allDomains.data.forEach(domain => { * const orgId = domain.relationships?.organization?.data?.id || 'unassigned'; * if (!domainsByOrg[orgId]) { * domainsByOrg[orgId] = []; * } * domainsByOrg[orgId].push(domain.attributes.name); * }); * * @example * // Manual pagination for large domain datasets * async function getAllDomainsByOrganization(orgId) { * let page = 1; * let allDomains = []; * let hasMore = true; * * while (hasMore) { * const response = await client.domains.list({ * filter: { organization_id: orgId }, * page: { number: page, size: 100 }, * sort: 'name' * }); * * allDomains = [...allDomains, ...response.data]; * hasMore = response.meta.pagination.total_pages > page; * page++; * } * * return allDomains; * } * * @example * // Domain audit and reporting * async function generateDomainReport() { * try { * const domains = await client.domains.list({ * include: ['organization'], * sort: 'name' * }, true); * * const report = { * totalDomains: domains.data.length, * domainsByOrganization: {}, * topLevelDomains: {} * }; * * domains.data.forEach(domain => { * const domainName = domain.attributes.name; * const orgId = domain.relationships?.organization?.data?.id || 'unassigned'; * * // Count by organization * if (!report.domainsByOrganization[orgId]) { * report.domainsByOrganization[orgId] = 0; * } * report.domainsByOrganization[orgId]++; * * // Count top-level domains * const tld = domainName.split('.').pop()?.toLowerCase(); * if (tld) { * if (!report.topLevelDomains[tld]) { * report.topLevelDomains[tld] = 0; * } * report.topLevelDomains[tld]++; * } * }); * * return report; * } catch (error) { * console.error('Failed to generate domain report:', error.message); * throw error; * } * } * * @example * // Error handling for list operations * try { * const results = await client.domains.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 domains'); * } else if (error.response?.status === 429) { * console.log('Rate limit exceeded - please wait before retrying'); * } else { * console.log('Request failed:', error.message); * } * } * * @example * // Search for specific domain patterns * async function findDomainsByPattern(pattern) { * try { * // Get all domains since filtering by name pattern may not be supported * const allDomains = await client.domains.list({}, true); * * // Filter domains that match the pattern * const matchingDomains = allDomains.data.filter(domain => { * const domainName = domain.attributes.name.toLowerCase(); * return domainName.includes(pattern.toLowerCase()); * }); * * return matchingDomains; * } catch (error) { * console.error('Domain search failed:', error.message); * return []; * } * } * * // Usage: Find all domains containing 'company' * const companyDomains = await findDomainsByPattern('company'); */ list(options?: QueryUtilOptions, allPages?: boolean): Promise>; }