import { ITGlueClient } from '../client'; import { QueryUtilOptions, QueryParams, RequestBody, BaseListResponse, BaseItemResponse, ExportResource } from '../types'; /** * Exports resource module for IT Glue API * * Provides methods to interact with the /exports endpoint. * Exports enable you to create, manage, and download data exports from IT Glue, * allowing you to extract organizational data in various formats for backup, * migration, reporting, or compliance purposes. This resource manages the * export lifecycle from creation through completion and download. * * ## Related Resources * Exports are commonly used with: * - {@link Organizations} - Export organizational data and structure * - {@link Configurations} - Export IT infrastructure and asset details * - {@link Contacts} - Export personnel and contact information * - {@link Documents} - Export files and documentation attachments * - {@link Passwords} - Export encrypted credential data securely * - {@link FlexibleAssets} - Export custom data structures and forms * - {@link Locations} - Export site and facility information * - {@link Users} - Export user account and activity data * - {@link UserMetrics} - Export user activity analytics and insights * - {@link Tags} - Export categorization and labeling data * - {@link Attachments} - Export file attachments and media content * - {@link RelatedItems} - Export resource relationships and connections * * @see {@link Organizations#list} for retrieving organizational data for export * @see {@link Configurations#list} for retrieving configuration data for export * @see {@link Documents#list} for retrieving documents for export * @see {@link UserMetrics#list} for retrieving user activity data for export * * @example * import { ITGlueClient } from '../client'; * import { Exports } from './resources/exports'; * * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const exports = new Exports(client); * * // List exports * const list = await exports.list(); * * // Get a single export * const exportItem = await exports.get('123'); * * // Create a new export * const created = await exports.create({ * data: { * type: 'exports', * attributes: { * export_type: 'organizations' * } * } * }); * * // Delete an export * await exports.delete('123'); * * @category Data Management */ export declare class Exports { private client; private basePath; private paginationUtil; /** * Create an Exports resource instance * @param {ITGlueClient} client - ITGlueClient instance */ constructor(client: ITGlueClient); /** * List all exports * * Retrieves a list of all data exports created in your IT Glue organization, * including their current status, creation dates, and download availability. * Use this to monitor export progress, find completed exports ready for download, * or manage export history and cleanup. * * Exports are automatically managed through their lifecycle from creation to * expiration. This endpoint provides visibility into all export operations * and their current states. * * @param {QueryUtilOptions} [options] - Optional query parameters (filter, sort, page, etc.) * @param {boolean} [allPages=false] - If true, fetches all pages automatically * @returns {Promise>} List of export resources and pagination metadata * @throws {Error} When access denied (403) or invalid filter parameters (422) * @example * // List all exports (default sorting by newest first) * await exports.list(); * @example * // Filter exports by status and type * await exports.list({ * filter: { * status: 'completed', * export_type: 'organizations' * }, * sort: '-created_at', * page: { number: 1, size: 50 } * }); * @example * // Monitor recent export progress * await exports.list({ * filter: { * status: ['processing', 'completed'], * created_at: '2024-01-01..' * }, * sort: '-created_at', * include: ['download_url'] * }); * @example * // Error handling for export listing * try { * const exports = await exports.list({ * filter: { invalid_field: 'value' } * }); * } catch (error) { * if (error.response?.status === 403) { * console.log('Insufficient permissions to access exports'); * } else if (error.response?.status === 422) { * console.log('Invalid filter parameters:', error.response.data.errors); * } * } * @example * // Find completed exports ready for download * const completedExports = await exports.list({ * filter: { * status: 'completed', * download_url: 'not_null' * }, * sort: '-completed_at' * }); * * for (const exportItem of completedExports.data) { * console.log(`Export ${exportItem.id} (${exportItem.attributes.export_type}) ready for download`); * } */ list(options?: QueryUtilOptions, allPages?: boolean): Promise>; /** * Get a single export by ID * * Retrieves detailed information about a specific export, including its current * status, progress, download URL (if completed), and metadata. Use this to check * export progress, retrieve download links, or get detailed export information * for monitoring and management purposes. * * @param {string} id - Export ID (required) * @param {QueryParams} [params] - Optional query parameters * @returns {Promise>} Export resource * @throws {Error} When export not found (404) or access denied (403) * @example * // Get a specific export * await exports.get('123'); * @example * // Get export with download URL and metadata * await exports.get('123', { * include: ['download_url', 'file_size', 'record_count'] * }); * @example * // Error handling for export retrieval * try { * const exportItem = await exports.get('invalid-id'); * } catch (error) { * if (error.response?.status === 404) { * console.log('Export not found'); * } else if (error.response?.status === 403) { * console.log('Access denied to export'); * } * } * @example * // Monitor export progress and download when ready * const exportItem = await exports.get('123'); * * if (exportItem.data.attributes.status === 'completed') { * const downloadUrl = exportItem.data.attributes.download_url; * console.log(`Export completed! Download: ${downloadUrl}`); * console.log(`File size: ${exportItem.data.attributes.file_size} bytes`); * console.log(`Records exported: ${exportItem.data.attributes.record_count}`); * } else if (exportItem.data.attributes.status === 'processing') { * console.log(`Export in progress: ${exportItem.data.attributes.progress_percentage}% complete`); * } else if (exportItem.data.attributes.status === 'failed') { * console.log(`Export failed: ${exportItem.data.attributes.error_message}`); * } * @see * {@link Organizations#get} - Get specific organization details * {@link Organizations#list} - List organizations related to exports */ get(id: string, params?: QueryParams): Promise>; /** * Create a new export * * Initiates a new data export operation for the specified resource type and * configuration. The export will be processed asynchronously, and you can * monitor its progress using the get() method. Once completed, the export * will be available for download through the provided URL. * * Export creation supports various options for customizing the output format, * filtering data, and specifying export parameters to meet your specific * data extraction requirements. * * @param {RequestBody} data - Export data (must be formatted according to JSON:API spec) * @returns {Promise>} Created export resource * @throws {Error} When validation fails (422) or access denied (403) * @example * // Create a basic organization export * await exports.create({ * data: { * type: 'exports', * attributes: { * export_type: 'organizations', * format: 'json' * } * } * }); * @example * // Create a filtered configuration export with specific options * await exports.create({ * data: { * type: 'exports', * attributes: { * export_type: 'configurations', * format: 'csv', * filter: { * organization_id: '123', * configuration_type_id: '456' * }, * include_relationships: true, * include_attachments: false * } * } * }); * @example * // Error handling for export creation * try { * const newExport = await exports.create({ * data: { * type: 'exports', * attributes: { * export_type: 'invalid_type' * } * } * }); * } catch (error) { * if (error.response?.status === 422) { * console.log('Invalid export parameters:', error.response.data.errors); * } else if (error.response?.status === 403) { * console.log('Insufficient permissions to create exports'); * } * } * @example * // Create export and monitor progress * const newExport = await exports.create({ * data: { * type: 'exports', * attributes: { * export_type: 'organizations', * format: 'json', * include_relationships: true * } * } * }); * * console.log(`Export created with ID: ${newExport.data.id}`); * console.log(`Status: ${newExport.data.attributes.status}`); * * // Poll for completion (in a real application, use proper polling with delays) * const checkProgress = async () => { * const status = await exports.get(newExport.data.id); * if (status.data.attributes.status === 'completed') { * console.log(`Export ready! Download: ${status.data.attributes.download_url}`); * } else { * console.log(`Progress: ${status.data.attributes.progress_percentage}%`); * } * }; * @see * {@link Organizations#create} - Create new organization * {@link Organizations#list} - List organizations related to exports */ create(data: RequestBody): Promise>; /** * Delete an export by ID * * Permanently removes an export and its associated files from IT Glue. * This action cannot be undone, and any download URLs will become invalid. * Use this to clean up completed exports, remove failed exports, or manage * storage space by deleting exports that are no longer needed. * * Note: Exports are automatically cleaned up after their retention period, * but manual deletion allows for immediate cleanup when needed. * * @param {string} id - Export ID (required) * @returns {Promise} * @throws {Error} When export not found (404), access denied (403), or export cannot be deleted (409) * @example * // Delete a completed export * await exports.delete('123'); * @example * // Delete a failed export with error handling * try { * await exports.delete('456'); * console.log('Export deleted successfully'); * } catch (error) { * if (error.response?.status === 404) { * console.log('Export not found or already deleted'); * } else if (error.response?.status === 403) { * console.log('Insufficient permissions to delete export'); * } else if (error.response?.status === 409) { * console.log('Export cannot be deleted (may be in progress)'); * } * } * @example * // Clean up old completed exports * const oldExports = await exports.list({ * filter: { * status: 'completed', * created_at: '..2024-01-01' * } * }); * * for (const exportItem of oldExports.data) { * try { * await exports.delete(exportItem.id); * console.log(`Deleted old export: ${exportItem.id}`); * } catch (error) { * console.log(`Failed to delete export ${exportItem.id}:`, error.message); * } * } * @see * {@link Organizations#list} - List organizations related to exports * {@link Organizations#get} - Get specific organization details */ delete(id: string): Promise; }