Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .github/buildomat/jobs/dpd_openapi.sh

This file was deleted.

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dpd-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2024"
common.workspace = true
dpd-types.workspace = true
dropshot.workspace = true
dropshot-api-manager-types.workspace = true
oxnet.workspace = true
schemars.workspace = true
serde.workspace = true
Expand Down
28 changes: 28 additions & 0 deletions dpd-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,41 @@ use dropshot::{
HttpResponseOk, HttpResponseUpdatedNoContent, PaginationParams, Path,
Query, RequestContext, ResultsPage, TypedBody,
};
use dropshot_api_manager_types::api_versions;
use oxnet::{Ipv4Net, Ipv6Net};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use transceiver_controller::{
Datapath, Monitors, PowerState, message::LedState,
};

api_versions!([
// WHEN CHANGING THE API (part 1 of 2):
//
// +- Pick a new semver and define it in the list below. The list MUST
// | remain sorted, which generally means that your version should go at
// | the very top.
// |
// | Duplicate this line, uncomment the *second* copy, update that copy for
// | your new API version, and leave the first copy commented out as an
// | example for the next person.
// v
// (next_int, IDENT),
(1, INITIAL),
]);

// WHEN CHANGING THE API (part 2 of 2):
//
// The call to `api_versions!` above defines constants of type
// `semver::Version` that you can use in your Dropshot API definition to specify
// the version when a particular endpoint was added or removed. For example, if
// you used:
//
// (2, ADD_FOOBAR)
//
// Then you could use `VERSION_ADD_FOOBAR` as the version in which endpoints
// were added or removed.

#[dropshot::api_description]
pub trait DpdApi {
type Context;
Expand Down
2 changes: 1 addition & 1 deletion dpd-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct ClientState {

// Automatically generate the client bindings using Progenitor.
progenitor::generate_api!(
spec = "../openapi/dpd.json",
spec = "../openapi/dpd/dpd-latest.json",
interface = Positional,
inner_type = crate::ClientState,
pre_hook = (|state: &crate::ClientState, request: &reqwest::Request| {
Expand Down
22 changes: 13 additions & 9 deletions dpd/src/api_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use dpd_types::switch_port::Led;
use dpd_types::switch_port::ManagementMode;
use dpd_types::transceivers::Transceiver;
use dropshot::ClientErrorStatusCode;
use dropshot::ClientSpecifiesVersionInHeader;
use dropshot::EmptyScanParams;
use dropshot::HttpError;
use dropshot::HttpResponseCreated;
Expand All @@ -45,6 +46,7 @@ use dropshot::Query;
use dropshot::RequestContext;
use dropshot::ResultsPage;
use dropshot::TypedBody;
use dropshot::VersionPolicy;
use dropshot::WhichPage;
use slog::{debug, error, info, o};
use transceiver_controller::Datapath;
Expand Down Expand Up @@ -2618,15 +2620,17 @@ fn launch_server(
.log
.new(o!("unit" => "api-server", "server_id" => id.to_string()));

slog::info!(log, "starting api server {id} on {addr}");
dropshot::HttpServerStarter::new(
&config_dropshot,
http_api(),
switch.clone(),
&log,
)
.map(|s| s.start())
.map_err(|e| anyhow::anyhow!(e.to_string()))
dropshot::ServerBuilder::new(http_api(), switch, log)
.config(config_dropshot)
.version_policy(VersionPolicy::Dynamic(Box::new(
ClientSpecifiesVersionInHeader::new(
omicron_common::api::VERSION_HEADER,
dpd_api::latest_version(),
),
)))
.build_starter()
.map(|s| s.start())
.map_err(|e| anyhow::anyhow!(e.to_string()))
}

// Manage the set of api servers currently listening for requests. When a
Expand Down
4 changes: 2 additions & 2 deletions dropshot-apis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub fn environment() -> anyhow::Result<Environment> {
pub fn all_apis() -> anyhow::Result<ManagedApis> {
let apis = vec![ManagedApiConfig {
ident: "dpd",
versions: Versions::Lockstep {
version: semver::Version::new(0, 1, 0),
versions: Versions::Versioned {
supported_versions: dpd_api::supported_versions(),
},
title: "Oxide Switch Dataplane Controller",
metadata: ManagedApiMetadata {
Expand Down
2 changes: 1 addition & 1 deletion openapi/dpd.json → openapi/dpd/dpd-1.0.0-40fbc6.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://oxide.computer",
"email": "api@oxide.computer"
},
"version": "0.1.0"
"version": "1.0.0"
},
"paths": {
"/all-settings": {
Expand Down
1 change: 1 addition & 0 deletions openapi/dpd/dpd-latest.json