Skip to content

Commit 4181ee1

Browse files
committed
make repo get and put endpoints more conventional
1 parent 5222d49 commit 4181ee1

File tree

7 files changed

+33
-28
lines changed

7 files changed

+33
-28
lines changed

nexus/external-api/output/nexus_tags.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ ping GET /v1/ping
296296

297297
API operations found with tag "system/update"
298298
OPERATION ID METHOD URL PATH
299-
system_update_get_repository GET /v1/system/update/repository/{system_version}
300-
system_update_put_repository PUT /v1/system/update/repository
301299
system_update_repository_list GET /v1/system/update/repositories
300+
system_update_repository_upload PUT /v1/system/update/repositories
301+
system_update_repository_view GET /v1/system/update/repositories/{system_version}
302302
system_update_trust_root_create POST /v1/system/update/trust-roots
303303
system_update_trust_root_delete DELETE /v1/system/update/trust-roots/{trust_root_id}
304304
system_update_trust_root_list GET /v1/system/update/trust-roots

nexus/external-api/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,11 +2967,11 @@ pub trait NexusExternalApi {
29672967
/// System release repositories are verified by the updates trust store.
29682968
#[endpoint {
29692969
method = PUT,
2970-
path = "/v1/system/update/repository",
2970+
path = "/v1/system/update/repositories",
29712971
tags = ["system/update"],
29722972
request_body_max_bytes = PUT_UPDATE_REPOSITORY_MAX_BYTES,
29732973
}]
2974-
async fn system_update_put_repository(
2974+
async fn system_update_repository_upload(
29752975
rqctx: RequestContext<Self::Context>,
29762976
query: Query<params::UpdatesPutRepositoryParams>,
29772977
body: StreamingBody,
@@ -2980,10 +2980,10 @@ pub trait NexusExternalApi {
29802980
/// Fetch system release repository description by version
29812981
#[endpoint {
29822982
method = GET,
2983-
path = "/v1/system/update/repository/{system_version}",
2983+
path = "/v1/system/update/repositories/{system_version}",
29842984
tags = ["system/update"],
29852985
}]
2986-
async fn system_update_get_repository(
2986+
async fn system_update_repository_view(
29872987
rqctx: RequestContext<Self::Context>,
29882988
path_params: Path<params::UpdatesGetRepositoryParams>,
29892989
) -> Result<HttpResponseOk<views::TufRepo>, HttpError>;

nexus/src/external_api/http_entrypoints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6639,7 +6639,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
66396639

66406640
// Updates
66416641

6642-
async fn system_update_put_repository(
6642+
async fn system_update_repository_upload(
66436643
rqctx: RequestContext<ApiContext>,
66446644
query: Query<params::UpdatesPutRepositoryParams>,
66456645
body: StreamingBody,
@@ -6664,7 +6664,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
66646664
.await
66656665
}
66666666

6667-
async fn system_update_get_repository(
6667+
async fn system_update_repository_view(
66686668
rqctx: RequestContext<ApiContext>,
66696669
path_params: Path<params::UpdatesGetRepositoryParams>,
66706670
) -> Result<HttpResponseOk<views::TufRepo>, HttpError> {

nexus/tests/integration_tests/endpoints.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,16 +2535,21 @@ pub static VERIFY_ENDPOINTS: LazyLock<Vec<VerifyEndpoint>> = LazyLock::new(
25352535
],
25362536
},
25372537
VerifyEndpoint {
2538-
url: "/v1/system/update/repository?file_name=demo-repo.zip",
2538+
url: "/v1/system/update/repositories?file_name=demo-repo.zip",
25392539
visibility: Visibility::Public,
25402540
unprivileged_access: UnprivilegedAccess::None,
2541-
allowed_methods: vec![AllowedMethod::Put(
2542-
// In reality this is the contents of a zip file.
2543-
serde_json::Value::Null,
2544-
)],
2541+
allowed_methods: vec![
2542+
// the query param is only relevant to the put
2543+
AllowedMethod::Put(
2544+
// In reality this is the contents of a zip file.
2545+
serde_json::Value::Null,
2546+
),
2547+
// get doesn't use the query param but it doesn't break if it's there
2548+
AllowedMethod::Get
2549+
],
25452550
},
25462551
VerifyEndpoint {
2547-
url: "/v1/system/update/repository/1.0.0",
2552+
url: "/v1/system/update/repositories/1.0.0",
25482553
visibility: Visibility::Public,
25492554
unprivileged_access: UnprivilegedAccess::None,
25502555
allowed_methods: vec![AllowedMethod::Get],

nexus/tests/integration_tests/updates.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl TestRepo {
140140
expected_status: StatusCode,
141141
) -> NexusRequest<'a> {
142142
let url = format!(
143-
"/v1/system/update/repository?file_name={}",
143+
"/v1/system/update/repositories?file_name={}",
144144
self.0.file_name().expect("archive path must have a file name")
145145
);
146146
let request = RequestBuilder::new(client, Method::PUT, &url)
@@ -196,7 +196,7 @@ async fn test_repo_upload_unconfigured() -> Result<()> {
196196
// with a 404 error.
197197
object_get_error(
198198
client,
199-
"/v1/system/update/repository/1.0.0",
199+
"/v1/system/update/repositories/1.0.0",
200200
StatusCode::NOT_FOUND,
201201
)
202202
.await;
@@ -348,7 +348,7 @@ async fn test_repo_upload() -> Result<()> {
348348

349349
// Now get the repository that was just uploaded.
350350
let repo =
351-
object_get::<TufRepo>(client, "/v1/system/update/repository/1.0.0")
351+
object_get::<TufRepo>(client, "/v1/system/update/repositories/1.0.0")
352352
.await;
353353

354354
// Compare just the repo metadata (not artifacts)
@@ -525,9 +525,11 @@ async fn test_repo_upload() -> Result<()> {
525525
);
526526

527527
// Now get the repository that was just uploaded.
528-
let get_repo =
529-
object_get::<TufRepo>(client, "/v1/system/update/repository/2.0.0")
530-
.await;
528+
let get_repo = object_get::<TufRepo>(
529+
client,
530+
"/v1/system/update/repositories/2.0.0",
531+
)
532+
.await;
531533

532534
// Validate the repo metadata
533535
assert_eq!(get_repo.system_version.to_string(), "2.0.0");

nexus/types/src/external_api/params.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,14 +2398,14 @@ pub struct ResourceMetrics {
23982398

23992399
// SYSTEM UPDATE
24002400

2401-
/// Parameters for PUT requests for `/v1/system/update/repository`.
2401+
/// Parameters for PUT requests for `/v1/system/update/repositories`.
24022402
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
24032403
pub struct UpdatesPutRepositoryParams {
24042404
/// The name of the uploaded file.
24052405
pub file_name: String,
24062406
}
24072407

2408-
/// Parameters for GET requests for `/v1/system/update/repository`.
2408+
/// Parameters for GET requests for `/v1/system/update/repositories`.
24092409
#[derive(Clone, Debug, Deserialize, JsonSchema)]
24102410
pub struct UpdatesGetRepositoryParams {
24112411
/// The version to get.

openapi/nexus.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10961,16 +10961,14 @@
1096110961
"x-dropshot-pagination": {
1096210962
"required": []
1096310963
}
10964-
}
10965-
},
10966-
"/v1/system/update/repository": {
10964+
},
1096710965
"put": {
1096810966
"tags": [
1096910967
"system/update"
1097010968
],
1097110969
"summary": "Upload system release repository",
1097210970
"description": "System release repositories are verified by the updates trust store.",
10973-
"operationId": "system_update_put_repository",
10971+
"operationId": "system_update_repository_upload",
1097410972
"parameters": [
1097510973
{
1097610974
"in": "query",
@@ -11013,13 +11011,13 @@
1101311011
}
1101411012
}
1101511013
},
11016-
"/v1/system/update/repository/{system_version}": {
11014+
"/v1/system/update/repositories/{system_version}": {
1101711015
"get": {
1101811016
"tags": [
1101911017
"system/update"
1102011018
],
1102111019
"summary": "Fetch system release repository description by version",
11022-
"operationId": "system_update_get_repository",
11020+
"operationId": "system_update_repository_view",
1102311021
"parameters": [
1102411022
{
1102511023
"in": "path",

0 commit comments

Comments
 (0)