1
0

response_enc

This commit is contained in:
syui 2024-04-02 19:08:29 +09:00
parent ef9f54ecfb
commit bc6faa76f6
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
5 changed files with 928 additions and 87 deletions

View File

@ -583,7 +583,7 @@ func decodeListCardParams(args [0]string, r *http.Request) (params ListCardParam
MinSet: true,
Min: 1,
MaxSet: true,
Max: 5000,
Max: 255,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
@ -748,7 +748,7 @@ func decodeListGroupParams(args [0]string, r *http.Request) (params ListGroupPar
MinSet: true,
Min: 1,
MaxSet: true,
Max: 5000,
Max: 255,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
@ -1080,7 +1080,7 @@ func decodeListMaParams(args [0]string, r *http.Request) (params ListMaParams, _
MinSet: true,
Min: 1,
MaxSet: true,
Max: 5000,
Max: 255,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
@ -1245,7 +1245,7 @@ func decodeListUeParams(args [0]string, r *http.Request) (params ListUeParams, _
MinSet: true,
Min: 1,
MaxSet: true,
Max: 5000,
Max: 255,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
@ -1410,7 +1410,7 @@ func decodeListUserParams(args [0]string, r *http.Request) (params ListUserParam
MinSet: true,
Min: 1,
MaxSet: true,
Max: 5000,
Max: 255,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,

View File

@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s
}
}
func encodeCreateMaResponse(response CreateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaCreate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeCreate:
@ -353,6 +408,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s
}
}
func encodeDeleteMaResponse(response DeleteMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteMaNoContent:
w.WriteHeader(204)
span.SetStatus(codes.Ok, http.StatusText(204))
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteUeNoContent:
@ -691,6 +807,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
}
}
func encodeListMaResponse(response ListMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUeOKApplicationJSON:
@ -894,6 +1077,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
}
}
func encodeListUserMaResponse(response ListUserMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserUeOKApplicationJSON:
@ -1164,6 +1414,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
}
}
func encodeReadMaResponse(response ReadMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeReadMaOwnerResponse(response ReadMaOwnerRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaOwnerRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeRead:
@ -1299,7 +1683,6 @@ func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, s
}
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *UserRead:
w.Header().Set("Content-Type", "application/json")
@ -1500,6 +1883,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s
}
}
func encodeUpdateMaResponse(response UpdateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaUpdate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeUpdate:

View File

@ -12,14 +12,10 @@ import (
"api/ent/ma"
"api/ent/ue"
"api/ent/user"
"os"
"github.com/go-faster/jx"
)
// origin-config
var password = os.Getenv("PASS")
var token = os.Getenv("TOKEN")
// OgentHandler implements the ogen generated Handler interface and uses Ent as data layer.
type OgentHandler struct {
client *ent.Client
@ -67,13 +63,8 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
if v, ok := req.CreatedAt.Get(); ok {
b.SetCreatedAt(v)
}
if req.Password == password {
b.SetOwnerID(req.Owner)
} else {
b.SetOwnerID(0)
}
// Add all edges.
//b.SetOwnerID(req.Owner)
b.SetOwnerID(req.Owner)
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -160,17 +151,9 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
b.SetAuthor(v)
}
// Add all edges.
//if v, ok := req.Owner.Get(); ok {
// b.SetOwnerID(v)
//}
if v, ok := req.Token.Get(); ok {
if v == token {
b.SetToken(v)
if v, ok := req.Owner.Get(); ok {
b.SetOwnerID(v)
}
}
}
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -204,8 +187,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
// DeleteCard handles DELETE /cards/{id} requests.
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Card.DeleteOneID(0).Exec(ctx)
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):
@ -401,8 +383,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par
// DeleteGroup handles DELETE /groups/{id} requests.
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
err := h.client.Group.DeleteOneID(0).Exec(ctx)
//err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):
@ -544,12 +525,7 @@ func (h *OgentHandler) CreateMa(ctx context.Context, req *CreateMaReq) (CreateMa
b.SetCreatedAt(v)
}
// Add all edges.
//b.SetOwnerID(req.Owner)
if req.Password == password {
b.SetOwnerID(req.Owner)
} else {
b.SetOwnerID(0)
}
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -648,17 +624,9 @@ func (h *OgentHandler) UpdateMa(ctx context.Context, req *UpdateMaReq, params Up
b.SetUpdatedAt(v)
}
// Add all edges.
//if v, ok := req.Owner.Get(); ok {
// b.SetOwnerID(v)
//}
if v, ok := req.Token.Get(); ok {
if v == token {
b.SetToken(v)
if v, ok := req.Owner.Get(); ok {
b.SetOwnerID(v)
}
}
}
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -692,8 +660,7 @@ func (h *OgentHandler) UpdateMa(ctx context.Context, req *UpdateMaReq, params Up
// DeleteMa handles DELETE /mas/{id} requests.
func (h *OgentHandler) DeleteMa(ctx context.Context, params DeleteMaParams) (DeleteMaRes, error) {
err := h.client.Ma.DeleteOneID(0).Exec(ctx)
//err := h.client.Ma.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Ma.DeleteOneID(params.ID).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):
@ -840,12 +807,7 @@ func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUe
b.SetCreatedAt(v)
}
// Add all edges.
//b.SetOwnerID(req.Owner)
if req.Password == password {
b.SetOwnerID(req.Owner)
} else {
b.SetOwnerID(0)
}
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -959,17 +921,9 @@ func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params Up
b.SetAuthor(v)
}
// Add all edges.
//if v, ok := req.Owner.Get(); ok {
// b.SetOwnerID(v)
//}
if v, ok := req.Token.Get(); ok {
if v == token {
b.SetToken(v)
if v, ok := req.Owner.Get(); ok {
b.SetOwnerID(v)
}
}
}
// Persist to storage.
e, err := b.Save(ctx)
if err != nil {
@ -1003,8 +957,7 @@ func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params Up
// DeleteUe handles DELETE /ues/{id} requests.
func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
//err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Ue.DeleteOneID(0).Exec(ctx)
err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):
@ -1095,12 +1048,7 @@ func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
b := h.client.User.Create()
// Add all fields.
//b.SetUsername(req.Username)
if req.Password == password {
b.SetUsername(req.Username)
} else {
b.SetUsername("")
}
if v, ok := req.Did.Get(); ok {
b.SetDid(v)
}
@ -1310,9 +1258,6 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea
// UpdateUser handles PATCH /users/{id} requests.
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
b := h.client.User.UpdateOneID(params.ID)
if v, ok := req.Token.Get(); ok {
if v == token {
// Add all fields.
if v, ok := req.Did.Get(); ok {
b.SetDid(v)
@ -1464,9 +1409,6 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
}
if req.Ma != nil {
b.ClearMa().AddMaIDs(req.Ma...)
}
b.SetToken(v)
}
}
// Persist to storage.
e, err := b.Save(ctx)
@ -1501,8 +1443,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
// DeleteUser handles DELETE /users/{id} requests.
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
err := h.client.User.DeleteOneID(0).Exec(ctx)
//err := h.client.User.DeleteOneID(params.ID).Exec(ctx)
err := h.client.User.DeleteOneID(params.ID).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):

