-
Notifications
You must be signed in to change notification settings - Fork 4
/
rdev_profile.go
42 lines (31 loc) · 936 Bytes
/
rdev_profile.go
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
33
34
35
36
37
38
39
40
41
42
package component
import (
"net/http"
"bunnyshell.com/cli/pkg/api"
"bunnyshell.com/cli/pkg/api/common"
"bunnyshell.com/cli/pkg/lib"
"bunnyshell.com/sdk"
)
type RDevContextOptions struct {
common.ItemOptions
Profile any
}
func NewRDevContextOptions(id string) *RDevContextOptions {
return &RDevContextOptions{
ItemOptions: *common.NewItemOptions(id),
}
}
func RDevContext(options *RDevContextOptions) (*sdk.ComponentProfileItem, error) {
model, resp, err := RDevContextRaw(options)
if err != nil {
return nil, api.ParseError(resp, err)
}
return model, nil
}
func RDevContextRaw(options *RDevContextOptions) (*sdk.ComponentProfileItem, *http.Response, error) {
profile := options.GetProfile()
ctx, cancel := lib.GetContextFromProfile(profile)
defer cancel()
request := lib.GetAPIFromProfile(profile).ComponentAPI.ComponentRemoteDevProfile(ctx, options.ID)
return request.Body(options.Profile).Execute()
}