@codacy/codacy-mcp
Version:
Codacy MCP server
236 lines (235 loc) • 9.98 kB
JavaScript
import { OpenAPI } from '../core/OpenAPI.js';
import { request as __request } from '../core/request.js';
export class GatePoliciesService {
/**
* Set the gate policy as the default for an organization
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy * @returns void
* @throws ApiError
*/
static setDefaultGatePolicy(provider, remoteOrganizationName, gatePolicyId, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}/setDefault',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Set the built-in Codacy gate policy as the default for an organization
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider * @returns void
* @throws ApiError
*/
static setCodacyDefault(provider, remoteOrganizationName, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/setCodacyDefault',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Get a gate policy
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy * @returns GetGatePolicyResultResponse Successful operation
* @throws ApiError
*/
static getGatePolicy(provider, remoteOrganizationName, gatePolicyId, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Delete a gate policy
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy * @returns void
* @throws ApiError
*/
static deleteGatePolicy(provider, remoteOrganizationName, gatePolicyId, abortSignal) {
return __request(OpenAPI, {
method: 'DELETE',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Update a gate policy
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy* @param requestBody The new value for the name, is default option, or quality gates of the gate policy * @returns GetGatePolicyResultResponse Successful operation
* @throws ApiError
*/
static updateGatePolicy(provider, remoteOrganizationName, gatePolicyId, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'PATCH',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
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 gate policies for an organization
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @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 GatePoliciesListResponse Successful operation
* @throws ApiError
*/
static listGatePolicies(provider, remoteOrganizationName, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Create a gate policy
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Details of the gate policy to create * @returns GetGatePolicyResultResponse Successful operation
* @throws ApiError
*/
static createGatePolicy(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
409: `Conflict`,
500: `Internal Server Error`,
},
});
}
/**
* List all repositories following a gate policy
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy* @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 ListRepositoriesFollowingGatePolicyResultResponse Successful operation
* @throws ApiError
*/
static listRepositoriesFollowingGatePolicy(provider, remoteOrganizationName, gatePolicyId, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}/repositories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Apply a gate policy to a list of repositories
* Link or unlink a gate policy to a list of repositories.
*
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param gatePolicyId Identifier of the gate policy* @param requestBody * @returns void
* @throws ApiError
*/
static applyGatePolicyToRepositories(provider, remoteOrganizationName, gatePolicyId, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'PUT',
url: '/organizations/{provider}/{remoteOrganizationName}/gate-policies/{gatePolicyId}/repositories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'gatePolicyId': gatePolicyId,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
}