View File

@ -30,7 +30,7 @@
"description": "item count to render per page",
"schema": {
"type": "integer",
"maximum": 5000,
"maximum": 255,
"minimum": 1
}
}
@ -402,7 +402,7 @@
"description": "item count to render per page",
"schema": {
"type": "integer",
"maximum": 5000,
"maximum": 255,
"minimum": 1
}
}
@ -728,7 +728,7 @@
"description": "item count to render per page",
"schema": {
"type": "integer",
"maximum": 5000,
"maximum": 255,
"minimum": 1
}
}
@ -1101,7 +1101,7 @@
"description": "item count to render per page",
"schema": {
"type": "integer",
"maximum": 5000,
"maximum": 255,
"minimum": 1
}
}
@ -1502,7 +1502,7 @@
"description": "item count to render per page",
"schema": {
"type": "integer",
"maximum": 5000,
"maximum": 255,
"minimum": 1
}
}

View File

@ -121,6 +121,61 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s
}
}
func encodeCreateMaResponse(response CreateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaCreate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeCreate:
@ -353,6 +408,67 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s
}
}
func encodeDeleteMaResponse(response DeleteMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteMaNoContent:
w.WriteHeader(204)
span.SetStatus(codes.Ok, http.StatusText(204))
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteUeNoContent:
@ -691,6 +807,73 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
}
}
func encodeListMaResponse(response ListMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUeOKApplicationJSON:
@ -894,6 +1077,73 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
}
}
func encodeListUserMaResponse(response ListUserMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserUeOKApplicationJSON:
@ -1164,6 +1414,140 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
}
}
func encodeReadMaResponse(response ReadMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeReadMaOwnerResponse(response ReadMaOwnerRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaOwnerRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeRead:
@ -1299,7 +1683,6 @@ func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, s
}
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *UserRead:
w.Header().Set("Content-Type", "application/json")
@ -1500,6 +1883,73 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s
}
}
func encodeUpdateMaResponse(response UpdateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaUpdate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
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 encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeUpdate: