1
0
api/ent/ogent/oas_client_gen.go

2460 lines
57 KiB
Go
Raw Normal View History

2022-08-31 06:18:14 +00:00
// Code generated by ogen, DO NOT EDIT.
package ogent
import (
"context"
"net/url"
"time"
"github.com/go-faster/errors"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
2022-08-31 07:49:08 +00:00
"github.com/ogen-go/ogen/conv"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/otelogen"
"github.com/ogen-go/ogen/uri"
2022-08-31 06:18:14 +00:00
)
// Client implements OAS client.
type Client struct {
serverURL *url.URL
2022-08-31 07:49:08 +00:00
baseClient
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
var _ Handler = struct {
*Client
}{}
2022-08-31 06:18:14 +00:00
// NewClient initializes new Client defined by OAS.
2022-08-31 07:49:08 +00:00
func NewClient(serverURL string, opts ...ClientOption) (*Client, error) {
2022-08-31 06:18:14 +00:00
u, err := url.Parse(serverURL)
if err != nil {
return nil, err
}
2022-08-31 07:49:08 +00:00
c, err := newClientConfig(opts...).baseClient()
if err != nil {
2022-08-31 06:18:14 +00:00
return nil, err
}
2022-08-31 07:49:08 +00:00
return &Client{
serverURL: u,
baseClient: c,
}, nil
}
type serverURLKey struct{}
// WithServerURL sets context key to override server URL.
func WithServerURL(ctx context.Context, u *url.URL) context.Context {
return context.WithValue(ctx, serverURLKey{}, u)
}
func (c *Client) requestURL(ctx context.Context) *url.URL {
u, ok := ctx.Value(serverURLKey{}).(*url.URL)
if !ok {
return c.serverURL
}
return u
}
// CreateCard invokes createCard operation.
//
// Creates a new Card and persists it to storage.
//
// POST /cards
func (c *Client) CreateCard(ctx context.Context, request *CreateCardReq) (CreateCardRes, error) {
res, err := c.sendCreateCard(ctx, request)
_ = res
return res, err
}
func (c *Client) sendCreateCard(ctx context.Context, request *CreateCardReq) (res CreateCardRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createCard"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CreateCard",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCreateCardRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCreateCardResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CreateGroup invokes createGroup operation.
//
// Creates a new Group and persists it to storage.
//
// POST /groups
func (c *Client) CreateGroup(ctx context.Context, request *CreateGroupReq) (CreateGroupRes, error) {
res, err := c.sendCreateGroup(ctx, request)
_ = res
return res, err
}
func (c *Client) sendCreateGroup(ctx context.Context, request *CreateGroupReq) (res CreateGroupRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createGroup"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CreateGroup",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCreateGroupRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCreateGroupResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// CreateUe invokes createUe operation.
//
// Creates a new Ue and persists it to storage.
//
// POST /ues
func (c *Client) CreateUe(ctx context.Context, request *CreateUeReq) (CreateUeRes, error) {
res, err := c.sendCreateUe(ctx, request)
_ = res
return res, err
}
func (c *Client) sendCreateUe(ctx context.Context, request *CreateUeReq) (res CreateUeRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createUe"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CreateUe",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/ues"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCreateUeRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCreateUeResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// CreateUser invokes createUser operation.
//
// Creates a new User and persists it to storage.
//
// POST /users
func (c *Client) CreateUser(ctx context.Context, request *CreateUserReq) (CreateUserRes, error) {
res, err := c.sendCreateUser(ctx, request)
_ = res
return res, err
}
func (c *Client) sendCreateUser(ctx context.Context, request *CreateUserReq) (res CreateUserRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createUser"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CreateUser",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/users"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCreateUserRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCreateUserResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// DeleteCard invokes deleteCard operation.
//
// Deletes the Card with the requested ID.
//
// DELETE /cards/{id}
func (c *Client) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
res, err := c.sendDeleteCard(ctx, params)
_ = res
return res, err
}
func (c *Client) sendDeleteCard(ctx context.Context, params DeleteCardParams) (res DeleteCardRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteCard"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DeleteCard",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "DELETE", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDeleteCardResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// DeleteGroup invokes deleteGroup operation.
//
// Deletes the Group with the requested ID.
//
// DELETE /groups/{id}
func (c *Client) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
res, err := c.sendDeleteGroup(ctx, params)
_ = res
return res, err
}
func (c *Client) sendDeleteGroup(ctx context.Context, params DeleteGroupParams) (res DeleteGroupRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteGroup"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DeleteGroup",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "DELETE", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDeleteGroupResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// DeleteUe invokes deleteUe operation.
//
// Deletes the Ue with the requested ID.
//
// DELETE /ues/{id}
func (c *Client) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
res, err := c.sendDeleteUe(ctx, params)
_ = res
return res, err
}
func (c *Client) sendDeleteUe(ctx context.Context, params DeleteUeParams) (res DeleteUeRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteUe"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DeleteUe",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/ues/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "DELETE", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDeleteUeResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// DeleteUser invokes deleteUser operation.
//
// Deletes the User with the requested ID.
//
// DELETE /users/{id}
func (c *Client) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
res, err := c.sendDeleteUser(ctx, params)
_ = res
return res, err
}
func (c *Client) sendDeleteUser(ctx context.Context, params DeleteUserParams) (res DeleteUserRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteUser"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DeleteUser",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/users/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "DELETE", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDeleteUserResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// DrawDone invokes drawDone operation.
//
// Draws a card item as done.
//
// PUT /cards/{id}/d
func (c *Client) DrawDone(ctx context.Context, params DrawDoneParams) error {
res, err := c.sendDrawDone(ctx, params)
_ = res
return err
}
func (c *Client) sendDrawDone(ctx context.Context, params DrawDoneParams) (res *DrawDoneNoContent, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("drawDone"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DrawDone",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
u.Path += "/d"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PUT", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDrawDoneResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// DrawStart invokes drawStart operation.
//
// Draws a card item as done.
//
// PATCH /users/{id}/card/start
func (c *Client) DrawStart(ctx context.Context, params DrawStartParams) error {
res, err := c.sendDrawStart(ctx, params)
_ = res
return err
}
func (c *Client) sendDrawStart(ctx context.Context, params DrawStartParams) (res *DrawStartNoContent, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("drawStart"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "DrawStart",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/users/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
u.Path += "/card/start"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeDrawStartResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ListCard invokes listCard operation.
//
// List Cards.
//
// GET /cards
func (c *Client) ListCard(ctx context.Context, params ListCardParams) (ListCardRes, error) {
res, err := c.sendListCard(ctx, params)
_ = res
return res, err
}
func (c *Client) sendListCard(ctx context.Context, params ListCardParams) (res ListCardRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listCard"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ListCard",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards"
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeListCardResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ListGroup invokes listGroup operation.
//
// List Groups.
//
// GET /groups
func (c *Client) ListGroup(ctx context.Context, params ListGroupParams) (ListGroupRes, error) {
res, err := c.sendListGroup(ctx, params)
_ = res
return res, err
}
func (c *Client) sendListGroup(ctx context.Context, params ListGroupParams) (res ListGroupRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listGroup"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ListGroup",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups"
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeListGroupResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ListGroupUsers invokes listGroupUsers operation.
//
// List attached Users.
//
// GET /groups/{id}/users
func (c *Client) ListGroupUsers(ctx context.Context, params ListGroupUsersParams) (ListGroupUsersRes, error) {
res, err := c.sendListGroupUsers(ctx, params)
_ = res
return res, err
}
func (c *Client) sendListGroupUsers(ctx context.Context, params ListGroupUsersParams) (res ListGroupUsersRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listGroupUsers"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ListGroupUsers",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
u.Path += "/users"
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeListGroupUsersResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// ListUe invokes listUe operation.
2022-08-31 07:49:08 +00:00
//
2024-02-03 06:48:28 +00:00
// List Ues.
2022-08-31 07:49:08 +00:00
//
2024-02-03 06:48:28 +00:00
// GET /ues
func (c *Client) ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error) {
res, err := c.sendListUe(ctx, params)
2022-08-31 07:49:08 +00:00
_ = res
return res, err
}
2024-02-03 06:48:28 +00:00
func (c *Client) sendListUe(ctx context.Context, params ListUeParams) (res ListUeRes, err error) {
2022-08-31 07:49:08 +00:00
otelAttrs := []attribute.KeyValue{
2024-02-03 06:48:28 +00:00
otelogen.OperationID("listUe"),
2022-08-31 07:49:08 +00:00
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
2024-02-03 06:48:28 +00:00
ctx, span := c.cfg.Tracer.Start(ctx, "ListUe",
2022-08-31 07:49:08 +00:00
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
2024-02-03 06:48:28 +00:00
u.Path += "/ues"
2022-08-31 07:49:08 +00:00
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
defer resp.Body.Close()
stage = "DecodeResponse"
2024-02-03 06:48:28 +00:00
result, err := decodeListUeResponse(resp)
2022-08-31 07:49:08 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
return result, nil
2022-08-31 06:18:14 +00:00
}
2024-02-03 06:48:28 +00:00
// ListUser invokes listUser operation.
2022-08-31 06:18:14 +00:00
//
2024-02-03 06:48:28 +00:00
// List Users.
2022-08-31 06:18:14 +00:00
//
2024-02-03 06:48:28 +00:00
// GET /users
func (c *Client) ListUser(ctx context.Context, params ListUserParams) (ListUserRes, error) {
res, err := c.sendListUser(ctx, params)
2022-08-31 07:49:08 +00:00
_ = res
return res, err
}
2024-02-03 06:48:28 +00:00
func (c *Client) sendListUser(ctx context.Context, params ListUserParams) (res ListUserRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2024-02-03 06:48:28 +00:00
otelogen.OperationID("listUser"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
2024-02-03 06:48:28 +00:00
ctx, span := c.cfg.Tracer.Start(ctx, "ListUser",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
2024-02-03 06:48:28 +00:00
u.Path += "/users"
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
2024-02-03 06:48:28 +00:00
result, err := decodeListUserResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// ListUserCard invokes listUserCard operation.
2022-08-31 06:18:14 +00:00
//
2024-02-03 06:48:28 +00:00
// List attached Cards.
2022-08-31 06:18:14 +00:00
//
2024-02-03 06:48:28 +00:00
// GET /users/{id}/card
func (c *Client) ListUserCard(ctx context.Context, params ListUserCardParams) (ListUserCardRes, error) {
res, err := c.sendListUserCard(ctx, params)
2022-08-31 07:49:08 +00:00
_ = res
return res, err
}
2024-02-03 06:48:28 +00:00
func (c *Client) sendListUserCard(ctx context.Context, params ListUserCardParams) (res ListUserCardRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2024-02-03 06:48:28 +00:00
otelogen.OperationID("listUserCard"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
2024-02-03 06:48:28 +00:00
ctx, span := c.cfg.Tracer.Start(ctx, "ListUserCard",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
2024-02-03 06:48:28 +00:00
u.Path += "/users/"
2022-08-31 06:18:14 +00:00
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
2024-02-03 06:48:28 +00:00
u.Path += "/card"
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
2024-02-03 06:48:28 +00:00
result, err := decodeListUserCardResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// ListUserUe invokes listUserUe operation.
2022-08-31 06:18:14 +00:00
//
2024-02-03 06:48:28 +00:00
// List attached Ues.
2022-08-31 07:49:08 +00:00
//
2024-02-03 06:48:28 +00:00
// GET /users/{id}/ue
func (c *Client) ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error) {
res, err := c.sendListUserUe(ctx, params)
2022-08-31 07:49:08 +00:00
_ = res
return res, err
}
2024-02-03 06:48:28 +00:00
func (c *Client) sendListUserUe(ctx context.Context, params ListUserUeParams) (res ListUserUeRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2024-02-03 06:48:28 +00:00
otelogen.OperationID("listUserUe"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
2024-02-03 06:48:28 +00:00
ctx, span := c.cfg.Tracer.Start(ctx, "ListUserUe",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
2024-02-03 06:48:28 +00:00
u.Path += "/users/"
2022-08-31 06:18:14 +00:00
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
2024-02-03 06:48:28 +00:00
u.Path += "/ue"
2022-08-31 06:18:14 +00:00
2024-02-03 06:48:28 +00:00
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Page.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "itemsPerPage" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "itemsPerPage",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ItemsPerPage.Get(); ok {
return e.EncodeValue(conv.IntToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeListUserUeResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ReadCard invokes readCard operation.
//
// Finds the Card with the requested ID and returns it.
//
// GET /cards/{id}
func (c *Client) ReadCard(ctx context.Context, params ReadCardParams) (ReadCardRes, error) {
res, err := c.sendReadCard(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadCard(ctx context.Context, params ReadCardParams) (res ReadCardRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readCard"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadCard",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeReadCardResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ReadCardOwner invokes readCardOwner operation.
//
// Find the attached User of the Card with the given ID.
//
// GET /cards/{id}/owner
func (c *Client) ReadCardOwner(ctx context.Context, params ReadCardOwnerParams) (ReadCardOwnerRes, error) {
res, err := c.sendReadCardOwner(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadCardOwner(ctx context.Context, params ReadCardOwnerParams) (res ReadCardOwnerRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readCardOwner"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadCardOwner",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
u.Path += "/owner"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
2022-08-31 06:18:14 +00:00
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
result, err := decodeReadCardOwnerResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// ReadGroup invokes readGroup operation.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// Finds the Group with the requested ID and returns it.
//
// GET /groups/{id}
func (c *Client) ReadGroup(ctx context.Context, params ReadGroupParams) (ReadGroupRes, error) {
res, err := c.sendReadGroup(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadGroup(ctx context.Context, params ReadGroupParams) (res ReadGroupRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2022-08-31 07:49:08 +00:00
otelogen.OperationID("readGroup"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadGroup",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups/"
2022-08-31 06:18:14 +00:00
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
result, err := decodeReadGroupResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// ReadUe invokes readUe operation.
//
// Finds the Ue with the requested ID and returns it.
//
// GET /ues/{id}
func (c *Client) ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error) {
res, err := c.sendReadUe(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadUe(ctx context.Context, params ReadUeParams) (res ReadUeRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readUe"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadUe",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/ues/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeReadUeResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// ReadUeOwner invokes readUeOwner operation.
//
// Find the attached User of the Ue with the given ID.
//
// GET /ues/{id}/owner
func (c *Client) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error) {
res, err := c.sendReadUeOwner(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (res ReadUeOwnerRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readUeOwner"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadUeOwner",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/ues/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
u.Path += "/owner"
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeReadUeOwnerResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// ReadUser invokes readUser operation.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// Finds the User with the requested ID and returns it.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// GET /users/{id}
func (c *Client) ReadUser(ctx context.Context, params ReadUserParams) (ReadUserRes, error) {
res, err := c.sendReadUser(ctx, params)
_ = res
return res, err
}
func (c *Client) sendReadUser(ctx context.Context, params ReadUserParams) (res ReadUserRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2022-08-31 07:49:08 +00:00
otelogen.OperationID("readUser"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "ReadUser",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/users/"
2022-08-31 06:18:14 +00:00
{
2022-08-31 07:49:08 +00:00
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
2022-08-31 06:18:14 +00:00
})
if err := func() error {
2022-08-31 07:49:08 +00:00
return e.EncodeValue(conv.IntToString(params.ID))
2022-08-31 06:18:14 +00:00
}(); err != nil {
2022-08-31 07:49:08 +00:00
return res, errors.Wrap(err, "encode path")
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
u.Path += e.Result()
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeReadUserResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// UpdateCard invokes updateCard operation.
//
// Updates a Card and persists changes to storage.
//
// PATCH /cards/{id}
func (c *Client) UpdateCard(ctx context.Context, request *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
res, err := c.sendUpdateCard(ctx, request, params)
_ = res
return res, err
}
func (c *Client) sendUpdateCard(ctx context.Context, request *UpdateCardReq, params UpdateCardParams) (res UpdateCardRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateCard"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "UpdateCard",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/cards/"
2022-08-31 06:18:14 +00:00
{
2022-08-31 07:49:08 +00:00
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
2022-08-31 06:18:14 +00:00
})
if err := func() error {
2022-08-31 07:49:08 +00:00
return e.EncodeValue(conv.IntToString(params.ID))
2022-08-31 06:18:14 +00:00
}(); err != nil {
2022-08-31 07:49:08 +00:00
return res, errors.Wrap(err, "encode path")
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
u.Path += e.Result()
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeUpdateCardRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
result, err := decodeUpdateCardResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// UpdateGroup invokes updateGroup operation.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// Updates a Group and persists changes to storage.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// PATCH /groups/{id}
func (c *Client) UpdateGroup(ctx context.Context, request *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) {
res, err := c.sendUpdateGroup(ctx, request, params)
_ = res
return res, err
}
func (c *Client) sendUpdateGroup(ctx context.Context, request *UpdateGroupReq, params UpdateGroupParams) (res UpdateGroupRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2022-08-31 07:49:08 +00:00
otelogen.OperationID("updateGroup"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "UpdateGroup",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/groups/"
2022-08-31 06:18:14 +00:00
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeUpdateGroupRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
result, err := decodeUpdateGroupResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2024-02-03 06:48:28 +00:00
// UpdateUe invokes updateUe operation.
//
// Updates a Ue and persists changes to storage.
//
// PATCH /ues/{id}
func (c *Client) UpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error) {
res, err := c.sendUpdateUe(ctx, request, params)
_ = res
return res, err
}
func (c *Client) sendUpdateUe(ctx context.Context, request *UpdateUeReq, params UpdateUeParams) (res UpdateUeRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateUe"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "UpdateUe",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
u.Path += "/ues/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeUpdateUeRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeUpdateUeResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
2022-08-31 07:49:08 +00:00
// UpdateUser invokes updateUser operation.
2022-08-31 06:18:14 +00:00
//
2022-08-31 07:49:08 +00:00
// Updates a User and persists changes to storage.
2022-08-31 06:18:14 +00:00
//
// PATCH /users/{id}
2022-08-31 07:49:08 +00:00
func (c *Client) UpdateUser(ctx context.Context, request *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
res, err := c.sendUpdateUser(ctx, request, params)
_ = res
return res, err
}
func (c *Client) sendUpdateUser(ctx context.Context, request *UpdateUserReq, params UpdateUserParams) (res UpdateUserRes, err error) {
2022-08-31 06:18:14 +00:00
otelAttrs := []attribute.KeyValue{
2022-08-31 07:49:08 +00:00
otelogen.OperationID("updateUser"),
2022-08-31 06:18:14 +00:00
}
2022-08-31 07:49:08 +00:00
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "UpdateUser",
2022-08-31 06:18:14 +00:00
trace.WithAttributes(otelAttrs...),
2022-08-31 07:49:08 +00:00
clientSpanKind,
2022-08-31 06:18:14 +00:00
)
2022-08-31 07:49:08 +00:00
// Track stage for error reporting.
var stage string
2022-08-31 06:18:14 +00:00
defer func() {
if err != nil {
span.RecordError(err)
2022-08-31 07:49:08 +00:00
span.SetStatus(codes.Error, stage)
2022-08-31 06:18:14 +00:00
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
2022-08-31 07:49:08 +00:00
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
2022-08-31 06:18:14 +00:00
u.Path += "/users/"
{
// Encode "id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.ID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
u.Path += e.Result()
}
2022-08-31 07:49:08 +00:00
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeUpdateUserRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
2022-08-31 06:18:14 +00:00
2022-08-31 07:49:08 +00:00
stage = "SendRequest"
2022-08-31 06:18:14 +00:00
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
2022-08-31 07:49:08 +00:00
stage = "DecodeResponse"
result, err := decodeUpdateUserResponse(resp)
2022-08-31 06:18:14 +00:00
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}