Skip to content

Commit c9881b9

Browse files
committed
codacy-api/ and routing fixes
1 parent 64c071e commit c9881b9

11 files changed

+46
-63
lines changed

docusaurus/docs/codacy-api/api-tokens.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ import ApiTokenWarning from './../_includes/ApiTokenWarning.mdx'
88
Codacy provides **account** and **repository**-level API tokens that allow you to:
99

1010
- [Upload coverage data](../coverage-reporter/index.md) to Codacy
11-
- Upload to Codacy the results of [running client-side analysis tools](../repositories-configure/local-analysis/client-side-tools.md)
12-
- [Authenticate when using the Codacy API](using-the-codacy-api.md#authenticating-requests)
11+
- Upload to Codacy the results of [running client-side analysis tools](../repositories-configure/local-analysis/client-side-tools)
12+
- [Authenticate when using the Codacy API](using-the-codacy-api#authenticating-requests)
1313

1414
The sections below provide details about the two types of API tokens and instructions on how to generate and revoke them.
1515

1616
<ApiTokenWarning />
1717

18-
## Generating and revoking account API tokens ||account-api-tokens||
18+
## Generating and revoking account API tokens \{#account-api-tokens\}
1919

20-
Account API tokens are defined at the **Codacy user account level**. Each account API token authorizes access to the same organizations, repositories, and operations as the [roles and permissions of the owner of the account](../organizations/roles-and-permissions-for-organizations.md).
20+
Account API tokens are defined at the **Codacy user account level**. Each account API token authorizes access to the same organizations, repositories, and operations as the [roles and permissions of the owner of the account](../organizations/roles-and-permissions-for-organizations).
2121

2222
:::caution
23-
**If you're using an account API token to upload coverage** be sure to [check the roles](../organizations/roles-and-permissions-for-organizations.md) that your Git provider account must have to authorize uploading coverage to Codacy.
23+
**If you're using an account API token to upload coverage** be sure to [check the roles](../organizations/roles-and-permissions-for-organizations) that your Git provider account must have to authorize uploading coverage to Codacy.
2424

2525
Use a dedicated service account to integrate Codacy with your repositories. This prevents disruption of service if the user who created an account API token loses access to the repositories, which may happen when a user leaves the team or the organization.
2626
:::
2727

28-
You can create new account API tokens programmatically [using the Codacy API](examples/creating-repository-api-tokens-programmatically.md) or using the Codacy UI:
28+
You can create new account API tokens programmatically [using the Codacy API](examples/creating-repository-api-tokens-programmatically) or using the Codacy UI:
2929

3030
1. Open your account, tab **Access management**.
3131

@@ -47,11 +47,11 @@ When you have tokens created, you can view them inside the tokens table. By hove
4747

4848
To delete an account API token, click the trash icon in the Actions column of the table. After this, all applications or services using that token to access the Codacy API will fail to authenticate and will receive the reply `{"error":"not found"}`.
4949

50-
## Generating and revoking repository API tokens ||repository-api-tokens"||
50+
## Generating and revoking repository API tokens \{#repository-api-tokens\}
5151

5252
Repository API tokens are defined on **individual repositories**. Each repository API token only authorizes access to the corresponding repository.
5353

54-
You can create new repository API tokens programmatically [using the Codacy API](examples/creating-repository-api-tokens-programmatically.md) or using the Codacy UI:
54+
You can create new repository API tokens programmatically [using the Codacy API](examples/creating-repository-api-tokens-programmatically) or using the Codacy UI:
5555

5656
1. Open your repository **Settings**, tab **Integrations**.
5757

@@ -67,5 +67,5 @@ To revoke a repository API token, click the **X** next to the token. After this,
6767
## See also
6868

6969
- [Adding coverage to your repository](../coverage-reporter/index.md)
70-
- [Client-side tools](../repositories-configure/local-analysis/client-side-tools.md)
71-
- [Creating repository API tokens programmatically](examples/creating-repository-api-tokens-programmatically.md)
70+
- [Client-side tools](../repositories-configure/local-analysis/client-side-tools)
71+
- [Creating repository API tokens programmatically](examples/creating-repository-api-tokens-programmatically)

docusaurus/docs/codacy-api/examples/adding-people-to-codacy-programmatically.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ curl -X POST https://app.codacy.com/api/v3/organizations/<GIT_PROVIDER>/<ORGANIZ
1616

1717
Substitute the placeholders with your own values:
1818

19-
- **API_KEY:** [Account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
19+
- **API_KEY:** [Account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
2020
- **GIT_PROVIDER:** Git provider hosting of the organization, using one of the values in the table below. For example, `gh` for GitHub Cloud.
2121

2222
| Value | Git provider |
@@ -39,7 +39,7 @@ We provide an example Bash script that adds all emails in a text file to Codacy.
3939

4040
The example script:
4141

42-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
42+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
4343
1. Defines the path and filename of the file containing the email addresses list.
4444
1. Uses `awk` and `sed` to read the email addresses list from a file.
4545
1. Calls the endpoint [addPeopleToOrganization](https://app.codacy.com/api/api-docs#addpeopletoorganization) to add a list of email addresses to Codacy.
@@ -70,4 +70,4 @@ [email protected]
7070

7171
## See also
7272

73-
- [Adding people to your organization](/organizations/managing-people/#adding-people)
73+
- [Adding people to your organization](../../organizations/managing-people#adding-people)

docusaurus/docs/codacy-api/examples/adding-repositories-to-codacy-programmatically.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ curl -X POST https://app.codacy.com/api/v3/repositories \
2121

2222
Substitute the placeholders with your own values:
2323

24-
- **API_KEY:** [Account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
24+
- **API_KEY:** [Account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
2525
- **GIT_PROVIDER:** Git provider hosting of the repository, using one of the values in the table below. For example, `gh` for GitHub Cloud.
2626

2727
| Value | Git provider |
@@ -44,26 +44,27 @@ Substitute the placeholders with your own values:
4444
We provide an example Bash script that adds all repositories in a GitHub Cloud organization to Codacy. We suggest that you adapt the script to your specific scenario.
4545

4646
:::caution
47-
Since Codacy automatically analyzes new repositories, adding many repositories in a short time can cause delays in the analysis of other repositories depending on the size of the repositories, the sizing of the infrastructure, and the concurrent analysis configuration. For example:
47+
Since Codacy automatically analyzes new repositories, adding many repositories in a short time can cause delays in the analysis of other repositories depending on the size of the repositories, the sizing of the infrastructure, and the concurrent analysis configuration. For example:
4848

49-
| Repositories added | Expected delay |
50-
| ------------------ | -------------- |
51-
| 1 to 10 | Small |
52-
| 11 to 100 | Considerable |
53-
| More than 100 | Extreme |
49+
| Repositories added | Expected delay |
50+
| ------------------ | -------------- |
51+
| 1 to 10 | Small |
52+
| 11 to 100 | Considerable |
53+
| More than 100 | Extreme |
5454

55-
To avoid these delays, add repositories in small batches or space out adding new repositories over time.
55+
To avoid these delays, add repositories in small batches or space out adding new repositories over time.
5656
:::
5757

5858
The example script:
5959

60-
1. Defines a GitHub [personal access token](https://github.com/settings/tokens), the GitHub organization name, and the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
60+
1. Defines a GitHub [personal access token](https://github.com/settings/tokens), the GitHub organization name, and the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
6161
1. Calls the GitHub API to [obtain the list of all repositories](https://docs.github.com/en/rest/repos/repos#list-organization-repositories) in the defined organization.
6262
1. Uses [jq](https://github.com/stedolan/jq) to return the value of `full_name` for each repository obtained in the JSON response. The `full_name` already includes the organization and repository names using the format `<organization>/<repository>`.
6363
1. For each repository, calls the endpoint [<span class="skip-vale">addRepository</span>](https://app.codacy.com/api/api-docs#addrepository) to add a new repository specifying `gh` as the Git provider and the value of `full_name` as the full path of the repository.
6464
1. Checks the HTTP status code obtained in the response and performs basic error handling.
6565
1. Pauses a few seconds between requests to the Codacy API to avoid rate limiting.
6666

67+
6768
```bash
6869
#!/bin/bash
6970

docusaurus/docs/codacy-api/examples/creating-repository-api-tokens-programmatically.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Example of how to create new repository API tokens for all reposito
55
import ApiExamplePaginationImportant from '../../_includes/ApiExamplePaginationImportant.mdx'
66

77

8-
To create new [repository API tokens](../api-tokens.md) for your Codacy repositories programmatically, use the Codacy API endpoint [createRepositoryApiToken](https://app.codacy.com/api/api-docs#createrepositoryapitoken). You can also list all repository API tokens for a repository using the endpoint [listRepositoryApiTokens](https://api.codacy.com/api/api-docs#listrepositoryapitokens).
8+
To create new [repository API tokens](../api-tokens) for your Codacy repositories programmatically, use the Codacy API endpoint [createRepositoryApiToken](https://app.codacy.com/api/api-docs#createrepositoryapitoken). You can also list all repository API tokens for a repository using the endpoint [listRepositoryApiTokens](https://api.codacy.com/api/api-docs#listrepositoryapitokens).
99

1010
For example, if you're [setting up coverage](../../coverage-reporter/index.md) for all your repositories and prefer not to use a single account API token that grants the same permissions as an administrator, you need to create an individual repository API token for each repository.
1111

@@ -15,7 +15,7 @@ This example creates a new repository API token for a repository and outputs the
1515

1616
The example script:
1717

18-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
18+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
1919
1. Calls the endpoint [createRepositoryApiToken](https://app.codacy.com/api/api-docs#createrepositoryapitoken) to create a new repository API token and uses [jq](https://github.com/stedolan/jq) to obtain only the created token string.
2020

2121
```bash
@@ -95,7 +95,7 @@ This example lists all repository API tokens created for a repository.
9595

9696
The example script:
9797

98-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
98+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
9999
1. Calls the endpoint [listRepositoryApiTokens](https://api.codacy.com/api/api-docs#listrepositoryapitokens) to list the repository API tokens available on the repository and uses [jq](https://github.com/stedolan/jq) to obtain only the token strings, or exit with a non-zero status if the repository doesn't have any repository API tokens created yet.
100100

101101
```bash

docusaurus/docs/codacy-api/examples/identifying-commits-without-coverage-data.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This example checks whether the open pull requests in a repository have received
2424

2525
The example script:
2626

27-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
27+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API, the Git provider, the organization name, and the repository name passed as an argument to the script.
2828
1. Calls the Codacy API endpoint [listRepositoryPullRequests](https://api.codacy.com/api/api-docs#listrepositorypullrequests) to retrieve the list of open pull requests on the repository.
2929
1. Uses [jq](https://github.com/stedolan/jq) to select only the numbers that identify the pull requests on the Git provider.
3030
1. For each pull request, outputs the pull request number and calls the Codacy API endpoint [getPullRequestCoverageReports](https://api.codacy.com/api/api-docs#getpullrequestcoveragereports) to obtain the information about the coverage data received for the head and common ancestor commits of the pull request.

docusaurus/docs/codacy-api/examples/obtaining-code-quality-metrics-for-files.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This example exports the grade, total issues, complexity, coverage, and duplicat
1616

1717
The example script:
1818

19-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
19+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
2020
1. Calls the endpoint [<span class="skip-vale">listFiles</span>](https://app.codacy.com/api/api-docs#listfiles) to retrieve the code quality metrics, filtering the results by files that include `src/router/` in the path.
2121
1. Uses [jq](https://github.com/stedolan/jq) to select only the necessary data fields and convert the results to the CSV format.
2222

@@ -45,5 +45,5 @@ Example output:
4545

4646
## See also
4747

48-
- [Which metrics does Codacy calculate?](../../faq/code-analysis/which-metrics-does-codacy-calculate.md)
49-
- [Files page](../../repositories/files.md)
48+
- [Which metrics does Codacy calculate?](../../faq/code-analysis/which-metrics-does-codacy-calculate)
49+
- [Files page](../../repositories/files)

docusaurus/docs/codacy-api/examples/obtaining-current-issues-in-repositories.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This example exports the pattern ID, issue level, file path, and timestamp for a
1515

1616
The example script:
1717

18-
1. Defines the [account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
18+
1. Defines the [account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
1919
1. Calls the endpoint [searchRepositoryIssues](https://app.codacy.com/api/api-docs#searchrepositoryissues) to retrieve information about the issues, filtering the results by security issues with the relevant severity levels.
2020
1. Uses [jq](https://github.com/stedolan/jq) to select only the necessary data fields and convert the results to the CSV format.
2121

@@ -45,5 +45,5 @@ Example output:
4545

4646
## See also
4747

48-
- [Which metrics does Codacy calculate?](../../faq/code-analysis/which-metrics-does-codacy-calculate.md)
49-
- [Issues page](../../repositories/issues.md)
48+
- [Which metrics does Codacy calculate?](../../faq/code-analysis/which-metrics-does-codacy-calculate)
49+
- [Issues page](../../repositories/issues)

docusaurus/docs/codacy-api/examples/triggering-dast-scans.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Thanks to the new app scanning capabilities available on the Security and risk m
88
:::caution
99
**App scanning is a business feature.** If you are a Codacy Pro customer, contact our customer success team to access a short trial.
1010

11-
**Check your [permissions](../../organizations/roles-and-permissions-for-organizations.md).** Only git provider admins and organization managers will be able to create new targets and trigger scans (in app and via the API).
11+
**Check your [permissions](../../organizations/roles-and-permissions-for-organizations).** Only git provider admins and organization managers will be able to create new targets and trigger scans (in app and via the API).
1212
:::
1313

1414

@@ -52,12 +52,12 @@ Replace the placeholders with your own values:
5252

5353
| Field | Required | Description |
5454
|-------|----------|-------------|
55-
| **API_KEY** | true | [Account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API |
55+
| **API_KEY** | true | [Account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API |
5656
| **GIT_PROVIDER** | true | Git provider hosting of the organization, using one of the values in the table below. <br/>**Options:** `gh` (GitHub Cloud), `ghe`(GitHub Enterprise), `gl` (Gitlab Cloud), `gle` (Gitlab Enterprise), `bb` (Bitbucket Cloud), `bbe` (Bitbucket Server) |
5757
| **ORGANIZATION** | true | Name of the organization on the Git provider. You must have admin permissions over the organization on the Git provider.<br/>For example, `codacy` |
5858
| **TARGET_URL** | true | URL of the Web app or API that will be scanned. <br/>Must start with `http://` or `https://`<br/>For example, `https://api.codacy.com/v1`|
5959
| **TARGET_TYPE** | false | Type of target to be scanned <br/> **Options:** `webapp` (default), `openapi` or `graphql`|
60-
| **API_DEFINITION_URL** | false * | The URL to a publicly accessible OpenAPI specification.<br/>*** Required for OpenAPI targets**|
60+
| **API_DEFINITION_URL** | false * | The URL to a publicly accessible OpenAPI specification.<br/>* **Required for OpenAPI targets**|
6161
| **HEADER_NAME** | false | Name of the authentication header. <br/>For example, `Authentication`|
6262
| **HEADER_VALUE** | false | Value of the authentication header. <br/>For example, a token or API key|
6363

@@ -79,12 +79,12 @@ curl -X POST https://app.codacy.com/api/v3/organizations/{GIT_PROVIDER}/{ORGANIZ
7979

8080
Replace the placeholders with your own values:
8181

82-
- **API_KEY:** [Account API token](../api-tokens.md#account-api-tokens) used to authenticate on the Codacy API.
82+
- **API_KEY:** [Account API token](../api-tokens#account-api-tokens) used to authenticate on the Codacy API.
8383
- **GIT_PROVIDER:** Git provider hosting of the organization (check the table on the example above). For example, `gh` for GitHub Cloud.
8484
- **ORGANIZATION:** Name of the organization on the Git provider. For example, `codacy`. You must have admin permissions over the organization on the Git provider.
85-
- **DAST_TARGET_ID:** Identifier of a DAST target to analyze (obtained in the [previous section](./triggering-dast-scans.md#creating-targets). For example, `457`. You must have admin permissions over the organization on the Git provider.
85+
- **DAST_TARGET_ID:** Identifier of a DAST target to analyze (obtained in the [previous section](./triggering-dast-scans#creating-targets). For example, `457`. You must have admin permissions over the organization on the Git provider.
8686

87-
Scans occur asynchronously. To monitor an ongoing scan you can use the [target management page in Codacy](../../organizations/managing-security-and-risk.md#app-scanning). Once completed, you can access all scan results by navigating to the **Security dashboard**, selecting the **Findings tab** and filtering by **Scan types > DAST/App scanning**, or by clicking on a configured target to expand all of that target's results.
87+
Scans occur asynchronously. To monitor an ongoing scan you can use the [target management page in Codacy](../../organizations/managing-security-and-risk#app-scanning). Once completed, you can access all scan results by navigating to the **Security dashboard**, selecting the **Findings tab** and filtering by **Scan types > DAST/App scanning**, or by clicking on a configured target to expand all of that target's results.
8888
Additionaly, you can use the `SearchSRMItems` endpoint to filter findings by their DAST target URL with the following request:
8989
```bash
9090
curl -X POST https://app.codacy.com/api/v3/organizations/gh/codacy/security/items/search \

0 commit comments

Comments
 (0)