openapi: rename unclear endpoints

This commit is contained in:
Quaternions 2024-12-11 17:54:11 -08:00
parent a9a4eaa20d
commit 1a747bee80
7 changed files with 139 additions and 109 deletions

View File

@ -241,9 +241,9 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/Error" $ref: "#/components/schemas/Error"
/submissions/{SubmissionID}/status/validate: /submissions/{SubmissionID}/status/validator-validated:
post: post:
summary: Role Validator changes status from Validating -> Validated summary: (Internal endpoint) Role Validator changes status from Validating -> Validated
operationId: actionSubmissionValidate operationId: actionSubmissionValidate
tags: tags:
- Submissions - Submissions
@ -258,9 +258,9 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/Error" $ref: "#/components/schemas/Error"
/submissions/{SubmissionID}/status/publish: /submissions/{SubmissionID}/status/validator-published:
post: post:
summary: Role Validator changes status from Publishing -> Published summary: (Internal endpoint) Role Validator changes status from Publishing -> Published
operationId: actionSubmissionPublish operationId: actionSubmissionPublish
tags: tags:
- Submissions - Submissions

View File

@ -26,9 +26,9 @@ import (
type Invoker interface { type Invoker interface {
// ActionSubmissionPublish invokes actionSubmissionPublish operation. // ActionSubmissionPublish invokes actionSubmissionPublish operation.
// //
// Role Validator changes status from Publishing -> Published. // (Internal endpoint) Role Validator changes status from Publishing -> Published.
// //
// POST /submissions/{SubmissionID}/status/publish // POST /submissions/{SubmissionID}/status/validator-published
ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error
// ActionSubmissionReject invokes actionSubmissionReject operation. // ActionSubmissionReject invokes actionSubmissionReject operation.
// //
@ -68,9 +68,9 @@ type Invoker interface {
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
// ActionSubmissionValidate invokes actionSubmissionValidate operation. // ActionSubmissionValidate invokes actionSubmissionValidate operation.
// //
// Role Validator changes status from Validating -> Validated. // (Internal endpoint) Role Validator changes status from Validating -> Validated.
// //
// POST /submissions/{SubmissionID}/status/validate // POST /submissions/{SubmissionID}/status/validator-validated
ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error
// CreateScript invokes createScript operation. // CreateScript invokes createScript operation.
// //
@ -214,9 +214,9 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
// ActionSubmissionPublish invokes actionSubmissionPublish operation. // ActionSubmissionPublish invokes actionSubmissionPublish operation.
// //
// Role Validator changes status from Publishing -> Published. // (Internal endpoint) Role Validator changes status from Publishing -> Published.
// //
// POST /submissions/{SubmissionID}/status/publish // POST /submissions/{SubmissionID}/status/validator-published
func (c *Client) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error { func (c *Client) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error {
_, err := c.sendActionSubmissionPublish(ctx, params) _, err := c.sendActionSubmissionPublish(ctx, params)
return err return err
@ -226,7 +226,7 @@ func (c *Client) sendActionSubmissionPublish(ctx context.Context, params ActionS
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("actionSubmissionPublish"), otelogen.OperationID("actionSubmissionPublish"),
semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/publish"), semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-published"),
} }
// Run stopwatch. // Run stopwatch.
@ -278,7 +278,7 @@ func (c *Client) sendActionSubmissionPublish(ctx context.Context, params ActionS
} }
pathParts[1] = encoded pathParts[1] = encoded
} }
pathParts[2] = "/status/publish" pathParts[2] = "/status/validator-published"
uri.AddPathParts(u, pathParts[:]...) uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest" stage = "EncodeRequest"
@ -1049,9 +1049,9 @@ func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params
// ActionSubmissionValidate invokes actionSubmissionValidate operation. // ActionSubmissionValidate invokes actionSubmissionValidate operation.
// //
// Role Validator changes status from Validating -> Validated. // (Internal endpoint) Role Validator changes status from Validating -> Validated.
// //
// POST /submissions/{SubmissionID}/status/validate // POST /submissions/{SubmissionID}/status/validator-validated
func (c *Client) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error { func (c *Client) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error {
_, err := c.sendActionSubmissionValidate(ctx, params) _, err := c.sendActionSubmissionValidate(ctx, params)
return err return err
@ -1061,7 +1061,7 @@ func (c *Client) sendActionSubmissionValidate(ctx context.Context, params Action
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("actionSubmissionValidate"), otelogen.OperationID("actionSubmissionValidate"),
semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validate"), semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-validated"),
} }
// Run stopwatch. // Run stopwatch.
@ -1113,7 +1113,7 @@ func (c *Client) sendActionSubmissionValidate(ctx context.Context, params Action
} }
pathParts[1] = encoded pathParts[1] = encoded
} }
pathParts[2] = "/status/validate" pathParts[2] = "/status/validator-validated"
uri.AddPathParts(u, pathParts[:]...) uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest" stage = "EncodeRequest"

View File

@ -32,16 +32,16 @@ func (c *codeRecorder) WriteHeader(status int) {
// handleActionSubmissionPublishRequest handles actionSubmissionPublish operation. // handleActionSubmissionPublishRequest handles actionSubmissionPublish operation.
// //
// Role Validator changes status from Publishing -> Published. // (Internal endpoint) Role Validator changes status from Publishing -> Published.
// //
// POST /submissions/{SubmissionID}/status/publish // POST /submissions/{SubmissionID}/status/validator-published
func (s *Server) handleActionSubmissionPublishRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { func (s *Server) handleActionSubmissionPublishRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w} statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter w = statusWriter
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("actionSubmissionPublish"), otelogen.OperationID("actionSubmissionPublish"),
semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/publish"), semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-published"),
} }
// Start a span for this request. // Start a span for this request.
@ -120,7 +120,7 @@ func (s *Server) handleActionSubmissionPublishRequest(args [1]string, argsEscape
mreq := middleware.Request{ mreq := middleware.Request{
Context: ctx, Context: ctx,
OperationName: ActionSubmissionPublishOperation, OperationName: ActionSubmissionPublishOperation,
OperationSummary: "Role Validator changes status from Publishing -> Published", OperationSummary: "(Internal endpoint) Role Validator changes status from Publishing -> Published",
OperationID: "actionSubmissionPublish", OperationID: "actionSubmissionPublish",
Body: nil, Body: nil,
Params: middleware.Parameters{ Params: middleware.Parameters{
@ -1351,16 +1351,16 @@ func (s *Server) handleActionSubmissionTriggerValidateRequest(args [1]string, ar
// handleActionSubmissionValidateRequest handles actionSubmissionValidate operation. // handleActionSubmissionValidateRequest handles actionSubmissionValidate operation.
// //
// Role Validator changes status from Validating -> Validated. // (Internal endpoint) Role Validator changes status from Validating -> Validated.
// //
// POST /submissions/{SubmissionID}/status/validate // POST /submissions/{SubmissionID}/status/validator-validated
func (s *Server) handleActionSubmissionValidateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { func (s *Server) handleActionSubmissionValidateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w} statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter w = statusWriter
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("actionSubmissionValidate"), otelogen.OperationID("actionSubmissionValidate"),
semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validate"), semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-validated"),
} }
// Start a span for this request. // Start a span for this request.
@ -1439,7 +1439,7 @@ func (s *Server) handleActionSubmissionValidateRequest(args [1]string, argsEscap
mreq := middleware.Request{ mreq := middleware.Request{
Context: ctx, Context: ctx,
OperationName: ActionSubmissionValidateOperation, OperationName: ActionSubmissionValidateOperation,
OperationSummary: "Role Validator changes status from Validating -> Validated", OperationSummary: "(Internal endpoint) Role Validator changes status from Validating -> Validated",
OperationID: "actionSubmissionValidate", OperationID: "actionSubmissionValidate",
Body: nil, Body: nil,
Params: middleware.Parameters{ Params: middleware.Parameters{

View File

@ -356,29 +356,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
break break
} }
switch elem[0] { switch elem[0] {
case 'p': // Prefix: "publish"
origElem := elem
if l := len("publish"); len(elem) >= l && elem[0:l] == "publish" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch r.Method {
case "POST":
s.handleActionSubmissionPublishRequest([1]string{
args[0],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, "POST")
}
return
}
elem = origElem
case 'r': // Prefix: "re" case 'r': // Prefix: "re"
origElem := elem origElem := elem
if l := len("re"); len(elem) >= l && elem[0:l] == "re" { if l := len("re"); len(elem) >= l && elem[0:l] == "re" {
@ -547,9 +524,44 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
elem = origElem elem = origElem
case 'v': // Prefix: "validate" case 'v': // Prefix: "validator-"
origElem := elem origElem := elem
if l := len("validate"); len(elem) >= l && elem[0:l] == "validate" { if l := len("validator-"); len(elem) >= l && elem[0:l] == "validator-" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
break
}
switch elem[0] {
case 'p': // Prefix: "published"
origElem := elem
if l := len("published"); len(elem) >= l && elem[0:l] == "published" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch r.Method {
case "POST":
s.handleActionSubmissionPublishRequest([1]string{
args[0],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, "POST")
}
return
}
elem = origElem
case 'v': // Prefix: "validated"
origElem := elem
if l := len("validated"); len(elem) >= l && elem[0:l] == "validated" {
elem = elem[l:] elem = elem[l:]
} else { } else {
break break
@ -586,6 +598,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
elem = origElem elem = origElem
} }
elem = origElem
}
} }
s.notFound(w, r) s.notFound(w, r)
} }
@ -1018,31 +1033,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
break break
} }
switch elem[0] { switch elem[0] {
case 'p': // Prefix: "publish"
origElem := elem
if l := len("publish"); len(elem) >= l && elem[0:l] == "publish" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch method {
case "POST":
r.name = ActionSubmissionPublishOperation
r.summary = "Role Validator changes status from Publishing -> Published"
r.operationID = "actionSubmissionPublish"
r.pathPattern = "/submissions/{SubmissionID}/status/publish"
r.args = args
r.count = 1
return r, true
default:
return
}
}
elem = origElem
case 'r': // Prefix: "re" case 'r': // Prefix: "re"
origElem := elem origElem := elem
if l := len("re"); len(elem) >= l && elem[0:l] == "re" { if l := len("re"); len(elem) >= l && elem[0:l] == "re" {
@ -1223,9 +1213,46 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
} }
elem = origElem elem = origElem
case 'v': // Prefix: "validate" case 'v': // Prefix: "validator-"
origElem := elem origElem := elem
if l := len("validate"); len(elem) >= l && elem[0:l] == "validate" { if l := len("validator-"); len(elem) >= l && elem[0:l] == "validator-" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
break
}
switch elem[0] {
case 'p': // Prefix: "published"
origElem := elem
if l := len("published"); len(elem) >= l && elem[0:l] == "published" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch method {
case "POST":
r.name = ActionSubmissionPublishOperation
r.summary = "(Internal endpoint) Role Validator changes status from Publishing -> Published"
r.operationID = "actionSubmissionPublish"
r.pathPattern = "/submissions/{SubmissionID}/status/validator-published"
r.args = args
r.count = 1
return r, true
default:
return
}
}
elem = origElem
case 'v': // Prefix: "validated"
origElem := elem
if l := len("validated"); len(elem) >= l && elem[0:l] == "validated" {
elem = elem[l:] elem = elem[l:]
} else { } else {
break break
@ -1236,9 +1263,9 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
switch method { switch method {
case "POST": case "POST":
r.name = ActionSubmissionValidateOperation r.name = ActionSubmissionValidateOperation
r.summary = "Role Validator changes status from Validating -> Validated" r.summary = "(Internal endpoint) Role Validator changes status from Validating -> Validated"
r.operationID = "actionSubmissionValidate" r.operationID = "actionSubmissionValidate"
r.pathPattern = "/submissions/{SubmissionID}/status/validate" r.pathPattern = "/submissions/{SubmissionID}/status/validator-validated"
r.args = args r.args = args
r.count = 1 r.count = 1
return r, true return r, true
@ -1264,6 +1291,9 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
elem = origElem elem = origElem
} }
elem = origElem
}
} }
return r, false return r, false
} }

View File

@ -10,9 +10,9 @@ import (
type Handler interface { type Handler interface {
// ActionSubmissionPublish implements actionSubmissionPublish operation. // ActionSubmissionPublish implements actionSubmissionPublish operation.
// //
// Role Validator changes status from Publishing -> Published. // (Internal endpoint) Role Validator changes status from Publishing -> Published.
// //
// POST /submissions/{SubmissionID}/status/publish // POST /submissions/{SubmissionID}/status/validator-published
ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error
// ActionSubmissionReject implements actionSubmissionReject operation. // ActionSubmissionReject implements actionSubmissionReject operation.
// //
@ -52,9 +52,9 @@ type Handler interface {
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
// ActionSubmissionValidate implements actionSubmissionValidate operation. // ActionSubmissionValidate implements actionSubmissionValidate operation.
// //
// Role Validator changes status from Validating -> Validated. // (Internal endpoint) Role Validator changes status from Validating -> Validated.
// //
// POST /submissions/{SubmissionID}/status/validate // POST /submissions/{SubmissionID}/status/validator-validated
ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error
// CreateScript implements createScript operation. // CreateScript implements createScript operation.
// //

View File

@ -15,9 +15,9 @@ var _ Handler = UnimplementedHandler{}
// ActionSubmissionPublish implements actionSubmissionPublish operation. // ActionSubmissionPublish implements actionSubmissionPublish operation.
// //
// Role Validator changes status from Publishing -> Published. // (Internal endpoint) Role Validator changes status from Publishing -> Published.
// //
// POST /submissions/{SubmissionID}/status/publish // POST /submissions/{SubmissionID}/status/validator-published
func (UnimplementedHandler) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error { func (UnimplementedHandler) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error {
return ht.ErrNotImplemented return ht.ErrNotImplemented
} }
@ -78,9 +78,9 @@ func (UnimplementedHandler) ActionSubmissionTriggerValidate(ctx context.Context,
// ActionSubmissionValidate implements actionSubmissionValidate operation. // ActionSubmissionValidate implements actionSubmissionValidate operation.
// //
// Role Validator changes status from Validating -> Validated. // (Internal endpoint) Role Validator changes status from Validating -> Validated.
// //
// POST /submissions/{SubmissionID}/status/validate // POST /submissions/{SubmissionID}/status/validator-validated
func (UnimplementedHandler) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error { func (UnimplementedHandler) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error {
return ht.ErrNotImplemented return ht.ErrNotImplemented
} }

View File

@ -66,9 +66,9 @@ pub type ReqwestError=reqwest::Error;
// there are lots of action endpoints and they all follow the same pattern // there are lots of action endpoints and they all follow the same pattern
macro_rules! action{ macro_rules! action{
($fname:ident,$action:ident)=>{ ($fname:ident,$action:expr)=>{
pub async fn $fname(&self,config:SubmissionID)->Result<(),Error>{ pub async fn $fname(&self,config:SubmissionID)->Result<(),Error>{
let url_raw=format!(concat!("{}/submissions/{}/status/",stringify!($action)),self.base_url,config.0); let url_raw=format!(concat!("{}/submissions/{}/status/",$action),self.base_url,config.0);
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?; let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
self.post(url).await.map_err(Error::Reqwest)? self.post(url).await.map_err(Error::Reqwest)?
@ -125,6 +125,6 @@ impl Context{
Ok(()) Ok(())
} }
action!(action_submission_validate,validate); action!(action_submission_validate,"validator-validated");
action!(action_submission_publish,publish); action!(action_submission_publish,"validator-published");
} }