feat(api): add candidate assessment attempt contract
This commit is contained in:
1 parent
6c86c4e559
commit
565ef8d4f5
100 files changed
+30314
-74
No files matched your search
@@ -21,6 +21,8 @@ var regexMap = map[string]ogenregex.Regexp{
|
||||
"^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"),
|
||||
"^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"),
|
||||
"^[A-Za-z0-9_-]+$": ogenregex.MustCompile("^[A-Za-z0-9_-]+$"),
|
||||
"^[a-z0-9_+-]+$": ogenregex.MustCompile("^[a-z0-9_+-]+$"),
|
||||
"^[a-z0-9_]+$": ogenregex.MustCompile("^[a-z0-9_]+$"),
|
||||
"^[a-z][a-z0-9_]*$": ogenregex.MustCompile("^[a-z][a-z0-9_]*$"),
|
||||
"^\\S(?:.*\\S)?$": ogenregex.MustCompile("^\\S(?:.*\\S)?$"),
|
||||
"^__Host-lincodex_session=": ogenregex.MustCompile("^__Host-lincodex_session="),
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,6 +5,14 @@ type ConfirmEmailRes interface {
|
||||
confirmEmailRes()
|
||||
}
|
||||
|
||||
type CreateMyAssessmentAttemptRes interface {
|
||||
createMyAssessmentAttemptRes()
|
||||
}
|
||||
|
||||
type FinalizeMyAssessmentAttemptRes interface {
|
||||
finalizeMyAssessmentAttemptRes()
|
||||
}
|
||||
|
||||
type GetConsentTextRes interface {
|
||||
getConsentTextRes()
|
||||
}
|
||||
@@ -17,6 +25,18 @@ type GetCurrentSessionRes interface {
|
||||
getCurrentSessionRes()
|
||||
}
|
||||
|
||||
type GetMyAssessmentAttemptRes interface {
|
||||
getMyAssessmentAttemptRes()
|
||||
}
|
||||
|
||||
type GetMyAssessmentAvailabilityRes interface {
|
||||
getMyAssessmentAvailabilityRes()
|
||||
}
|
||||
|
||||
type GetMyAssessmentResultRes interface {
|
||||
getMyAssessmentResultRes()
|
||||
}
|
||||
|
||||
type GetMyQuestionnaireRes interface {
|
||||
getMyQuestionnaireRes()
|
||||
}
|
||||
@@ -40,3 +60,7 @@ type ResendEmailVerificationRes interface {
|
||||
type SaveMyQuestionnaireRes interface {
|
||||
saveMyQuestionnaireRes()
|
||||
}
|
||||
|
||||
type SubmitMyAssessmentAnswerRes interface {
|
||||
submitMyAssessmentAnswerRes()
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -6,16 +6,22 @@ package api
|
||||
type OperationName = string
|
||||
|
||||
const (
|
||||
ConfirmEmailOperation OperationName = "ConfirmEmail"
|
||||
GetConsentTextOperation OperationName = "GetConsentText"
|
||||
GetCurrentAccountOperation OperationName = "GetCurrentAccount"
|
||||
GetCurrentSessionOperation OperationName = "GetCurrentSession"
|
||||
GetHealthzOperation OperationName = "GetHealthz"
|
||||
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
|
||||
GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog"
|
||||
LoginOperation OperationName = "Login"
|
||||
LogoutOperation OperationName = "Logout"
|
||||
RegisterAccountOperation OperationName = "RegisterAccount"
|
||||
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
|
||||
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
|
||||
ConfirmEmailOperation OperationName = "ConfirmEmail"
|
||||
CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt"
|
||||
FinalizeMyAssessmentAttemptOperation OperationName = "FinalizeMyAssessmentAttempt"
|
||||
GetConsentTextOperation OperationName = "GetConsentText"
|
||||
GetCurrentAccountOperation OperationName = "GetCurrentAccount"
|
||||
GetCurrentSessionOperation OperationName = "GetCurrentSession"
|
||||
GetHealthzOperation OperationName = "GetHealthz"
|
||||
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
|
||||
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
|
||||
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
|
||||
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
|
||||
GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog"
|
||||
LoginOperation OperationName = "Login"
|
||||
LogoutOperation OperationName = "Logout"
|
||||
RegisterAccountOperation OperationName = "RegisterAccount"
|
||||
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
|
||||
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
|
||||
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
|
||||
)
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/google/uuid"
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
@@ -14,6 +15,249 @@ import (
|
||||
"github.com/ogen-go/ogen/validate"
|
||||
)
|
||||
|
||||
// CreateMyAssessmentAttemptParams is parameters of CreateMyAssessmentAttempt operation.
|
||||
type CreateMyAssessmentAttemptParams struct {
|
||||
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
|
||||
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
|
||||
// request by method, path, and body.
|
||||
//
|
||||
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
|
||||
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
|
||||
// not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
//
|
||||
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
|
||||
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
|
||||
// precondition_required (nothing changed; read the resource again and retry), 422
|
||||
// idempotency_key_reused, 429, and every 5xx.
|
||||
//
|
||||
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
|
||||
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
|
||||
// before any other key check; a running request with the same fingerprint returns 409
|
||||
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
|
||||
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
|
||||
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
func unpackCreateMyAssessmentAttemptParams(packed middleware.Parameters) (params CreateMyAssessmentAttemptParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}
|
||||
params.IdempotencyKey = packed[key].(string)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeCreateMyAssessmentAttemptParams(args [0]string, argsEscaped bool, r *http.Request) (params CreateMyAssessmentAttemptParams, _ error) {
|
||||
h := uri.NewHeaderDecoder(r.Header)
|
||||
// Decode header: Idempotency-Key.
|
||||
if err := func() error {
|
||||
cfg := uri.HeaderParameterDecodingConfig{
|
||||
Name: "Idempotency-Key",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.HasParam(cfg); err == nil {
|
||||
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.IdempotencyKey = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 255,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(params.IdempotencyKey)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// FinalizeMyAssessmentAttemptParams is parameters of FinalizeMyAssessmentAttempt operation.
|
||||
type FinalizeMyAssessmentAttemptParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
|
||||
AttemptID uuid.UUID
|
||||
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
|
||||
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
|
||||
// request by method, path, and body.
|
||||
//
|
||||
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
|
||||
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
|
||||
// not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
//
|
||||
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
|
||||
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
|
||||
// precondition_required (nothing changed; read the resource again and retry), 422
|
||||
// idempotency_key_reused, 429, and every 5xx.
|
||||
//
|
||||
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
|
||||
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
|
||||
// before any other key check; a running request with the same fingerprint returns 409
|
||||
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
|
||||
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
|
||||
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
func unpackFinalizeMyAssessmentAttemptParams(packed middleware.Parameters) (params FinalizeMyAssessmentAttemptParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}
|
||||
params.AttemptID = packed[key].(uuid.UUID)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}
|
||||
params.IdempotencyKey = packed[key].(string)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeFinalizeMyAssessmentAttemptParams(args [1]string, argsEscaped bool, r *http.Request) (params FinalizeMyAssessmentAttemptParams, _ error) {
|
||||
h := uri.NewHeaderDecoder(r.Header)
|
||||
// Decode path: attempt_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "attempt_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.AttemptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode header: Idempotency-Key.
|
||||
if err := func() error {
|
||||
cfg := uri.HeaderParameterDecodingConfig{
|
||||
Name: "Idempotency-Key",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.HasParam(cfg); err == nil {
|
||||
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.IdempotencyKey = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 255,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(params.IdempotencyKey)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetConsentTextParams is parameters of GetConsentText operation.
|
||||
type GetConsentTextParams struct {
|
||||
// Consent whose text is requested.
|
||||
@@ -88,6 +332,140 @@ func decodeGetConsentTextParams(args [1]string, argsEscaped bool, r *http.Reques
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetMyAssessmentAttemptParams is parameters of GetMyAssessmentAttempt operation.
|
||||
type GetMyAssessmentAttemptParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
|
||||
AttemptID uuid.UUID
|
||||
}
|
||||
|
||||
func unpackGetMyAssessmentAttemptParams(packed middleware.Parameters) (params GetMyAssessmentAttemptParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}
|
||||
params.AttemptID = packed[key].(uuid.UUID)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeGetMyAssessmentAttemptParams(args [1]string, argsEscaped bool, r *http.Request) (params GetMyAssessmentAttemptParams, _ error) {
|
||||
// Decode path: attempt_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "attempt_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.AttemptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetMyAssessmentResultParams is parameters of GetMyAssessmentResult operation.
|
||||
type GetMyAssessmentResultParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
|
||||
AttemptID uuid.UUID
|
||||
}
|
||||
|
||||
func unpackGetMyAssessmentResultParams(packed middleware.Parameters) (params GetMyAssessmentResultParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}
|
||||
params.AttemptID = packed[key].(uuid.UUID)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeGetMyAssessmentResultParams(args [1]string, argsEscaped bool, r *http.Request) (params GetMyAssessmentResultParams, _ error) {
|
||||
// Decode path: attempt_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "attempt_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.AttemptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// RegisterAccountParams is parameters of RegisterAccount operation.
|
||||
type RegisterAccountParams struct {
|
||||
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
|
||||
@@ -181,3 +559,152 @@ func decodeRegisterAccountParams(args [0]string, argsEscaped bool, r *http.Reque
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentAnswerParams is parameters of SubmitMyAssessmentAnswer operation.
|
||||
type SubmitMyAssessmentAnswerParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
|
||||
AttemptID uuid.UUID
|
||||
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
|
||||
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
|
||||
// request by method, path, and body.
|
||||
//
|
||||
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
|
||||
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
|
||||
// not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
//
|
||||
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
|
||||
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
|
||||
// precondition_required (nothing changed; read the resource again and retry), 422
|
||||
// idempotency_key_reused, 429, and every 5xx.
|
||||
//
|
||||
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
|
||||
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
|
||||
// before any other key check; a running request with the same fingerprint returns 409
|
||||
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
|
||||
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
|
||||
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
func unpackSubmitMyAssessmentAnswerParams(packed middleware.Parameters) (params SubmitMyAssessmentAnswerParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}
|
||||
params.AttemptID = packed[key].(uuid.UUID)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}
|
||||
params.IdempotencyKey = packed[key].(string)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeSubmitMyAssessmentAnswerParams(args [1]string, argsEscaped bool, r *http.Request) (params SubmitMyAssessmentAnswerParams, _ error) {
|
||||
h := uri.NewHeaderDecoder(r.Header)
|
||||
// Decode path: attempt_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "attempt_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.AttemptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode header: Idempotency-Key.
|
||||
if err := func() error {
|
||||
cfg := uri.HeaderParameterDecodingConfig{
|
||||
Name: "Idempotency-Key",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.HasParam(cfg); err == nil {
|
||||
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.IdempotencyKey = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 255,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(params.IdempotencyKey)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
@@ -93,6 +93,164 @@ func (s *Server) decodeConfirmEmailRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) (
|
||||
req *AssessmentAttemptCreate,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request AssessmentAttemptCreate
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeFinalizeMyAssessmentAttemptRequest(r *http.Request) (
|
||||
req *AssessmentFinalization,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request AssessmentFinalization
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeLoginRequest(r *http.Request) (
|
||||
req *LoginRequest,
|
||||
rawBody []byte,
|
||||
@@ -408,3 +566,82 @@ func (s *Server) decodeSaveMyQuestionnaireRequest(r *http.Request) (
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSubmitMyAssessmentAnswerRequest(r *http.Request) (
|
||||
req *AssessmentAnswerSubmission,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request AssessmentAnswerSubmission
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,252 @@ func encodeConfirmEmailResponse(response ConfirmEmailRes, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
func encodeCreateMyAssessmentAttemptResponse(response CreateMyAssessmentAttemptRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(201)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *CreateMyAssessmentAttemptBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *CreateMyAssessmentAttemptUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *CreateMyAssessmentAttemptForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *CreateMyAssessmentAttemptConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *CreateMyAssessmentAttemptUnprocessableEntity:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(422)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *TooManyRequestsHeaders:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Retry-After" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Retry-After",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := response.RetryAfter.Get(); ok {
|
||||
return e.EncodeValue(conv.Int32ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Retry-After header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(429)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeFinalizeMyAssessmentAttemptResponse(response FinalizeMyAssessmentAttemptRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptPreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *FinalizeMyAssessmentAttemptUnprocessableEntity:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(422)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetConsentTextResponse(response GetConsentTextRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ConsentText:
|
||||
@@ -227,6 +473,219 @@ func encodeGetHealthzResponse(response *HealthResponse, w http.ResponseWriter, s
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeGetMyAssessmentAttemptResponse(response GetMyAssessmentAttemptRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentAttemptUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentAttemptForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentAttemptNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyAssessmentAvailabilityResponse(response GetMyAssessmentAvailabilityRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAvailabilityHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentAvailabilityUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentAvailabilityForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyAssessmentResultResponse(response GetMyAssessmentResultRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentResultHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentResultUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentResultForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentResultNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyAssessmentResultConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyQuestionnaireResponse(response GetMyQuestionnaireRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateQuestionnaireHeaders:
|
||||
@@ -742,6 +1201,157 @@ func encodeSaveMyQuestionnaireResponse(response SaveMyQuestionnaireRes, w http.R
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerPreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SubmitMyAssessmentAnswerUnprocessableEntity:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(422)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *TooManyRequestsHeaders:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Retry-After" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Retry-After",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := response.RetryAfter.Get(); ok {
|
||||
return e.EncodeValue(conv.Int32ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Retry-After header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(429)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeErrorResponse(response *ProblemStatusCode, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
code := response.StatusCode
|
||||
|
||||
@@ -11,22 +11,31 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
rn14AllowedHeaders = map[string]string{
|
||||
rn23AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn1AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn12AllowedHeaders = map[string]string{
|
||||
rn21AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key",
|
||||
}
|
||||
rn11AllowedHeaders = map[string]string{
|
||||
rn20AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn6AllowedHeaders = map[string]string{
|
||||
rn11AllowedHeaders = map[string]string{
|
||||
"DELETE": "X-Csrf-Token",
|
||||
}
|
||||
rn9AllowedHeaders = map[string]string{
|
||||
rn3AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn24AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn6AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn18AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
)
|
||||
@@ -183,7 +192,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn14AllowedHeaders,
|
||||
allowedHeaders: rn23AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -260,7 +269,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn12AllowedHeaders,
|
||||
allowedHeaders: rn21AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -284,7 +293,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn11AllowedHeaders,
|
||||
allowedHeaders: rn20AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -311,7 +320,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "DELETE,GET",
|
||||
allowedHeaders: rn6AllowedHeaders,
|
||||
allowedHeaders: rn11AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -324,31 +333,242 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
case 'm': // Prefix: "me/questionnaire"
|
||||
case 'm': // Prefix: "me/"
|
||||
|
||||
if l := len("me/questionnaire"); len(elem) >= l && elem[0:l] == "me/questionnaire" {
|
||||
if l := len("me/"); len(elem) >= l && elem[0:l] == "me/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyQuestionnaireRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleSaveMyQuestionnaireRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn9AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "assessment-a"
|
||||
|
||||
if l := len("assessment-a"); len(elem) >= l && elem[0:l] == "assessment-a" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 't': // Prefix: "ttempts"
|
||||
|
||||
if l := len("ttempts"); len(elem) >= l && elem[0:l] == "ttempts" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
s.handleCreateMyAssessmentAttemptRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn3AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "attempt_id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyAssessmentAttemptRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "answers"
|
||||
|
||||
if l := len("answers"); len(elem) >= l && elem[0:l] == "answers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
s.handleSubmitMyAssessmentAnswerRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn24AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'f': // Prefix: "finalize"
|
||||
|
||||
if l := len("finalize"); len(elem) >= l && elem[0:l] == "finalize" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
s.handleFinalizeMyAssessmentAttemptRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn6AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'r': // Prefix: "result"
|
||||
|
||||
if l := len("result"); len(elem) >= l && elem[0:l] == "result" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyAssessmentResultRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'v': // Prefix: "vailability"
|
||||
|
||||
if l := len("vailability"); len(elem) >= l && elem[0:l] == "vailability" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyAssessmentAvailabilityRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
|
||||
if l := len("questionnaire"); len(elem) >= l && elem[0:l] == "questionnaire" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyQuestionnaireRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleSaveMyQuestionnaireRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn18AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 's': // Prefix: "specializations"
|
||||
@@ -723,38 +943,241 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
|
||||
}
|
||||
|
||||
case 'm': // Prefix: "me/questionnaire"
|
||||
case 'm': // Prefix: "me/"
|
||||
|
||||
if l := len("me/questionnaire"); len(elem) >= l && elem[0:l] == "me/questionnaire" {
|
||||
if l := len("me/"); len(elem) >= l && elem[0:l] == "me/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyQuestionnaireOperation
|
||||
r.summary = "Read the questionnaire of the current candidate."
|
||||
r.operationID = "GetMyQuestionnaire"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/questionnaire"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = SaveMyQuestionnaireOperation
|
||||
r.summary = "Replace the questionnaire of the current candidate."
|
||||
r.operationID = "SaveMyQuestionnaire"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/questionnaire"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "assessment-a"
|
||||
|
||||
if l := len("assessment-a"); len(elem) >= l && elem[0:l] == "assessment-a" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 't': // Prefix: "ttempts"
|
||||
|
||||
if l := len("ttempts"); len(elem) >= l && elem[0:l] == "ttempts" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = CreateMyAssessmentAttemptOperation
|
||||
r.summary = "Start an assessment attempt for a category of the current candidate."
|
||||
r.operationID = "CreateMyAssessmentAttempt"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "attempt_id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyAssessmentAttemptOperation
|
||||
r.summary = "Read or resume an assessment attempt of the current candidate."
|
||||
r.operationID = "GetMyAssessmentAttempt"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "answers"
|
||||
|
||||
if l := len("answers"); len(elem) >= l && elem[0:l] == "answers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = SubmitMyAssessmentAnswerOperation
|
||||
r.summary = "Answer the current item or submit a practice of an assessment attempt."
|
||||
r.operationID = "SubmitMyAssessmentAnswer"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/answers"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'f': // Prefix: "finalize"
|
||||
|
||||
if l := len("finalize"); len(elem) >= l && elem[0:l] == "finalize" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = FinalizeMyAssessmentAttemptOperation
|
||||
r.summary = "Ask for the grade decision of an assessment attempt."
|
||||
r.operationID = "FinalizeMyAssessmentAttempt"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/finalize"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'r': // Prefix: "result"
|
||||
|
||||
if l := len("result"); len(elem) >= l && elem[0:l] == "result" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyAssessmentResultOperation
|
||||
r.summary = "Read the result of an assessment attempt of the current candidate."
|
||||
r.operationID = "GetMyAssessmentResult"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/result"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'v': // Prefix: "vailability"
|
||||
|
||||
if l := len("vailability"); len(elem) >= l && elem[0:l] == "vailability" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyAssessmentAvailabilityOperation
|
||||
r.summary = "Read which assessment attempts the current candidate can start."
|
||||
r.operationID = "GetMyAssessmentAvailability"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-availability"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
|
||||
if l := len("questionnaire"); len(elem) >= l && elem[0:l] == "questionnaire" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyQuestionnaireOperation
|
||||
r.summary = "Read the questionnaire of the current candidate."
|
||||
r.operationID = "GetMyQuestionnaire"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/questionnaire"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = SaveMyQuestionnaireOperation
|
||||
r.summary = "Replace the questionnaire of the current candidate."
|
||||
r.operationID = "SaveMyQuestionnaire"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/questionnaire"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 's': // Prefix: "specializations"
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -56,11 +56,17 @@ func findAuthorization(h http.Header, prefix string) (string, bool) {
|
||||
|
||||
// operationRolesSessionCookie is a private map storing roles per operation.
|
||||
var operationRolesSessionCookie = map[string][]string{
|
||||
GetCurrentAccountOperation: []string{},
|
||||
GetCurrentSessionOperation: []string{},
|
||||
GetMyQuestionnaireOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
CreateMyAssessmentAttemptOperation: []string{},
|
||||
FinalizeMyAssessmentAttemptOperation: []string{},
|
||||
GetCurrentAccountOperation: []string{},
|
||||
GetCurrentSessionOperation: []string{},
|
||||
GetMyAssessmentAttemptOperation: []string{},
|
||||
GetMyAssessmentAvailabilityOperation: []string{},
|
||||
GetMyAssessmentResultOperation: []string{},
|
||||
GetMyQuestionnaireOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
}
|
||||
|
||||
// GetRolesForSessionCookie returns the required roles for the given operation.
|
||||
@@ -86,8 +92,11 @@ func GetRolesForSessionCookie(operation string) []string {
|
||||
|
||||
// operationRolesSessionCsrf is a private map storing roles per operation.
|
||||
var operationRolesSessionCsrf = map[string][]string{
|
||||
LogoutOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
CreateMyAssessmentAttemptOperation: []string{},
|
||||
FinalizeMyAssessmentAttemptOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
}
|
||||
|
||||
// GetRolesForSessionCsrf returns the required roles for the given operation.
|
||||
|
||||
@@ -35,6 +35,91 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/identity/email-verifications
|
||||
ConfirmEmail(ctx context.Context, req *EmailVerificationRequest) (ConfirmEmailRes, error)
|
||||
// CreateMyAssessmentAttempt implements CreateMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. The body names the category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
// different body with the same key answers 422 idempotency_key_reused. 400 is never stored, so a
|
||||
// corrected retry is evaluated again.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), the Idempotency-Key (422, 409
|
||||
// idempotency_in_progress, replay), domain rules (400 with a pointer, for example `/specialization`
|
||||
// for a specialization that is not in the questionnaire or `/task_language` for a language that the
|
||||
// bank does not offer), then availability (409 state_conflict). The rate limit can answer 429 with
|
||||
// Retry-After before any of them; it is not stored.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts
|
||||
CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
|
||||
// FinalizeMyAssessmentAttempt implements FinalizeMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. Finalize always answers with the attempt, never with the
|
||||
// result: the decision may continue the attempt, and one response type keeps that unambiguous for
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
//
|
||||
// - `demo_basic` compares the raw score with the pass mark of the recorded basic grading policy and
|
||||
// completes the attempt. It never offers an additional practice.
|
||||
// - `adaptive` applies the probability bands of the recorded policy. Confirmation or rejection
|
||||
// completes the attempt. A probability in the band below confirmation (0.50 to below 0.80 in the
|
||||
// demo policy) on the first finalize, while time and sessions remain, completes nothing: the server
|
||||
// appends an `additional` practice, moves the attempt to `additional_practice_pending`, and answers
|
||||
// 200 with it. The additional practice continues the same attempt, keeps its limits, and spends no
|
||||
// new attempt. The next finalize, after its verdict, decides with the added evidence; a probability
|
||||
// still below confirmation gives `not_confirmed`. An attempt offers at most one additional
|
||||
// practice.
|
||||
// - Finalize in `additional_practice_pending` declines the offer and gives `not_confirmed` with the
|
||||
// current evidence. A retry of the first finalize with a new key cannot decline by accident: it
|
||||
// carries the version from before the offer and answers 412.
|
||||
//
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
// what is unfinished; the attempt shows it in `state`, `progress`, `current_item`, and `practices`. A
|
||||
// stale `expected_version` answers 412 version_conflict, the repository status for a stale version.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
FinalizeMyAssessmentAttempt(ctx context.Context, req *AssessmentFinalization, params FinalizeMyAssessmentAttemptParams) (FinalizeMyAssessmentAttemptRes, error)
|
||||
// GetConsentText implements GetConsentText operation.
|
||||
//
|
||||
// Public operation without a session. Returns the current text of a consent that is given before an
|
||||
@@ -71,6 +156,71 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/healthz
|
||||
GetHealthz(ctx context.Context) (*HealthResponse, error)
|
||||
// GetMyAssessmentAttempt implements GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
GetMyAssessmentAttempt(ctx context.Context, params GetMyAssessmentAttemptParams) (GetMyAssessmentAttemptRes, error)
|
||||
// GetMyAssessmentAvailability implements GetMyAssessmentAvailability operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account; the candidate comes from the session. For each
|
||||
// specialization of the questionnaire, returns the confirmed grade, the active attempt, and for every
|
||||
// grade whether an attempt can start now, in which mode, and with which limits: the time limit, the
|
||||
// session limit, the item limit, and whether a code practice is required. The client shows them before
|
||||
// the start, together with the method and the signals that are collected, and resumes an active
|
||||
// attempt by `active_attempt_id`, for example after it lost the response of CreateMyAssessmentAttempt.
|
||||
//
|
||||
// `insufficient_bank` is the state of a category whose bank is not published or has too few families
|
||||
// that this candidate has not seen; the server limits attempts instead of repeating families.
|
||||
// `cooldown` carries the date when the attempt opens, so the client can explain a blocked attempt with
|
||||
// that date and offer support. Specializations and their retry intervals are independent. Attempts
|
||||
// that ended as `insufficient_bank` or with the reason `sandbox_unavailable` are platform limitations
|
||||
// and never cause a `cooldown`.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/assessment-availability
|
||||
GetMyAssessmentAvailability(ctx context.Context) (GetMyAssessmentAvailabilityRes, error)
|
||||
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (GetMyAssessmentResultRes, error)
|
||||
// GetMyQuestionnaire implements GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -234,6 +384,63 @@ type Handler interface {
|
||||
//
|
||||
// PUT /api/v1/me/questionnaire
|
||||
SaveMyQuestionnaire(ctx context.Context, req *CandidateQuestionnaireUpdate) (SaveMyQuestionnaireRes, error)
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. The body names the item and carries the answer in the
|
||||
// format of that item: `choice`, `number`, `string`, `order`, `find_error`, `configuration`, or
|
||||
// `practice`. It never carries a score, a duration, or a correctness flag; the server records the
|
||||
// times itself and scores the answer with the key of the fixed item instance. Time never enters the
|
||||
// ability estimate or the grade decision.
|
||||
//
|
||||
// The response is the attempt with the next item to answer. It never says whether the answer was
|
||||
// correct. Items are answered in order and each answer is final.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
// Only the score 0-3 and the pass state of each group are shown, never the checks, error output, or
|
||||
// seeds. Every outcome caused by the solution, such as a compilation error, a crash, or a time or
|
||||
// memory limit, is a `finished` verdict. A `failed` verdict means only that the sandbox infrastructure
|
||||
// could not run it; it consumes nothing. After `finished` the practice accepts no other solution, so
|
||||
// hidden group results cannot be used to tune it. Debug runs of the candidate's own tests and the
|
||||
// public examples are unlimited apart from the sandbox rate limit and never show hidden group results;
|
||||
// they are planned as a separate operation.
|
||||
//
|
||||
// Repeats and conflicts, per item:
|
||||
//
|
||||
// - A retry with the same Idempotency-Key and body within 24 hours replays the stored response.
|
||||
// - Sending the answer already stored for the item again, even with a new key or an older
|
||||
// `expected_version`, stores nothing, keeps the version, and answers 200 with the current attempt.
|
||||
// Each answer format defines equality: sets for `option_ids` and `line_numbers`, the exact sequence
|
||||
// for `element_ids`, numeric equality for `number`, identical text without normalization for `text`
|
||||
// and `config`, and the same language with identical source for a practice.
|
||||
// - A different answer for an item that already has one answers 409 state_conflict when
|
||||
// `expected_version` is current; with a stale version the version check comes first and answers
|
||||
// 412.
|
||||
// - Exception for a practice whose latest verdict is `failed`: the repeat rule does not apply. A
|
||||
// submission with the same or a different solution, with the current `expected_version`, queues it
|
||||
// again and advances the version.
|
||||
//
|
||||
// Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the
|
||||
// server answers 412 version_conflict and stores nothing; the client reads the attempt again. 412 is
|
||||
// the repository status for a stale version, also used by SaveMyQuestionnaire; 409 state_conflict is
|
||||
// kept for commands that the attempt state does not allow at the current version.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error)
|
||||
// NewError creates *ProblemStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
|
||||
@@ -43,6 +43,97 @@ func (UnimplementedHandler) ConfirmEmail(ctx context.Context, req *EmailVerifica
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateMyAssessmentAttempt implements CreateMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. The body names the category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
// different body with the same key answers 422 idempotency_key_reused. 400 is never stored, so a
|
||||
// corrected retry is evaluated again.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), the Idempotency-Key (422, 409
|
||||
// idempotency_in_progress, replay), domain rules (400 with a pointer, for example `/specialization`
|
||||
// for a specialization that is not in the questionnaire or `/task_language` for a language that the
|
||||
// bank does not offer), then availability (409 state_conflict). The rate limit can answer 429 with
|
||||
// Retry-After before any of them; it is not stored.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts
|
||||
func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (r CreateMyAssessmentAttemptRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// FinalizeMyAssessmentAttempt implements FinalizeMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. Finalize always answers with the attempt, never with the
|
||||
// result: the decision may continue the attempt, and one response type keeps that unambiguous for
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
//
|
||||
// - `demo_basic` compares the raw score with the pass mark of the recorded basic grading policy and
|
||||
// completes the attempt. It never offers an additional practice.
|
||||
// - `adaptive` applies the probability bands of the recorded policy. Confirmation or rejection
|
||||
// completes the attempt. A probability in the band below confirmation (0.50 to below 0.80 in the
|
||||
// demo policy) on the first finalize, while time and sessions remain, completes nothing: the server
|
||||
// appends an `additional` practice, moves the attempt to `additional_practice_pending`, and answers
|
||||
// 200 with it. The additional practice continues the same attempt, keeps its limits, and spends no
|
||||
// new attempt. The next finalize, after its verdict, decides with the added evidence; a probability
|
||||
// still below confirmation gives `not_confirmed`. An attempt offers at most one additional
|
||||
// practice.
|
||||
// - Finalize in `additional_practice_pending` declines the offer and gives `not_confirmed` with the
|
||||
// current evidence. A retry of the first finalize with a new key cannot decline by accident: it
|
||||
// carries the version from before the offer and answers 412.
|
||||
//
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
// what is unfinished; the attempt shows it in `state`, `progress`, `current_item`, and `practices`. A
|
||||
// stale `expected_version` answers 412 version_conflict, the repository status for a stale version.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
func (UnimplementedHandler) FinalizeMyAssessmentAttempt(ctx context.Context, req *AssessmentFinalization, params FinalizeMyAssessmentAttemptParams) (r FinalizeMyAssessmentAttemptRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetConsentText implements GetConsentText operation.
|
||||
//
|
||||
// Public operation without a session. Returns the current text of a consent that is given before an
|
||||
@@ -91,6 +182,80 @@ func (UnimplementedHandler) GetHealthz(ctx context.Context) (r *HealthResponse,
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyAssessmentAttempt implements GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
func (UnimplementedHandler) GetMyAssessmentAttempt(ctx context.Context, params GetMyAssessmentAttemptParams) (r GetMyAssessmentAttemptRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyAssessmentAvailability implements GetMyAssessmentAvailability operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account; the candidate comes from the session. For each
|
||||
// specialization of the questionnaire, returns the confirmed grade, the active attempt, and for every
|
||||
// grade whether an attempt can start now, in which mode, and with which limits: the time limit, the
|
||||
// session limit, the item limit, and whether a code practice is required. The client shows them before
|
||||
// the start, together with the method and the signals that are collected, and resumes an active
|
||||
// attempt by `active_attempt_id`, for example after it lost the response of CreateMyAssessmentAttempt.
|
||||
//
|
||||
// `insufficient_bank` is the state of a category whose bank is not published or has too few families
|
||||
// that this candidate has not seen; the server limits attempts instead of repeating families.
|
||||
// `cooldown` carries the date when the attempt opens, so the client can explain a blocked attempt with
|
||||
// that date and offer support. Specializations and their retry intervals are independent. Attempts
|
||||
// that ended as `insufficient_bank` or with the reason `sandbox_unavailable` are platform limitations
|
||||
// and never cause a `cooldown`.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/assessment-availability
|
||||
func (UnimplementedHandler) GetMyAssessmentAvailability(ctx context.Context) (r GetMyAssessmentAvailabilityRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
func (UnimplementedHandler) GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (r GetMyAssessmentResultRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyQuestionnaire implements GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -275,6 +440,66 @@ func (UnimplementedHandler) SaveMyQuestionnaire(ctx context.Context, req *Candid
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// an allowed Origin, and an Idempotency-Key. The body names the item and carries the answer in the
|
||||
// format of that item: `choice`, `number`, `string`, `order`, `find_error`, `configuration`, or
|
||||
// `practice`. It never carries a score, a duration, or a correctness flag; the server records the
|
||||
// times itself and scores the answer with the key of the fixed item instance. Time never enters the
|
||||
// ability estimate or the grade decision.
|
||||
//
|
||||
// The response is the attempt with the next item to answer. It never says whether the answer was
|
||||
// correct. Items are answered in order and each answer is final.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
// Only the score 0-3 and the pass state of each group are shown, never the checks, error output, or
|
||||
// seeds. Every outcome caused by the solution, such as a compilation error, a crash, or a time or
|
||||
// memory limit, is a `finished` verdict. A `failed` verdict means only that the sandbox infrastructure
|
||||
// could not run it; it consumes nothing. After `finished` the practice accepts no other solution, so
|
||||
// hidden group results cannot be used to tune it. Debug runs of the candidate's own tests and the
|
||||
// public examples are unlimited apart from the sandbox rate limit and never show hidden group results;
|
||||
// they are planned as a separate operation.
|
||||
//
|
||||
// Repeats and conflicts, per item:
|
||||
//
|
||||
// - A retry with the same Idempotency-Key and body within 24 hours replays the stored response.
|
||||
// - Sending the answer already stored for the item again, even with a new key or an older
|
||||
// `expected_version`, stores nothing, keeps the version, and answers 200 with the current attempt.
|
||||
// Each answer format defines equality: sets for `option_ids` and `line_numbers`, the exact sequence
|
||||
// for `element_ids`, numeric equality for `number`, identical text without normalization for `text`
|
||||
// and `config`, and the same language with identical source for a practice.
|
||||
// - A different answer for an item that already has one answers 409 state_conflict when
|
||||
// `expected_version` is current; with a stale version the version check comes first and answers
|
||||
// 412.
|
||||
// - Exception for a practice whose latest verdict is `failed`: the repeat rule does not apply. A
|
||||
// submission with the same or a different solution, with the current `expected_version`, queues it
|
||||
// again and advances the version.
|
||||
//
|
||||
// Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the
|
||||
// server answers 412 version_conflict and stores nothing; the client reads the attempt again. 412 is
|
||||
// the repository status for a stale version, also used by SaveMyQuestionnaire; 409 state_conflict is
|
||||
// kept for commands that the attempt state does not allow at the current version.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (r SubmitMyAssessmentAnswerRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// NewError creates *ProblemStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user