From bc6faa76f692004fa3b84787326fcceae9df2e93 Mon Sep 17 00:00:00 2001 From: syui Date: Tue, 2 Apr 2024 19:08:29 +0900 Subject: [PATCH] response_enc --- ent/ogent/oas_parameters_gen.go | 10 +- ent/ogent/oas_response_encoders_gen.go | 452 ++++++++++++++++++++++++- ent/ogent/ogent.go | 91 +---- ent/openapi.json | 10 +- tmp/ogent/oas_response_encoders_gen.go | 452 ++++++++++++++++++++++++- 5 files changed, 928 insertions(+), 87 deletions(-) diff --git a/ent/ogent/oas_parameters_gen.go b/ent/ogent/oas_parameters_gen.go index 1b0ee32..6b53af1 100644 --- a/ent/ogent/oas_parameters_gen.go +++ b/ent/ogent/oas_parameters_gen.go @@ -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, diff --git a/ent/ogent/oas_response_encoders_gen.go b/ent/ogent/oas_response_encoders_gen.go index 737e256..645a4f5 100644 --- a/ent/ogent/oas_response_encoders_gen.go +++ b/ent/ogent/oas_response_encoders_gen.go @@ -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: diff --git a/ent/ogent/ogent.go b/ent/ogent/ogent.go index c3c4dc7..19130e1 100644 --- a/ent/ogent/ogent.go +++ b/ent/ogent/ogent.go @@ -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,16 +151,8 @@ 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) - } - } + if v, ok := req.Owner.Get(); ok { + b.SetOwnerID(v) } // Persist to storage. e, err := b.Save(ctx) @@ -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) - } + b.SetOwnerID(req.Owner) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -648,16 +624,8 @@ 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) - } - } + if v, ok := req.Owner.Get(); ok { + b.SetOwnerID(v) } // Persist to storage. e, err := b.Save(ctx) @@ -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) - } + b.SetOwnerID(req.Owner) // Persist to storage. e, err := b.Save(ctx) if err != nil { @@ -959,16 +921,8 @@ 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) - } - } + if v, ok := req.Owner.Get(); ok { + b.SetOwnerID(v) } // Persist to storage. e, err := b.Save(ctx) @@ -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("") - } + b.SetUsername(req.Username) 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): diff --git a/ent/openapi.json b/ent/openapi.json index d375483..e18fd1b 100644 --- a/ent/openapi.json +++ b/ent/openapi.json @@ -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 } } diff --git a/tmp/ogent/oas_response_encoders_gen.go b/tmp/ogent/oas_response_encoders_gen.go index 737e256..645a4f5 100644 --- a/tmp/ogent/oas_response_encoders_gen.go +++ b/tmp/ogent/oas_response_encoders_gen.go @@ -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: