Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1ddb075b
Commit
1ddb075b
authored
Jan 11, 2020
by
raju249
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new endpoint, use generic name , remove sentry word in docs
parent
4be09441
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
46 deletions
+66
-46
doc/api/api_resources.md
doc/api/api_resources.md
+1
-1
doc/api/error_tracking.md
doc/api/error_tracking.md
+9
-6
lib/api/entities.rb
lib/api/entities.rb
+0
-5
lib/api/entities/error_tracking.rb
lib/api/entities/error_tracking.rb
+13
-0
lib/api/error_tracking.rb
lib/api/error_tracking.rb
+5
-5
spec/requests/api/error_tracking_spec.rb
spec/requests/api/error_tracking_spec.rb
+38
-29
No files found.
doc/api/api_resources.md
View file @
1ddb075b
...
@@ -29,7 +29,7 @@ The following API resources are available in the project context:
...
@@ -29,7 +29,7 @@ The following API resources are available in the project context:
|
[
Deployments
](
deployments.md
)
|
`/projects/:id/deployments`
|
|
[
Deployments
](
deployments.md
)
|
`/projects/:id/deployments`
|
|
[
Discussions
](
discussions.md
)
(
threaded
comments) |
`/projects/:id/issues/.../discussions`
,
`/projects/:id/snippets/.../discussions`
,
`/projects/:id/merge_requests/.../discussions`
,
`/projects/:id/commits/.../discussions`
(also available for groups) |
|
[
Discussions
](
discussions.md
)
(
threaded
comments) |
`/projects/:id/issues/.../discussions`
,
`/projects/:id/snippets/.../discussions`
,
`/projects/:id/merge_requests/.../discussions`
,
`/projects/:id/commits/.../discussions`
(also available for groups) |
|
[
Environments
](
environments.md
)
|
`/projects/:id/environments`
|
|
[
Environments
](
environments.md
)
|
`/projects/:id/environments`
|
|
[
Error Tracking
](
sentry_project_settings.md
)
|
`/projects/:id/error_tracking/sentry_project_
settings`
|
|
[
Error Tracking
](
error_tracking.md
)
|
`/projects/:id/error_tracking/
settings`
|
|
[
Events
](
events.md
)
|
`/projects/:id/events`
(also available for users and standalone) |
|
[
Events
](
events.md
)
|
`/projects/:id/events`
(also available for users and standalone) |
|
[
Issues
](
issues.md
)
|
`/projects/:id/issues`
(also available for groups and standalone) |
|
[
Issues
](
issues.md
)
|
`/projects/:id/issues`
(also available for groups and standalone) |
|
[
Issues Statistics
](
issues_statistics.md
)
|
`/projects/:id/issues_statistics`
(also available for groups and standalone) |
|
[
Issues Statistics
](
issues_statistics.md
)
|
`/projects/:id/issues_statistics`
(also available for groups and standalone) |
...
...
doc/api/
sentry_project_settings
.md
→
doc/api/
error_tracking
.md
View file @
1ddb075b
#
Sentry Project
Settings API
#
Error Tracking
Settings API
## Sentry Error Tracking Project Settings
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/34940) in GitLab 12.7.
## Error Tracking Project Settings
The Sentry Project Settings API allows you to retrieve Sentry Error Tracking Settings for a Project. Only for project maintainers.
The Sentry Project Settings API allows you to retrieve Sentry Error Tracking Settings for a Project. Only for project maintainers.
### Retrieve
Sentry
Error Tracking Settings
### Retrieve Error Tracking Settings
```
```
GET /projects/:id/error_tracking/se
ntry_project_se
ttings
GET /projects/:id/error_tracking/settings
```
```
| Attribute | Type | Required | Description |
| Attribute | Type | Required | Description |
...
@@ -15,7 +17,7 @@ GET /projects/:id/error_tracking/sentry_project_settings
...
@@ -15,7 +17,7 @@ GET /projects/:id/error_tracking/sentry_project_settings
|
`id`
| integer | yes | The ID of the project owned by the authenticated user |
|
`id`
| integer | yes | The ID of the project owned by the authenticated user |
```
bash
```
bash
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
https://gitlab.example.com/api/v4/projects/1/error_tracking/se
ntry_project_se
ttings
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
https://gitlab.example.com/api/v4/projects/1/error_tracking/settings
```
```
Example response:
Example response:
...
@@ -23,6 +25,7 @@ Example response:
...
@@ -23,6 +25,7 @@ Example response:
```
json
```
json
{
{
"project_name"
:
"sample sentry project"
,
"project_name"
:
"sample sentry project"
,
"sentry_external_url"
:
"https://sentry.io/myawesomeproject/project"
"sentry_external_url"
:
"https://sentry.io/myawesomeproject/project"
,
"api_url"
:
"https://sentry.io/api/0/projects/myawesomeproject/project"
}
}
```
```
lib/api/entities.rb
View file @
1ddb075b
...
@@ -166,11 +166,6 @@ module API
...
@@ -166,11 +166,6 @@ module API
end
end
end
end
class
SentryProjectErrorTrackingSettings
<
Grape
::
Entity
expose
:project_name
expose
:sentry_external_url
end
class
RemoteMirror
<
Grape
::
Entity
class
RemoteMirror
<
Grape
::
Entity
expose
:id
expose
:id
expose
:enabled
expose
:enabled
...
...
lib/api/entities/error_tracking.rb
0 → 100644
View file @
1ddb075b
# frozen_string_literal: true
module
API
module
Entities
module
ErrorTracking
class
ProjectSetting
<
Grape
::
Entity
expose
:project_name
expose
:sentry_external_url
expose
:api_url
end
end
end
end
\ No newline at end of file
lib/api/error_tracking.rb
View file @
1ddb075b
...
@@ -9,18 +9,18 @@ module API
...
@@ -9,18 +9,18 @@ module API
end
end
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get
sentry
error tracking settings for the project'
do
desc
'Get error tracking settings for the project'
do
success
Entities
::
SentryProjectErrorTrackingSettings
success
Entities
::
ErrorTracking
::
ProjectSetting
end
end
get
':id/error_tracking/se
ntry_project_se
ttings'
do
get
':id/error_tracking/settings'
do
authorize!
:
read_sentry_issue
,
user_project
authorize!
:
admin_operations
,
user_project
setting
=
user_project
.
error_tracking_setting
setting
=
user_project
.
error_tracking_setting
not_found!
(
'Error Tracking Setting'
)
unless
setting
not_found!
(
'Error Tracking Setting'
)
unless
setting
present
setting
,
with:
Entities
::
SentryProjectErrorTrackingSettings
present
setting
,
with:
Entities
::
ErrorTracking
::
ProjectSetting
end
end
end
end
end
end
...
...
spec/requests/api/error_tracking_spec.rb
View file @
1ddb075b
...
@@ -3,50 +3,59 @@
...
@@ -3,50 +3,59 @@
require
'spec_helper'
require
'spec_helper'
describe
API
::
ErrorTracking
do
describe
API
::
ErrorTracking
do
describe
"GET
sentry project
settings"
do
describe
"GET
/projects/:id/error_tracking/
settings"
do
let
(
:u
nauthorized_message
)
{
"401 Unauthorized"
}
let
(
:u
ser
)
{
create
(
:user
)
}
let
(
:setting
s_not_found_message
)
{
"404 Error Tracking Setting Not Found"
}
let
(
:setting
)
{
create
(
:project_error_tracking_setting
)
}
let
(
:
random_user
)
{
create
(
:user
)
}
let
(
:
project
)
{
setting
.
project
}
let
(
:project_error_tracking_setting
)
{
create
(
:project_error_tracking_setting
)
}
let
(
:project
)
do
def
make_request
create
(
:project
,
:repository
)
get
api
(
"/projects/
#{
project
.
id
}
/error_tracking/settings"
,
user
)
end
end
let
(
:project_with_settings
)
do
context
'when authenticated as maintainer'
do
create
(
:project
,
:repository
,
error_tracking_setting:
project_error_tracking_setting
)
before
do
project
.
add_maintainer
(
user
)
end
end
context
'when project has no settings'
do
it
'returns project settings'
do
it
'returns 404'
do
make_request
get
api
(
"/projects/
#{
project
.
id
}
/error_tracking/sentry_project_settings"
,
project
.
creator
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"message"
]).
to
eq
(
settings_not_found_message
)
expect
(
json_response
).
to
eq
(
'project_name'
=>
setting
.
project_name
,
'sentry_external_url'
=>
setting
.
sentry_external_url
,
'api_url'
=>
setting
.
api_url
)
end
end
end
end
context
'when user has permission to view settings'
do
context
'when authenticated as reporter'
do
it
'returns 200'
do
before
do
get
api
(
"/projects/
#{
project_with_settings
.
id
}
/error_tracking/sentry_project_settings"
,
project_with_settings
.
creator
)
project
.
add_reporter
(
user
)
end
it
'returns 403'
do
make_request
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
json_response
[
"project_name"
]).
to
eq
(
project_error_tracking_setting
.
project_name
)
expect
(
json_response
[
"sentry_external_url"
]).
to
eq
(
project_error_tracking_setting
.
sentry_external_url
)
end
end
end
end
context
'
When user does not own the project
'
do
context
'
when authenticated as non-member
'
do
it
'returns 404'
do
it
'returns 404'
do
get
api
(
"/projects/
#{
project
.
id
}
/error_tracking/sentry_project_settings"
,
random_user
)
make_request
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
context
'When unauthenticated'
do
context
'when unauthenticated'
do
it
'return 401'
do
let
(
:user
)
{
nil
}
get
api
(
"/projects/
#{
project
.
id
}
/error_tracking/sentry_project_settings"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
it
'returns 401'
do
expect
(
json_response
[
"message"
]).
to
eq
(
unauthorized_message
)
make_request
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment