@codacy/codacy-mcp
Version:
Codacy MCP server
431 lines (430 loc) • 22.2 kB
JavaScript
import { OpenAPI } from '../core/OpenAPI.js';
import { request as __request } from '../core/request.js';
export class CodingStandardsService {
/**
* List the coding standards for an organization, including draft coding standards
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider * @returns CodingStandardsListResponse List of coding standards for an organization
* @throws ApiError
*/
static listCodingStandards(provider, remoteOrganizationName, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Create a draft coding standard for an organization. To promote the draft coding standard to effective coding standard, see [promoteDraftCodingStandard](#promotedraftcodingstandard)
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Details of the coding standard to create* @param sourceRepository Name of a repository in the same organization to use as a template when creating the new coding standard* @param sourceCodingStandard Identifier of an existing coding standard to use as a template when creating a new coding standard, including the enabled repositories and default coding standard status * @returns CodingStandardResponse Successfully created a coding standard
* @throws ApiError
*/
static createCodingStandard(provider, remoteOrganizationName, requestBody, sourceRepository, sourceCodingStandard, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'sourceRepository': sourceRepository,
'sourceCodingStandard': sourceCodingStandard,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
422: `Unprocessable Entity`,
500: `An unexpected error occurred while creating the coding standard`,
},
});
}
/**
* Create a coding standard for an organization choosing from a series of presets.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Details of the coding standard to create * @returns CodingStandardResponse Successfully created a coding standard
* @throws ApiError
*/
static createCodingStandardPreset(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/presets-standards',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
422: `Unprocessable Entity`,
500: `An unexpected error occurred while creating the coding standard`,
},
});
}
/**
* Get a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier * @returns CodingStandardResponse Successful operation
* @throws ApiError
*/
static getCodingStandard(provider, remoteOrganizationName, codingStandardId, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Delete a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier * @returns void
* @throws ApiError
*/
static deleteCodingStandard(provider, remoteOrganizationName, codingStandardId, abortSignal) {
return __request(OpenAPI, {
method: 'DELETE',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `An unexpected error occurred while deleting a coding standard`,
},
});
}
/**
* Duplicates a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier * @returns CodingStandardResponse Successful operation
* @throws ApiError
*/
static duplicateCodingStandard(provider, remoteOrganizationName, codingStandardId, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/duplicate',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
500: `Internal Server Error`,
},
});
}
/**
* List tools in a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier * @returns CodingStandardToolsListResponse Successful operation
* @throws ApiError
*/
static listCodingStandardTools(provider, remoteOrganizationName, codingStandardId, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/tools',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `An unexpected error occurred while listing the tools of the coding standard`,
},
});
}
/**
* Set the default coding standard for an organization
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param requestBody * @returns any Successful operation
* @throws ApiError
*/
static setDefaultCodingStandard(provider, remoteOrganizationName, codingStandardId, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/setDefault',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* List the code patterns configured for a tool in a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param toolUuid Tool unique identifier* @param languages Languages filter* @param categories Filter by a comma separated list of code pattern categories. The allowed values are 'Security', 'ErrorProne', 'CodeStyle', 'Compatibility', 'UnusedCode', and 'Performance'* @param severityLevels Filter by a comma separated list of code pattern severity levels. The allowed values are 'Error', 'Warning', and 'Info'* @param search Filter the results searching by this string.* @param enabled Returns only the enabled or disabled patterns.* @param recommended Returns only the recommended or non-recommended patterns.* @param sort Field used to sort the tool's code patterns. The allowed values are 'category', 'recommended', and 'severity'* @param direction Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending).* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ConfiguredPatternsListResponse Successful operation
* @throws ApiError
*/
static listCodingStandardPatterns(provider, remoteOrganizationName, codingStandardId, toolUuid, languages, categories, severityLevels, search, enabled, recommended, sort, direction, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/tools/{toolUuid}/patterns',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
'toolUuid': toolUuid,
},
query: {
'languages': languages,
'categories': categories,
'severityLevels': severityLevels,
'search': search,
'enabled': enabled,
'recommended': recommended,
'sort': sort,
'direction': direction,
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Patterns overview for a coding standard tool.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param toolUuid Tool unique identifier* @param languages Languages filter* @param categories Filter by a comma separated list of code pattern categories. The allowed values are 'Security', 'ErrorProne', 'CodeStyle', 'Compatibility', 'UnusedCode', and 'Performance'* @param severityLevels Filter by a comma separated list of code pattern severity levels. The allowed values are 'Error', 'Warning', and 'Info'* @param search Filter the results searching by this string.* @param enabled Returns only the enabled or disabled patterns.* @param recommended Returns only the recommended or non-recommended patterns. * @returns ToolPatternsOverviewResponse Successful operation
* @throws ApiError
*/
static codingStandardToolPatternsOverview(provider, remoteOrganizationName, codingStandardId, toolUuid, languages, categories, severityLevels, search, enabled, recommended, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/tools/{toolUuid}/patterns/overview',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
'toolUuid': toolUuid,
},
query: {
'languages': languages,
'categories': categories,
'severityLevels': severityLevels,
'search': search,
'enabled': enabled,
'recommended': recommended,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Bulk updates the code patterns of a tool in a coding standard.
* Use filters to specify the code patterns to update, or omit the filters to update all code patterns.
*
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param toolUuid Tool unique identifier* @param requestBody * @param languages Languages filter* @param categories Filter by a comma separated list of code pattern categories. The allowed values are 'Security', 'ErrorProne', 'CodeStyle', 'Compatibility', 'UnusedCode', and 'Performance'* @param severityLevels Filter by a comma separated list of code pattern severity levels. The allowed values are 'Error', 'Warning', and 'Info'* @param search Filter the results searching by this string.* @param recommended Returns only the recommended or non-recommended patterns. * @returns void
* @throws ApiError
*/
static updateCodingStandardPatterns(provider, remoteOrganizationName, codingStandardId, toolUuid, requestBody, languages, categories, severityLevels, search, recommended, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/tools/{toolUuid}/patterns/update',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
'toolUuid': toolUuid,
},
query: {
'languages': languages,
'categories': categories,
'severityLevels': severityLevels,
'search': search,
'recommended': recommended,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
500: `Internal Server Error`,
},
});
}
/**
* Configure a tool in a draft coding standard.
* Toggle a tool and configure its code patterns in a draft coding standard.
* Only the code patterns included in the body are updated, and if there are none only the enabled status of the tool is set.
* You can only update draft coding standards and configure a maximum of 1000 code patterns per call.
*
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param toolUuid Tool unique identifier* @param requestBody Configuration of a tool and its code patterns * @returns void
* @throws ApiError
*/
static updateCodingStandardToolConfiguration(provider, remoteOrganizationName, codingStandardId, toolUuid, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'PATCH',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/tools/{toolUuid}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
'toolUuid': toolUuid,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
500: `Internal Server Error`,
},
});
}
/**
* List the repositories that are using a coding standard
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns CodingStandardRepositoriesListResponse Successful operation
* @throws ApiError
*/
static listCodingStandardRepositories(provider, remoteOrganizationName, codingStandardId, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/repositories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Apply a coding standard to a list of repositories
* Link or unlink a coding standard to a list of repositories.
* If the coding standard is a draft, the changes will only be effective when promoting the draft coding standard.
*
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier* @param requestBody * @returns ApplyCodingStandardToRepositoriesResultResponse Successful operation
* @throws ApiError
*/
static applyCodingStandardToRepositories(provider, remoteOrganizationName, codingStandardId, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'PATCH',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/repositories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Promote a draft coding standard to an effective coding standard. If the draft coding standard is marked as default, it becomes the new default coding standard
* Returns the result of applying the coding standard to the repositories.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param codingStandardId Coding standard identifier * @returns ApplyCodingStandardToRepositoriesResultResponse Successful operation
* @throws ApiError
*/
static promoteDraftCodingStandard(provider, remoteOrganizationName, codingStandardId, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/coding-standards/{codingStandardId}/promote',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'codingStandardId': codingStandardId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
500: `Internal Server Error`,
},
});
}
}