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
926a1aba
Commit
926a1aba
authored
Jun 09, 2020
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API to schedule project repository storage moves
A higher visibility endpoint than the update project endpoint.
parent
59e5a8ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
9 deletions
+114
-9
changelogs/unreleased/schedule_storage_move_api.yml
changelogs/unreleased/schedule_storage_move_api.yml
+5
-0
doc/api/project_repository_storage_moves.md
doc/api/project_repository_storage_moves.md
+49
-9
lib/api/project_repository_storage_moves.rb
lib/api/project_repository_storage_moves.rb
+19
-0
spec/requests/api/project_repository_storage_moves_spec.rb
spec/requests/api/project_repository_storage_moves_spec.rb
+41
-0
No files found.
changelogs/unreleased/schedule_storage_move_api.yml
0 → 100644
View file @
926a1aba
---
title
:
Add API to schedule project repository storage moves
merge_request
:
34119
author
:
type
:
added
doc/api/project_repository_storage_moves.md
View file @
926a1aba
...
...
@@ -16,7 +16,7 @@ are [paginated](README.md#pagination).
Example request:
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
primary
.example.com/api/v4/project_repository_storage_moves'
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
gitlab
.example.com/api/v4/project_repository_storage_moves'
```
Example response:
...
...
@@ -54,12 +54,12 @@ Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`project_id`
| integer | yes |
The
ID of the project |
|
`project_id`
| integer | yes | ID of the project |
Example request:
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
primary.example.com/api/v4/project
/1/repository_storage_moves'
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
gitlab.example.com/api/v4/projects
/1/repository_storage_moves'
```
Example response:
...
...
@@ -94,12 +94,12 @@ Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`repository_storage_id`
| integer | yes |
The
ID of the project repository storage move |
|
`repository_storage_id`
| integer | yes | ID of the project repository storage move |
Example request:
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
primary
.example.com/api/v4/project_repository_storage_moves/1'
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://
gitlab
.example.com/api/v4/project_repository_storage_moves/1'
```
Example response:
...
...
@@ -125,20 +125,60 @@ Example response:
## Get a single repository storage move for a project
```
plaintext
GET /project/:project_id/repository_storage_moves/:repository_storage_id
GET /project
s
/:project_id/repository_storage_moves/:repository_storage_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`project_id`
| integer | yes |
The
ID of the project |
|
`repository_storage_id`
| integer | yes |
The
ID of the project repository storage move |
|
`project_id`
| integer | yes | ID of the project |
|
`repository_storage_id`
| integer | yes | ID of the project repository storage move |
Example request:
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://primary.example.com/api/v4/project/1/repository_storage_moves/1'
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
'https://gitlab.example.com/api/v4/projects/1/repository_storage_moves/1'
```
Example response:
```
json
{
"id"
:
1
,
"created_at"
:
"2020-05-07T04:27:17.234Z"
,
"state"
:
"scheduled"
,
"source_storage_name"
:
"default"
,
"destination_storage_name"
:
"storage2"
,
"project"
:
{
"id"
:
1
,
"description"
:
null
,
"name"
:
"project1"
,
"name_with_namespace"
:
"John Doe2 / project1"
,
"path"
:
"project1"
,
"path_with_namespace"
:
"namespace1/project1"
,
"created_at"
:
"2020-05-07T04:27:17.016Z"
}
```
## Schedule a repository storage move for a project
```
plaintext
POST /projects/:project_id/repository_storage_moves
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`project_id`
| integer | yes | ID of the project |
|
`destination_storage_name`
| string | yes | Name of the destination storage shard |
Example request:
```
shell
curl
--request
POST
--header
"PRIVATE_TOKEN: <your_access_token>"
--header
"Content-Type: application/json"
\
--data
'{"destination_storage_name":"storage2"}'
'https://gitlab.example.com/api/v4/projects/1/repository_storage_moves'
```
Example response:
...
...
lib/api/project_repository_storage_moves.rb
View file @
926a1aba
...
...
@@ -63,6 +63,25 @@ module API
present
storage_move
,
with:
Entities
::
ProjectRepositoryStorageMove
,
current_user:
current_user
end
desc
'Schedule a project repository storage move'
do
detail
'This feature was introduced in GitLab 13.1.'
success
Entities
::
ProjectRepositoryStorageMove
end
params
do
requires
:destination_storage_name
,
type:
String
,
desc:
'The destination storage shard'
end
post
':id/repository_storage_moves'
do
storage_move
=
user_project
.
repository_storage_moves
.
build
(
declared_params
.
merge
(
source_storage_name:
user_project
.
repository_storage
)
)
if
storage_move
.
schedule
present
storage_move
,
with:
Entities
::
ProjectRepositoryStorageMove
,
current_user:
current_user
else
render_validation_error!
(
storage_move
)
end
end
end
end
end
spec/requests/api/project_repository_storage_moves_spec.rb
View file @
926a1aba
...
...
@@ -111,4 +111,45 @@ describe API::ProjectRepositoryStorageMoves do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository_storage_moves/
#{
project_repository_storage_move_id
}
"
}
end
end
describe
'POST /projects/:id/repository_storage_moves'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository_storage_moves"
}
let
(
:destination_storage_name
)
{
'test_second_storage'
}
def
create_project_repository_storage_move
post
api
(
url
,
user
),
params:
{
destination_storage_name:
destination_storage_name
}
end
before
do
stub_storage_settings
(
'test_second_storage'
=>
{
'path'
=>
'tmp/tests/extra_storage'
})
end
it
'schedules a project repository storage move'
do
create_project_repository_storage_move
storage_move
=
project
.
repository_storage_moves
.
last
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/project_repository_storage_move'
)
expect
(
json_response
[
'id'
]).
to
eq
(
storage_move
.
id
)
expect
(
json_response
[
'state'
]).
to
eq
(
'scheduled'
)
expect
(
json_response
[
'source_storage_name'
]).
to
eq
(
'default'
)
expect
(
json_response
[
'destination_storage_name'
]).
to
eq
(
destination_storage_name
)
end
describe
'permissions'
do
it
{
expect
{
create_project_repository_storage_move
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
create_project_repository_storage_move
}.
to
be_denied_for
(
:user
)
}
end
context
'destination_storage_name is missing'
do
let
(
:destination_storage_name
)
{
nil
}
it
'returns a validation error'
do
create_project_repository_storage_move
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
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