8000 Merge pull request #7504 from circleci/DOCTEAM-756_standalone_slug · marcoderama/circleci-docs@346cac9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 346cac9

Browse files
authored
Merge pull request circleci#7504 from circleci/DOCTEAM-756_standalone_slug
Gitlab resources for API
2 parents f3d50a0 + 810ca33 commit 346cac9

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

jekyll/_cci2/api-developers-guide.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,46 @@ v1) return EDN if no accept header is specified.
9090
## Getting started with the API
9191
{: #getting-started-with-the-api }
9292

93-
The CircleCI API shares similarities with previous API versions in that it identifies your projects using repository name. For instance, if you want to pull information from CircleCI about the GitHub repository "https://github.com/CircleCI-Public/circleci-cli" you can refer to that in the CircleCI API as `gh/CircleCI-Public/circleci-cli`, which is a _triplet_ of the project type (VCS provider), the name of your engineering organization (or your VCS username), and the name of the repository.
93+
### GitHub and Bitbucket projects
94+
{: #github-and-bitbucket-projects }
9495

95-
For the project type you can use `github` or `bitbucket` as well as the shorter forms `gh` or `bb`. For any other VCS type you can use `circleci`. The `organization` is your username or organization name in your version control system.
96+
The CircleCI API shares similarities with previous API versions in that it identifies your projects using repository name. For instance, if you want to pull information from CircleCI about the GitHub repository "https://github.com/CircleCI-Public/circleci-cli" you can refer to that in the CircleCI API as `gh/CircleCI-Public/circleci-cli`, which is a _triplet_ of the VCS type (VCS provider), the name of your engineering organization (or your VCS username), and the name of the repository.
97+
98+
For the VCS type you can use `github` or `bitbucket` as well as the shorter forms `gh` or `bb`. The `organization` is your username or organization name in your version control system.
9699

97100
With this API, CircleCI introduces a string representation of the triplet called the `project_slug`, which takes the following form:
98101

99102
```
100-
{project_type}/{org_name}/{repo_name}
103+
{vcs_type}/{org_name}/{repo_name}
101104
```
102105

103106
The `project_slug` is included in the payload when pulling information about a project, and when looking up a pipeline or workflow by ID. The `project_slug` can then be used to get information about the project.
104107

105108
![API structure]({{ site.baseurl }}/assets/img/docs/api-structure.png)
106109

107-
It is possible in the future the shape of a `project_slug` may change, but in all cases it would be usable as a human-readable identifier for a given project.
110+
For GitHub and Bitbucket projects, `project_slug` is currently usable as a human-readable identifier for a given project. For [GitLab projects](#gitlab-saas-support-projects), the slug format has been changed.
111+
112+
### GitLab SaaS Support projects
113+
{: #gitlab-saas-support-projects }
114+
115+
For GitLab Saas Support, organization as well as project names do not serve as identifiers, and are not part of project slugs. GitLab projects currently use a new slug format:
116+
117+
`circleci/:slug-remainder`
118+
119+
The project slug for GitLab projects can be found by navigating to your project in the CircleCI web app and taking the "triplet" string from the browser address bar.
120+
121+
![GitLab project slug available in address in the web app]({{ site.baseurl }}/assets/img/docs/standalone-project-slug.png)
122+
123+
In API requests, the project slug must be passed as a whole. For example:
124+
125+
```shell
126+
curl --header "Circle-Token: $CIRCLE_TOKEN" \
127+
--header "Accept: application/json" \
128+
--header "Content-Type: application/json" \
129+
https://circleci.com/api/v2/project/circleci/:slug-remainder
130+
```
131+
132+
GitLab project slugs must be treated as opaque strings. The slug should not be parsed to retrieve the project or organization IDs. To retrieve project and organization IDs or names, use the entire slug to fetch [project details](#get-project-details) or organization details. The IDs and names are included in the payload.
108133

109134
## Rate limits
110135
{: #rate-limits }
@@ -297,7 +322,7 @@ Whenever you see curly brackets `{}`, this represents a variable that you must m
297322
298323
To return project details, perform the following steps:
299324
300-
1. For this GET API call, under the `parameters` key, define the `project_slug` (`\<project_type\>/\<org_name\>/\<repo_name\>`) parameter you want returned in the JSON payload in your `curl` request as follows:
325+
1. For this GET API call, under the `parameters` key, define the `project_slug` (`\<vcs_type\>/\<org_name\>/\<repo_name\>`) parameter you want returned in the JSON payload in your `curl` request as follows:
301326
302327
```shell
303328
curl -X GET https://circleci.com/api/v2/project/{project_slug} \

jekyll/_cci2/api-intro.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ Currently, [Personal API tokens]({{site.baseurl}}/managing-api-tokens/#creating-
3737
## Getting started with the API v2
3838
{: #getting-started-with-the-api-v2 }
3939

40-
The CircleCI API v2 is backwards-compatible with previous API versions in the way it identifies your projects using repository name. For instance, if you want to pull information from CircleCI about the GitHub repository https://github.com/CircleCI-Public/circleci-cli you can refer to that in the CircleCI API as `gh/CircleCI-Public/circleci-cli`, which is a "triplet" of the project type, the name of your "organization", and the name of the repository. For the project type you can use `github` or `bitbucket` as well as the shorter forms `gh` or `bb`, which are now supported in API v2. The `organization` is your username or organization name in your version control system.
40+
**GitLab SaaS Support users:** Note that the definition of **project slug** provided in this section, as well as its usage throughout this document applies to GitHub and Bitbucket projects only. GitLab projects currently use a new slug format:
41+
<br>
42+
`circleci/:slug-remainder`
43+
<br>
44+
The project slug for GitLab projects can be found by navigating to your project in the CircleCI web app and taking the string from the browser address bar. The slug must be treated as an opaque string and passed in its entirety in API requests. Read the [API Developer's Guide]({{site.baseurl}}/api-developers-guide) for more details.
45+
{: class="alert alert-info"}
46+
47+
The CircleCI API v2 is backwards-compatible with previous API versions in the way it identifies your projects using repository name. For instance, if you want to pull information from CircleCI about the GitHub repository https://github.com/CircleCI-Public/circleci-cli you can refer to that in the CircleCI API as `gh/CircleCI-Public/circleci-cli`, which is a "triplet" of the VCS type, the name of your "organization", and the name of the repository. For the VCS type you can use `github` or `bitbucket` as well as the shorter forms `gh` or `bb`, which are now supported in API v2. The `organization` is your username or organization name in your version control system.
4148

4249
With API v2, CircleCI is introducing a string representation of the triplet called the `project_slug`, which takes the following form:
4350

44-
`<project_type>/<org_name>/<repo_name>`
51+
`<vcs_type>/<org_name>/<repo_name>`
4552

46-
The `project_slug` is included in the payload when pulling information about a project as well as when looking up a pipeline or workflow by ID. The `project_slug` can then be used to get information about the project. It is possible in the future the shape of a `project_slug` may change, but in all cases it would be usable as a human-readable identifier for a given project.
53+
The `project_slug` is included in the payload when pulling information about a project as well as when looking up a pipeline or workflow by ID. The `project_slug` can then be used to get information about the project. It is possible in the future the shape of a `project_slug` may change, but for GitHub and Bitbucket projects it is currently usable as a human-readable identifier for a given project.
4754

4855
## Authentication
4956
{: #authentication }
@@ -97,7 +104,7 @@ Endpoint | Description
97104
### Deprecated endpoints
98105
{: #deprecated-endpoints }
99106

100-
For this updated API v2 release, several endpoints have been deprecated, which are listed in the table below.
107+
With API v2, several endpoints from v1 have been deprecated, which are listed in the table below.
101108

102109
Endpoint | Description
103110
-----------|-----------------------------------------------------
@@ -110,15 +117,6 @@ Endpoint | Description
110117

111118
API v2 is not supported for installations of CircleCI server 2.x. API v2 is supported for self-hosted installations of CircleCI server 3.x.
112119

113-
## Data insights
114-
{: #data-insights }
115-
116-
The CircleCI API v2 enables you to call a specific set of endpoints to retrieve detailed [insights]({{site.baseurl}}/insights) and data about your jobs and workflows. This information can help you better understand how your jobs and workflows are performing while also providing you with data points that you can use to optimize your workflows and builds. Some examples of insights endpoints include:
117-
118-
- `GET /{vcs_slug}/{org_name}/projects/{project_name}`
119-
- `GET /{vcs_slug}/{org_name}/projects/{project_name}/workflows`
120-
- `GET /{vcs_slug}/{org_name}/projects/{project_name}/workflows/{workflow_name}/jobs`
121-
122120
## Next steps
123121

124122
- Review the [API Developer's Guide]({{site.baseurl}}/api-developers-guide) for a detailed walkthrough on authenticating as well as example API requests.
Loading

0 commit comments

Comments
 (0)
0