testrail-modern-client
Version:
A modern TypeScript client for TestRail API
114 lines (113 loc) • 5.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurationService = void 0;
const base_1 = require("./base");
/**
* Service class for managing TestRail configurations and configuration groups.
* Configurations are used to define different test environments or variations for test plans.
*/
class ConfigurationService extends base_1.BaseService {
/**
* Returns a list of available configurations, grouped by configuration groups.
*
* API Path: GET index.php?/api/v2/get_configs/:project_id
*
* @param projectId The ID of the project
* @returns An array of configuration groups, each containing a list of configurations
* @throws {Error} 400 - Invalid or unknown project
* @throws {Error} 403 - No access to the project
*/
async getConfigs(projectId) {
const response = await this.client.get(`/get_configs/${projectId}`);
return response.data;
}
/**
* Creates a new configuration group.
*
* API Path: POST index.php?/api/v2/add_config_group/:project_id
*
* @param projectId The ID of the project the configuration group should be added to
* @param group The configuration group to add (requires name property)
* @returns The created configuration group
* @throws {Error} 400 - Invalid or unknown project
* @throws {Error} 403 - No permissions to add configuration groups or no access to the project
*/
async addConfigGroup(projectId, group) {
const response = await this.client.post(`/add_config_group/${projectId}`, group);
return response.data;
}
/**
* Creates a new configuration within a configuration group.
*
* API Path: POST index.php?/api/v2/add_config/:config_group_id
*
* @param configGroupId The ID of the configuration group the configuration should be added to
* @param config The configuration to add (requires name property)
* @returns The created configuration
* @throws {Error} 400 - Invalid or unknown configuration group
* @throws {Error} 403 - No permissions to add configurations or no access to the project
*/
async addConfig(configGroupId, config) {
const response = await this.client.post(`/add_config/${configGroupId}`, config);
return response.data;
}
/**
* Updates an existing configuration group.
*
* API Path: POST index.php?/api/v2/update_config_group/:config_group_id
*
* @param configGroupId The ID of the configuration group
* @param group The configuration group updates (name property)
* @returns The updated configuration group
* @throws {Error} 400 - Invalid or unknown configuration group
* @throws {Error} 403 - No permissions to modify configuration groups or no access to the project
*/
async updateConfigGroup(configGroupId, group) {
const response = await this.client.post(`/update_config_group/${configGroupId}`, group);
return response.data;
}
/**
* Updates an existing configuration.
*
* API Path: POST index.php?/api/v2/update_config/:config_id
*
* @param configId The ID of the configuration
* @param config The configuration updates (name property)
* @returns The updated configuration
* @throws {Error} 400 - Invalid or unknown configuration
* @throws {Error} 403 - No permissions to modify configurations or no access to the project
*/
async updateConfig(configId, config) {
const response = await this.client.post(`/update_config/${configId}`, config);
return response.data;
}
/**
* Deletes an existing configuration group and its configurations.
* Warning: This operation cannot be undone and permanently deletes all configurations in this group.
* Note: It does not affect closed test plans/runs, or active test plans/runs unless they are updated.
*
* API Path: POST index.php?/api/v2/delete_config_group/:config_group_id
*
* @param configGroupId The ID of the configuration group
* @throws {Error} 400 - Invalid or unknown configuration group
* @throws {Error} 403 - No permissions to delete configuration groups or no access to the project
*/
async deleteConfigGroup(configGroupId) {
await this.client.post(`/delete_config_group/${configGroupId}`);
}
/**
* Deletes an existing configuration.
* Warning: This operation cannot be undone.
* Note: It does not affect closed test plans/runs, or active test plans/runs unless they are updated.
*
* API Path: POST index.php?/api/v2/delete_config/:config_id
*
* @param configId The ID of the configuration
* @throws {Error} 400 - Invalid or unknown configuration
* @throws {Error} 403 - No permissions to delete configurations or no access to the project
*/
async deleteConfig(configId) {
await this.client.post(`/delete_config/${configId}`);
}
}
exports.ConfigurationService = ConfigurationService;