Skip to content

Commit 16ea79c

Browse files
feat: update generated apis (#182)
- feat: add status to test service
1 parent 3591ab1 commit 16ea79c

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

api/test/v1/test_sdk.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,40 @@ func (enum *EyeColors) UnmarshalJSON(data []byte) error {
9494
return nil
9595
}
9696

97+
type HumanStatus string
98+
99+
const (
100+
// HumanStatusUnknown is [insert doc].
101+
HumanStatusUnknown = HumanStatus("unknown")
102+
// HumanStatusStopped is [insert doc].
103+
HumanStatusStopped = HumanStatus("stopped")
104+
// HumanStatusRunning is [insert doc].
105+
HumanStatusRunning = HumanStatus("running")
106+
)
107+
108+
func (enum HumanStatus) String() string {
109+
if enum == "" {
110+
// return default value if empty
111+
return "unknown"
112+
}
113+
return string(enum)
114+
}
115+
116+
func (enum HumanStatus) MarshalJSON() ([]byte, error) {
117+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
118+
}
119+
120+
func (enum *HumanStatus) UnmarshalJSON(data []byte) error {
121+
tmp := ""
122+
123+
if err := json.Unmarshal(data, &tmp); err != nil {
124+
return err
125+
}
126+
127+
*enum = HumanStatus(HumanStatus(tmp).String())
128+
return nil
129+
}
130+
97131
type ListHumansRequestOrderBy string
98132

99133
const (
@@ -160,6 +194,10 @@ type Human struct {
160194
//
161195
// Default value: unknown
162196
EyesColor EyeColors `json:"eyes_color"`
197+
// Status
198+
//
199+
// Default value: unknown
200+
Status HumanStatus `json:"status"`
163201

164202
Region scw.Region `json:"region"`
165203
}
@@ -486,3 +524,40 @@ func (s *API) DeleteHuman(req *DeleteHumanRequest, opts ...scw.RequestOption) (*
486524
}
487525
return &resp, nil
488526
}
527+
528+
type RunHumanRequest struct {
529+
Region scw.Region `json:"-"`
530+
531+
HumanID string `json:"-"`
532+
}
533+
534+
func (s *API) RunHuman(req *RunHumanRequest, opts ...scw.RequestOption) (*Human, error) {
535+
var err error
536+
537+
if req.Region == "" {
538+
defaultRegion, _ := s.client.GetDefaultRegion()
539+
req.Region = defaultRegion
540+
}
541+
542+
if fmt.Sprint(req.Region) == "" {
543+
return nil, errors.New("field Region cannot be empty in request")
544+
}
545+
546+
if fmt.Sprint(req.HumanID) == "" {
547+
return nil, errors.New("field HumanID cannot be empty in request")
548+
}
549+
550+
scwReq := &scw.ScalewayRequest{
551+
Method: "POST",
552+
Path: "/test/v1/regions/" + fmt.Sprint(req.Region) + "/humans/" + fmt.Sprint(req.HumanID) + "/run",
553+
Headers: http.Header{},
554+
}
555+
556+
var resp Human
557+
558+
err = s.client.Do(scwReq, &resp, opts...)
559+
if err != nil {
560+
return nil, err
561+
}
562+
return &resp, nil
563+
}

0 commit comments

Comments
 (0)