Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libs(Go): return response body for recover/replay #1392

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions go/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type (
EndpointTransformationOut = openapi.EndpointTransformationOut
EventExampleIn = openapi.EventExampleIn
Ordering = openapi.Ordering
RecoverOut = openapi.RecoverOut
ReplayOut = openapi.ReplayOut
)

type Endpoint struct {
Expand Down Expand Up @@ -150,23 +152,23 @@ func (e *Endpoint) RotateSecretWithOptions(ctx context.Context, appId string, en
return nil
}

func (e *Endpoint) Recover(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn) error {
func (e *Endpoint) Recover(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn) (*RecoverOut, error) {
return e.RecoverWithOptions(ctx, appId, endpointId, recoverIn, nil)
}

func (e *Endpoint) RecoverWithOptions(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn, options *PostOptions) error {
func (e *Endpoint) RecoverWithOptions(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn, options *PostOptions) (*RecoverOut, error) {
req := e.api.EndpointApi.V1EndpointRecover(ctx, appId, endpointId)
req = req.RecoverIn(openapi.RecoverIn(*recoverIn))
if options != nil {
if options.IdempotencyKey != nil {
req = req.IdempotencyKey(*options.IdempotencyKey)
}
}
_, res, err := req.Execute()
out, res, err := req.Execute()
if err != nil {
return wrapError(err, res)
return nil, wrapError(err, res)
}
return nil
return &out, nil
}

func (e *Endpoint) GetHeaders(ctx context.Context, appId string, endpointId string) (*EndpointHeadersOut, error) {
Expand Down Expand Up @@ -219,7 +221,7 @@ func (e *Endpoint) GetStatsWithOptions(ctx context.Context, appId string, endpoi
return &ret, nil
}

func (e *Endpoint) ReplayMissing(ctx context.Context, appId string, endpointId string, replayIn *ReplayIn) error {
func (e *Endpoint) ReplayMissing(ctx context.Context, appId string, endpointId string, replayIn *ReplayIn) (*ReplayOut, error) {
return e.ReplayMissingWithOptions(ctx, appId, endpointId, replayIn, nil)
}

Expand All @@ -229,19 +231,19 @@ func (e *Endpoint) ReplayMissingWithOptions(
endpointId string,
replayIn *ReplayIn,
options *PostOptions,
) error {
) (*ReplayOut, error) {
req := e.api.EndpointApi.V1EndpointReplay(ctx, appId, endpointId)
req.ReplayIn(openapi.ReplayIn(*replayIn))
if options != nil {
if options.IdempotencyKey != nil {
req = req.IdempotencyKey(*options.IdempotencyKey)
}
}
_, res, err := req.Execute()
out, res, err := req.Execute()
if err != nil {
return wrapError(err, res)
return nil, wrapError(err, res)
}
return nil
return &out, nil
}

func (e *Endpoint) TransformationGet(ctx context.Context, appId string, endpointId string) (*EndpointTransformationOut, error) {
Expand Down