From 2c7e8707fcc2979a8a26635a802b93aa325c8900 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Sat, 2 Jul 2022 22:20:41 -0700 Subject: [PATCH] working --- Cargo.lock | 8 ++- nexus/src/db/datastore.rs | 2 +- nexus/src/db/model/external_ip.rs | 2 +- nexus/src/external_api/device_auth.rs | 2 +- nexus/tests/output/nexus_tags.txt | 2 - openapi/nexus.json | 92 --------------------------- oxide-client/Cargo.toml | 3 +- oxide-client/src/lib.rs | 10 +-- 8 files changed, 15 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26584e7d99..33a9e5d079 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3427,9 +3427,11 @@ name = "oxide-client" version = "0.1.0" dependencies = [ "chrono", + "futures", "progenitor", "reqwest", "serde", + "serde_json", "uuid", ] @@ -4884,9 +4886,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" dependencies = [ "itoa 1.0.2", "ryu", @@ -6166,7 +6168,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] diff --git a/nexus/src/db/datastore.rs b/nexus/src/db/datastore.rs index c53b84c7a4..4ddb41fd45 100644 --- a/nexus/src/db/datastore.rs +++ b/nexus/src/db/datastore.rs @@ -2305,7 +2305,7 @@ impl DataStore { }; sled_client_types::NetworkInterface { name: sled_client_types::Name::from(&nic.name.0), - ip: nic.ip.ip().to_string(), + ip: nic.ip.ip(), mac: sled_client_types::MacAddr::from(nic.mac.0), subnet: sled_client_types::IpNet::from(ip_subnet), vni: sled_client_types::Vni::from(nic.vni.0), diff --git a/nexus/src/db/model/external_ip.rs b/nexus/src/db/model/external_ip.rs index d670e02aed..f4f69b0ba4 100644 --- a/nexus/src/db/model/external_ip.rs +++ b/nexus/src/db/model/external_ip.rs @@ -32,7 +32,7 @@ pub struct InstanceExternalIp { impl From for sled_agent_client::types::ExternalIp { fn from(eip: InstanceExternalIp) -> Self { Self { - ip: eip.ip.ip().to_string(), + ip: eip.ip.ip(), first_port: eip.first_port.0, last_port: eip.last_port.0, } diff --git a/nexus/src/external_api/device_auth.rs b/nexus/src/external_api/device_auth.rs index 744ea98339..f3adb836de 100644 --- a/nexus/src/external_api/device_auth.rs +++ b/nexus/src/external_api/device_auth.rs @@ -191,7 +191,7 @@ pub enum DeviceAccessTokenResponse { method = POST, path = "/device/token", content_type = "application/x-www-form-urlencoded", - tags = ["hidden"], // "token" + unpublished = true, }] pub async fn device_access_token( rqctx: Arc>>, diff --git a/nexus/tests/output/nexus_tags.txt b/nexus/tests/output/nexus_tags.txt index 95d99abfe4..0bc6c67479 100644 --- a/nexus/tests/output/nexus_tags.txt +++ b/nexus/tests/output/nexus_tags.txt @@ -12,9 +12,7 @@ vpc_firewall_rules_put /organizations/{organization_name}/proj API operations found with tag "hidden" OPERATION ID URL PATH -device_access_token /device/token device_auth_confirm /device/confirm -device_auth_request /device/auth device_auth_verify /device/verify logout /logout session_me /session/me diff --git a/openapi/nexus.json b/openapi/nexus.json index 9e354e60d1..96b51b3d80 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -10,36 +10,6 @@ "version": "0.0.1" }, "paths": { - "/device/auth": { - "post": { - "tags": [ - "hidden" - ], - "summary": "Start an OAuth 2.0 Device Authorization Grant", - "description": "This endpoint is designed to be accessed from an *unauthenticated* API client. It generates and records a `device_code` and `user_code` which must be verified and confirmed prior to a token being granted.", - "operationId": "device_auth_request", - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/DeviceAuthRequest" - } - } - }, - "required": true - }, - "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} - } - } - } - } - } - }, "/device/confirm": { "post": { "tags": [ @@ -82,36 +52,6 @@ } } }, - "/device/token": { - "post": { - "tags": [ - "hidden" - ], - "summary": "Request a device access token", - "description": "This endpoint should be polled by the client until the user code is verified and the grant is confirmed.", - "operationId": "device_access_token", - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/DeviceAccessTokenRequest" - } - } - }, - "required": true - }, - "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} - } - } - } - } - } - }, "/device/verify": { "get": { "tags": [ @@ -6273,38 +6213,6 @@ "public_cert" ] }, - "DeviceAccessTokenRequest": { - "type": "object", - "properties": { - "client_id": { - "type": "string", - "format": "uuid" - }, - "device_code": { - "type": "string" - }, - "grant_type": { - "type": "string" - } - }, - "required": [ - "client_id", - "device_code", - "grant_type" - ] - }, - "DeviceAuthRequest": { - "type": "object", - "properties": { - "client_id": { - "type": "string", - "format": "uuid" - } - }, - "required": [ - "client_id" - ] - }, "DeviceAuthVerify": { "type": "object", "properties": { diff --git a/oxide-client/Cargo.toml b/oxide-client/Cargo.toml index 458054d4f2..a148b1f04d 100644 --- a/oxide-client/Cargo.toml +++ b/oxide-client/Cargo.toml @@ -6,7 +6,8 @@ license = "MPL-2.0" [dependencies] progenitor = { git = "https://github.com/oxidecomputer/progenitor" } -#serde_json = "1.0" +futures = "0.3.21" +serde_json = "1.0.82" [dependencies.chrono] version = "0.4" diff --git a/oxide-client/src/lib.rs b/oxide-client/src/lib.rs index 8585adf338..7a6237759c 100644 --- a/oxide-client/src/lib.rs +++ b/oxide-client/src/lib.rs @@ -4,8 +4,8 @@ //! Interface for making API requests to the Oxide control plane. -// progenitor::generate_api!( -// spec = "../openapi/nexus.json", -// interface = Builder, -// tags = Separate, -// ); +progenitor::generate_api!( + spec = "../openapi/nexus.json", + interface = Builder, + tags = Separate, +);