import { ITGlueClient } from '../client'; import { QueryUtilOptions, QueryParams, RequestBody, BaseListResponse, BaseItemResponse, FlexibleAssetFieldResource } from '../types'; /** * FlexibleAssetFields resource module for IT Glue API * * Provides methods to interact with the /flexible_asset_fields endpoint. * Flexible asset fields define the individual custom fields (traits) that make up flexible asset types. * Each field specifies its data type (text, number, date, tag, relationship, etc.), validation rules, * display options, and ordering within the flexible asset type. Fields determine what information * can be captured when creating flexible assets of a specific type. * * ## Related Resources * Flexible asset fields are commonly used with: * - {@link FlexibleAssetTypes} - Parent types that contain these field definitions * - {@link FlexibleAssets} - Assets that use these fields to store data * - {@link Organizations} - Organizations that create custom field configurations * - {@link Configurations} - IT assets that may be referenced by flexible asset fields * - {@link Contacts} - People who may be referenced in relationship fields * - {@link Documents} - Documentation that may be linked through flexible asset fields * - {@link Tags} - Categorization options available in tag-type fields * - {@link RelatedItems} - Cross-resource relationships defined by flexible asset fields * - {@link Passwords} - Credential information stored in password-type fields * - {@link Locations} - Physical locations that may be referenced in location fields * - {@link Attachments} - Files and documents referenced through attachment fields * * @see {@link FlexibleAssetTypes#list} for retrieving parent flexible asset types * @see {@link FlexibleAssets#list} for retrieving assets using these fields * @see {@link Organizations#list} for retrieving organizations with custom fields * @see {@link FlexibleAssets#create} for creating assets with field data * * @example * import { ITGlueClient } from '../client'; * import { FlexibleAssetFields } from './resources/flexible-asset-fields'; * * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const flexibleAssetFields = new FlexibleAssetFields(client); * * // List flexible asset fields * const list = await flexibleAssetFields.list(); * * // Get a single flexible asset field * const field = await flexibleAssetFields.get('123'); * * // Create a new flexible asset field * const created = await flexibleAssetFields.create({ * data: { * type: 'flexible_asset_fields', * attributes: { * name: 'Server Name', * field_type: 'text' * } * } * }); * * // Update a flexible asset field * const updated = await flexibleAssetFields.update('123', { * data: { * type: 'flexible_asset_fields', * attributes: { * name: 'Updated Server Name' * } * } * }); * * // Bulk update multiple flexible asset fields * const bulkUpdated = await flexibleAssetFields.bulkUpdate({ * data: [ * { * type: 'flexible_asset_fields', * id: '123', * attributes: { name: 'Updated Field 1' } * }, * { * type: 'flexible_asset_fields', * id: '124', * attributes: { name: 'Updated Field 2' } * } * ] * }); * * // Delete a flexible asset field * await flexibleAssetFields.delete('123'); * * @category Assets */ export declare class FlexibleAssetFields { private client; private basePath; private paginationUtil; /** * Create a FlexibleAssetFields resource instance * @param {ITGlueClient} client - ITGlueClient instance */ constructor(client: ITGlueClient); /** * List all flexible asset fields * @param {QueryUtilOptions} [options] - Optional query parameters (filter, sort, page, etc.) * @param {boolean} [allPages=false] - If true, fetches all pages automatically * @returns {Promise>} List of flexible asset fields and pagination metadata * @example * // List all flexible asset fields * await flexibleAssetFields.list(); * @example * // List fields for a specific flexible asset type * await flexibleAssetFields.list({ * filter: { flexible_asset_type_id: '123' }, * sort: 'order' * }); * @example * // List fields with pagination and related data * await flexibleAssetFields.list({ * page: { number: 1, size: 25 }, * sort: 'name', * include: ['flexible_asset_type'] * }); */ list(options?: QueryUtilOptions, allPages?: boolean): Promise>; /** * Get a single flexible asset field by ID * @param {string} id - Flexible asset field ID * @param {QueryParams} [params] - Optional query parameters * @returns {Promise>} Flexible asset field resource * @example * const field = await flexibleAssetFields.get('123'); * @example * // Get field with related flexible asset type * const field = await flexibleAssetFields.get('123', { * include: ['flexible_asset_type'] * }); */ get(id: string, params?: QueryParams): Promise>; /** * Create a new flexible asset field * @param {RequestBody} data - Flexible asset field data (must be formatted according to JSON:API spec) * @returns {Promise>} Created flexible asset field resource * @example * const created = await flexibleAssetFields.create({ * data: { * type: 'flexible_asset_fields', * attributes: { * name: 'License Key', * field_type: 'text', * flexible_asset_type_id: '123', * order: 1, * required: true * } * } * }); * @example * // Create field with advanced configuration * const created = await flexibleAssetFields.create({ * data: { * type: 'flexible_asset_fields', * attributes: { * name: 'Expiration Date', * field_type: 'date', * flexible_asset_type_id: '123', * order: 2, * required: false, * hint: 'Enter the license expiration date' * } * } * }); */ create(data: RequestBody): Promise>; /** * Update a flexible asset field by ID * @param {string} id - Flexible asset field ID * @param {RequestBody} data - Updated flexible asset field data (must be formatted according to JSON:API spec) * @returns {Promise>} Updated flexible asset field resource * @example * const updated = await flexibleAssetFields.update('123', { * data: { * type: 'flexible_asset_fields', * attributes: { * name: 'Updated License Key', * hint: 'Enter the software license key' * } * } * }); * @example * // Update field ordering and requirements * const updated = await flexibleAssetFields.update('123', { * data: { * type: 'flexible_asset_fields', * attributes: { * order: 5, * required: false, * show_in_list: true * } * } * }); */ update(id: string, data: RequestBody): Promise>; /** * Bulk update multiple flexible asset fields * * Updates multiple flexible asset fields in a single operation. This is particularly * useful for reordering fields, updating multiple field properties at once, or making * batch changes to field configurations. The operation is atomic - either all updates * succeed or none are applied. * * @param {RequestBody} data - Bulk update data containing multiple flexible asset fields * @returns {Promise>} Updated flexible asset fields * @throws {Error} When validation fails for any field (422) or fields not found (404) * @example * // Bulk update field names and properties * const bulkUpdated = await flexibleAssetFields.bulkUpdate({ * data: [ * { * type: 'flexible_asset_fields', * id: '123', * attributes: { * name: 'Primary License Key', * required: true * } * }, * { * type: 'flexible_asset_fields', * id: '124', * attributes: { * name: 'Secondary License Key', * required: false * } * } * ] * }); * @example * // Bulk reorder fields by updating order values * const reordered = await flexibleAssetFields.bulkUpdate({ * data: [ * { * type: 'flexible_asset_fields', * id: '123', * attributes: { order: 1 } * }, * { * type: 'flexible_asset_fields', * id: '124', * attributes: { order: 2 } * }, * { * type: 'flexible_asset_fields', * id: '125', * attributes: { order: 3 } * } * ] * }); * @example * // Error handling for bulk update validation * try { * const bulkUpdated = await flexibleAssetFields.bulkUpdate({ * data: [ * { * type: 'flexible_asset_fields', * id: '123', * attributes: { name: '' } // Invalid empty name * } * ] * }); * } catch (error) { * if (error.response?.status === 422) { * console.log('Validation errors:', error.response.data.errors); * } * } */ bulkUpdate(data: RequestBody): Promise>; /** * Delete a flexible asset field by ID * @param {string} id - Flexible asset field ID * @returns {Promise} * @example * await flexibleAssetFields.delete('123'); */ delete(id: string): Promise; }