-
Notifications
You must be signed in to change notification settings - Fork 151
/
custom_endpoint.go
47 lines (40 loc) · 1.41 KB
/
custom_endpoint.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
43
44
45
46
47
package inference
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
inference "github.com/scaleway/scaleway-sdk-go/api/inference/v1beta1"
)
func endpointCreateBuilder(c *core.Command) *core.Command {
type llmInferenceEndpointSpecCustom struct {
*inference.EndpointSpec
IsPublic bool `json:"is-public"`
}
type createEndpointRequestCustom struct {
*inference.CreateEndpointRequest
Endpoint *llmInferenceEndpointSpecCustom `json:"endpoint"`
}
c.ArgSpecs.AddBefore("endpoint.private-network.private-network-id", &core.ArgSpec{
Name: "endpoint.is-public",
Short: "Will configure your public endpoint if true",
Required: false,
Default: core.DefaultValueSetter("false"),
})
c.ArgsType = reflect.TypeOf(createEndpointRequestCustom{})
c.Interceptor = func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) {
createEndpointCustomRequest := argsI.(*createEndpointRequestCustom)
createEndpointreq := createEndpointCustomRequest.CreateEndpointRequest
endpoint := createEndpointCustomRequest.Endpoint
if endpoint.IsPublic {
publicEndpoint := &inference.EndpointSpecPublic{}
endpointToCreate := inference.EndpointSpec{
Public: publicEndpoint,
PrivateNetwork: nil,
DisableAuth: endpoint.DisableAuth,
}
createEndpointreq.Endpoint = &endpointToCreate
}
return runner(ctx, createEndpointreq)
}
return c
}