Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nexus] Webhook API skeleton #7274

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 4 additions & 0 deletions Cargo.lock

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

13 changes: 13 additions & 0 deletions nexus/external-api/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ API operations found with tag "system/status"
OPERATION ID METHOD URL PATH
ping GET /v1/ping

API operations found with tag "system/webhooks"
OPERATION ID METHOD URL PATH
webhook_create POST /experimental/v1/webhooks
webhook_delete DELETE /experimental/v1/webhooks/{webhook_id}
webhook_delivery_list GET /experimental/v1/webhooks/{webhook_id}/deliveries
webhook_delivery_resend POST /experimental/v1/webhooks/{webhook_id}/deliveries/{event_id}/resend
webhook_event_class_list GET /experimental/v1/webhook-events/classes
webhook_event_class_view GET /experimental/v1/webhook-events/classes/{name}
webhook_secrets_add POST /experimental/v1/webhooks/{webhook_id}/secrets
webhook_secrets_list GET /experimental/v1/webhooks/{webhook_id}/secrets
webhook_update PUT /experimental/v1/webhooks/{webhook_id}
webhook_view GET /experimental/v1/webhooks/{webhook_id}

API operations found with tag "vpcs"
OPERATION ID METHOD URL PATH
internet_gateway_create POST /v1/internet-gateways
Expand Down
123 changes: 123 additions & 0 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ pub const API_VERSION: &str = "20241204.0.0";
url = "http://docs.oxide.computer/api/vpcs"
}
},
"system/webhooks" = {
description = "Webhooks deliver notifications for audit log events and fault management alerts.",
external_docs = {
url = "http://docs.oxide.computer/api/webhooks"
}
},
"system/probes" = {
description = "Probes for testing network connectivity",
external_docs = {
Expand Down Expand Up @@ -3088,6 +3094,123 @@ pub trait NexusExternalApi {
rqctx: RequestContext<Self::Context>,
params: TypedBody<params::DeviceAccessTokenRequest>,
) -> Result<Response<Body>, HttpError>;

// Webhooks (experimental)

/// List webhook event classes
#[endpoint {
method = GET,
path = "/experimental/v1/webhook-events/classes",
tags = ["system/webhooks"],
}]
async fn webhook_event_class_list(
rqctx: RequestContext<Self::Context>,
query_params: Query<
PaginationParams<params::EventClassFilter, params::EventClassPage>,
>,
) -> Result<HttpResponseOk<ResultsPage<views::EventClass>>, HttpError>;

/// Fetch details on an event class by name.
#[endpoint {
method = GET,
path ="/experimental/v1/webhook-events/classes/{name}",
tags = ["system/webhooks"],
}]
async fn webhook_event_class_view(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::EventClassSelector>,
) -> Result<HttpResponseOk<views::EventClass>, HttpError>;

/// Get the configuration for a webhook receiver.
#[endpoint {
method = GET,
path = "/experimental/v1/webhooks/{webhook_id}",
tags = ["system/webhooks"],
}]
async fn webhook_view(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
) -> Result<HttpResponseOk<views::Webhook>, HttpError>;

/// Create a new webhook receiver.
#[endpoint {
method = POST,
path = "/experimental/v1/webhooks",
tags = ["system/webhooks"],
}]
async fn webhook_create(
rqctx: RequestContext<Self::Context>,
params: TypedBody<params::WebhookCreate>,
) -> Result<HttpResponseCreated<views::Webhook>, HttpError>;

/// Update the configuration of an existing webhook receiver.
#[endpoint {
method = PUT,
path = "/experimental/v1/webhooks/{webhook_id}",
tags = ["system/webhooks"],
}]
async fn webhook_update(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
params: TypedBody<params::WebhookUpdate>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// Delete a webhook receiver.
#[endpoint {
method = DELETE,
path = "/experimental/v1/webhooks/{webhook_id}",
tags = ["system/webhooks"],
}]
async fn webhook_delete(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
) -> Result<HttpResponseDeleted, HttpError>;

/// List the IDs of secrets for a webhook receiver.
#[endpoint {
method = GET,
path = "/experimental/v1/webhooks/{webhook_id}/secrets",
tags = ["system/webhooks"],
}]
async fn webhook_secrets_list(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
) -> Result<HttpResponseOk<views::WebhookSecrets>, HttpError>;

/// Add a secret to a webhook receiver.
#[endpoint {
method = POST,
path = "/experimental/v1/webhooks/{webhook_id}/secrets",
tags = ["system/webhooks"],
}]
async fn webhook_secrets_add(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
params: TypedBody<params::WebhookSecret>,
) -> Result<HttpResponseCreated<views::WebhookSecretId>, HttpError>;

/// List delivery attempts to a webhook receiver.
#[endpoint {
method = GET,
path = "/experimental/v1/webhooks/{webhook_id}/deliveries",
tags = ["system/webhooks"],
}]
async fn webhook_delivery_list(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookPath>,
query_params: Query<PaginatedById>,
) -> Result<HttpResponseOk<ResultsPage<views::WebhookDelivery>>, HttpError>;

/// Request re-delivery of a webhook event.
#[endpoint {
method = POST,
path = "/experimental/v1/webhooks/{webhook_id}/deliveries/{event_id}/resend",
tags = ["system/webhooks"],
}]
async fn webhook_delivery_resend(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::WebhookDeliveryPath>,
) -> Result<HttpResponseCreated<views::WebhookDeliveryId>, HttpError>;
}

/// Perform extra validations on the OpenAPI spec.
Expand Down
Loading
Loading