-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinspect.go
More file actions
263 lines (232 loc) · 8.72 KB
/
inspect.go
File metadata and controls
263 lines (232 loc) · 8.72 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
//
// This source code is licensed under the terms described in the LICENSE file in
// the root directory of this source tree.
//
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package llamastackclient
import (
"context"
"encoding/json"
"net/http"
"slices"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
"github.com/llamastack/llama-stack-client-go/internal/requestconfig"
"github.com/llamastack/llama-stack-client-go/option"
"github.com/llamastack/llama-stack-client-go/packages/respjson"
)
// InspectService contains methods and other services that help with interacting
// with the llama-stack-client API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewInspectService] method instead.
type InspectService struct {
Options []option.RequestOption
}
// NewInspectService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewInspectService(opts ...option.RequestOption) (r InspectService) {
r = InspectService{}
r.Options = opts
return
}
// Get health status. Get the current health status of the service.
func (r *InspectService) Health(ctx context.Context, opts ...option.RequestOption) (res *HealthInfo, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/health"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Get version. Get the version of the service.
func (r *InspectService) Version(ctx context.Context, opts ...option.RequestOption) (res *VersionInfo, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/version"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Health status information for the service.
type HealthInfo struct {
// Current health status of the service
//
// Any of "OK", "Error", "Not Implemented".
Status HealthInfoStatus `json:"status,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Status respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r HealthInfo) RawJSON() string { return r.JSON.raw }
func (r *HealthInfo) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Current health status of the service
type HealthInfoStatus string
const (
HealthInfoStatusOk HealthInfoStatus = "OK"
HealthInfoStatusError HealthInfoStatus = "Error"
HealthInfoStatusNotImplemented HealthInfoStatus = "Not Implemented"
)
// Information about a registered provider including its configuration and health
// status.
type ProviderInfo struct {
// The API name this provider implements
API string `json:"api,required"`
// Configuration parameters for the provider
Config map[string]ProviderInfoConfigUnion `json:"config,required"`
// Current health status of the provider
Health map[string]ProviderInfoHealthUnion `json:"health,required"`
// Unique identifier for the provider
ProviderID string `json:"provider_id,required"`
// The type of provider implementation
ProviderType string `json:"provider_type,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
API respjson.Field
Config respjson.Field
Health respjson.Field
ProviderID respjson.Field
ProviderType respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ProviderInfo) RawJSON() string { return r.JSON.raw }
func (r *ProviderInfo) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ProviderInfoConfigUnion contains all possible properties and values from [bool],
// [float64], [string], [[]any].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBool OfFloat OfString OfAnyArray]
type ProviderInfoConfigUnion struct {
// This field will be present if the value is a [bool] instead of an object.
OfBool bool `json:",inline"`
// This field will be present if the value is a [float64] instead of an object.
OfFloat float64 `json:",inline"`
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [[]any] instead of an object.
OfAnyArray []any `json:",inline"`
JSON struct {
OfBool respjson.Field
OfFloat respjson.Field
OfString respjson.Field
OfAnyArray respjson.Field
raw string
} `json:"-"`
}
func (u ProviderInfoConfigUnion) AsBool() (v bool) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoConfigUnion) AsFloat() (v float64) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoConfigUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoConfigUnion) AsAnyArray() (v []any) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u ProviderInfoConfigUnion) RawJSON() string { return u.JSON.raw }
func (r *ProviderInfoConfigUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ProviderInfoHealthUnion contains all possible properties and values from [bool],
// [float64], [string], [[]any].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBool OfFloat OfString OfAnyArray]
type ProviderInfoHealthUnion struct {
// This field will be present if the value is a [bool] instead of an object.
OfBool bool `json:",inline"`
// This field will be present if the value is a [float64] instead of an object.
OfFloat float64 `json:",inline"`
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [[]any] instead of an object.
OfAnyArray []any `json:",inline"`
JSON struct {
OfBool respjson.Field
OfFloat respjson.Field
OfString respjson.Field
OfAnyArray respjson.Field
raw string
} `json:"-"`
}
func (u ProviderInfoHealthUnion) AsBool() (v bool) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoHealthUnion) AsFloat() (v float64) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoHealthUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ProviderInfoHealthUnion) AsAnyArray() (v []any) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u ProviderInfoHealthUnion) RawJSON() string { return u.JSON.raw }
func (r *ProviderInfoHealthUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Information about an API route including its path, method, and implementing
// providers.
type RouteInfo struct {
// HTTP method for the route
Method string `json:"method,required"`
// List of provider types that implement this route
ProviderTypes []string `json:"provider_types,required"`
// The API endpoint path
Route string `json:"route,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Method respjson.Field
ProviderTypes respjson.Field
Route respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r RouteInfo) RawJSON() string { return r.JSON.raw }
func (r *RouteInfo) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Version information for the service.
type VersionInfo struct {
// Version number of the service
Version string `json:"version,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Version respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r VersionInfo) RawJSON() string { return r.JSON.raw }
func (r *VersionInfo) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}