Skip to content

Commit efb34a5

Browse files
committed
update endpoint is a PUT on the resource, add unauthorized coverage
1 parent 662401d commit efb34a5

File tree

5 files changed

+54
-54
lines changed

5 files changed

+54
-54
lines changed

nexus/external-api/output/nexus_tags.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ instance_serial_console_stream GET /v1/instances/{instance}/seria
6262
instance_ssh_public_key_list GET /v1/instances/{instance}/ssh-public-keys
6363
instance_start POST /v1/instances/{instance}/start
6464
instance_stop POST /v1/instances/{instance}/stop
65-
instance_update PUT /v1/instances/{instance}/update
65+
instance_update PUT /v1/instances/{instance}
6666
instance_view GET /v1/instances/{instance}
6767

6868
API operations found with tag "login"

nexus/external-api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ pub trait NexusExternalApi {
11201120
/// Update instance
11211121
#[endpoint {
11221122
method = PUT,
1123-
path = "/v1/instances/{instance}/update",
1123+
path = "/v1/instances/{instance}",
11241124
tags = ["instances"],
11251125
}]
11261126
async fn instance_update(

nexus/tests/integration_tests/endpoints.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ pub static DEMO_INSTANCE_CREATE: Lazy<params::InstanceCreate> =
432432
boot_device: None,
433433
start: true,
434434
});
435+
pub static DEMO_INSTANCE_UPDATE: Lazy<params::InstanceUpdate> =
436+
Lazy::new(|| params::InstanceUpdate { boot_device: None });
435437

436438
// The instance needs a network interface, too.
437439
pub static DEMO_INSTANCE_NIC_NAME: Lazy<Name> =
@@ -1797,6 +1799,9 @@ pub static VERIFY_ENDPOINTS: Lazy<Vec<VerifyEndpoint>> = Lazy::new(|| {
17971799
allowed_methods: vec![
17981800
AllowedMethod::Get,
17991801
AllowedMethod::Delete,
1802+
AllowedMethod::Put(
1803+
serde_json::to_value(&*DEMO_INSTANCE_UPDATE).unwrap()
1804+
),
18001805
],
18011806
},
18021807

nexus/tests/integration_tests/instances.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,8 +3881,7 @@ async fn test_cannot_detach_boot_device(cptestctx: &ControlPlaneTestContext) {
38813881
assert_eq!(err.message, "boot disk cannot be detached");
38823882

38833883
// Change the instance's boot disk.
3884-
let url_instance_update =
3885-
format!("/v1/instances/{}/update", instance.identity.id);
3884+
let url_instance_update = format!("/v1/instances/{}", instance.identity.id);
38863885

38873886
let builder =
38883887
RequestBuilder::new(client, http::Method::PUT, &url_instance_update)
@@ -3983,8 +3982,7 @@ async fn test_boot_device_can_be_changed(cptestctx: &ControlPlaneTestContext) {
39833982
assert_eq!(instance.boot_device_id, Some(disks[0].identity.id.clone()));
39843983

39853984
// Change the instance's boot disk.
3986-
let url_instance_update =
3987-
format!("/v1/instances/{}/update", instance.identity.id);
3985+
let url_instance_update = format!("/v1/instances/{}", instance.identity.id);
39883986

39893987
let builder =
39903988
RequestBuilder::new(client, http::Method::PUT, &url_instance_update)
@@ -4060,8 +4058,7 @@ async fn test_boot_device_must_be_attached(
40604058

40614059
// Update the instance's boot device to the unattached disk. This should
40624060
// fail.
4063-
let url_instance_update =
4064-
format!("/v1/instances/{}/update", instance.identity.id);
4061+
let url_instance_update = format!("/v1/instances/{}", instance.identity.id);
40654062

40664063
let builder =
40674064
RequestBuilder::new(client, http::Method::PUT, &url_instance_update)

openapi/nexus.json

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,50 @@
19491949
"$ref": "#/components/responses/Error"
19501950
}
19511951
}
1952+
},
1953+
"put": {
1954+
"tags": [
1955+
"instances"
1956+
],
1957+
"summary": "Update instance configuration",
1958+
"operationId": "instance_update",
1959+
"parameters": [
1960+
{
1961+
"in": "query",
1962+
"name": "project",
1963+
"description": "Name or ID of the project",
1964+
"schema": {
1965+
"$ref": "#/components/schemas/NameOrId"
1966+
}
1967+
},
1968+
{
1969+
"in": "path",
1970+
"name": "instance",
1971+
"description": "Name or ID of the instance",
1972+
"required": true,
1973+
"schema": {
1974+
"$ref": "#/components/schemas/NameOrId"
1975+
}
1976+
}
1977+
],
1978+
"responses": {
1979+
"200": {
1980+
"description": "successful operation",
1981+
"content": {
1982+
"application/json": {
1983+
"schema": {
1984+
"$ref": "#/components/schemas/Instance"
1985+
}
1986+
}
1987+
}
1988+
},
1989+
"4XX": {
1990+
"$ref": "#/components/responses/Error"
1991+
},
1992+
"5XX": {
1993+
"$ref": "#/components/responses/Error"
1994+
}
1995+
}
19521996
}
19531997
},
19541998
"/v1/instances/{instance}/disks": {
@@ -2622,52 +2666,6 @@
26222666
}
26232667
}
26242668
},
2625-
"/v1/instances/{instance}/update": {
2626-
"put": {
2627-
"tags": [
2628-
"instances"
2629-
],
2630-
"summary": "Update instance configuration",
2631-
"operationId": "instance_update",
2632-
"parameters": [
2633-
{
2634-
"in": "query",
2635-
"name": "project",
2636-
"description": "Name or ID of the project",
2637-
"schema": {
2638-
"$ref": "#/components/schemas/NameOrId"
2639-
}
2640-
},
2641-
{
2642-
"in": "path",
2643-
"name": "instance",
2644-
"description": "Name or ID of the instance",
2645-
"required": true,
2646-
"schema": {
2647-
"$ref": "#/components/schemas/NameOrId"
2648-
}
2649-
}
2650-
],
2651-
"responses": {
2652-
"200": {
2653-
"description": "successful operation",
2654-
"content": {
2655-
"application/json": {
2656-
"schema": {
2657-
"$ref": "#/components/schemas/Instance"
2658-
}
2659-
}
2660-
}
2661-
},
2662-
"4XX": {
2663-
"$ref": "#/components/responses/Error"
2664-
},
2665-
"5XX": {
2666-
"$ref": "#/components/responses/Error"
2667-
}
2668-
}
2669-
}
2670-
},
26712669
"/v1/ip-pools": {
26722670
"get": {
26732671
"tags": [

0 commit comments

Comments
 (0)