-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwakeup.go
More file actions
32 lines (28 loc) · 826 Bytes
/
wakeup.go
File metadata and controls
32 lines (28 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package api
import (
"context"
"github.com/keboola/keboola-sdk-go/v2/pkg/request"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
type wakeupBody struct {
DesiredState string `json:"desiredState"`
}
func (a *API) WakeupApp(appID AppID) request.APIRequest[request.NoResult] {
return request.NewAPIRequest(request.NoResult{}, a.newRequest().
WithError(&Error{}).
WithOnError(func(ctx context.Context, response request.HTTPResponse, err error) error {
span := trace.SpanFromContext(ctx)
attrs := []attribute.KeyValue{
attribute.Int(attrSandboxesServiceStatusCode, response.StatusCode()),
}
span.SetAttributes(attrs...)
return err
}).
WithPatch("apps/{appId}").
AndPathParam("appId", appID.String()).
WithJSONBody(wakeupBody{
DesiredState: "running",
}),
)
}