-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.go
275 lines (245 loc) · 8.25 KB
/
editor.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
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
264
265
266
267
268
269
270
271
272
273
274
275
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package gitpod
import (
"context"
"net/http"
"net/url"
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
"github.com/gitpod-io/gitpod-sdk-go/internal/apiquery"
"github.com/gitpod-io/gitpod-sdk-go/internal/param"
"github.com/gitpod-io/gitpod-sdk-go/internal/requestconfig"
"github.com/gitpod-io/gitpod-sdk-go/option"
"github.com/gitpod-io/gitpod-sdk-go/packages/pagination"
)
// EditorService contains methods and other services that help with interacting
// with the gitpod 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 [NewEditorService] method instead.
type EditorService struct {
Options []option.RequestOption
}
// NewEditorService 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 NewEditorService(opts ...option.RequestOption) (r *EditorService) {
r = &EditorService{}
r.Options = opts
return
}
// Gets details about a specific editor.
//
// Use this method to:
//
// - View editor information
// - Get editor configuration
//
// ### Examples
//
// - Get editor details:
//
// Retrieves information about a specific editor.
//
// ```yaml
// id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
// ```
func (r *EditorService) Get(ctx context.Context, body EditorGetParams, opts ...option.RequestOption) (res *EditorGetResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.EditorService/GetEditor"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Lists all available code editors.
//
// Use this method to:
//
// - View supported editors
// - Get editor capabilities
// - Browse editor options
// - Check editor availability
//
// ### Examples
//
// - List editors:
//
// Shows all available editors with pagination.
//
// ```yaml
// pagination:
// pageSize: 20
// ```
func (r *EditorService) List(ctx context.Context, params EditorListParams, opts ...option.RequestOption) (res *pagination.EditorsPage[Editor], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "gitpod.v1.EditorService/ListEditors"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Lists all available code editors.
//
// Use this method to:
//
// - View supported editors
// - Get editor capabilities
// - Browse editor options
// - Check editor availability
//
// ### Examples
//
// - List editors:
//
// Shows all available editors with pagination.
//
// ```yaml
// pagination:
// pageSize: 20
// ```
func (r *EditorService) ListAutoPaging(ctx context.Context, params EditorListParams, opts ...option.RequestOption) *pagination.EditorsPageAutoPager[Editor] {
return pagination.NewEditorsPageAutoPager(r.List(ctx, params, opts...))
}
// Resolves the URL for accessing an editor in a specific environment.
//
// Use this method to:
//
// - Get editor access URLs
// - Launch editors for environments
// - Set up editor connections
// - Configure editor access
//
// ### Examples
//
// - Resolve editor URL:
//
// Gets the URL for accessing an editor in an environment.
//
// ```yaml
// editorId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// ```
func (r *EditorService) ResolveURL(ctx context.Context, body EditorResolveURLParams, opts ...option.RequestOption) (res *EditorResolveURLResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.EditorService/ResolveEditorURL"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type Editor struct {
ID string `json:"id,required" format:"uuid"`
InstallationInstructions string `json:"installationInstructions,required"`
Name string `json:"name,required"`
URLTemplate string `json:"urlTemplate,required"`
Alias string `json:"alias"`
IconURL string `json:"iconUrl"`
ShortDescription string `json:"shortDescription"`
JSON editorJSON `json:"-"`
}
// editorJSON contains the JSON metadata for the struct [Editor]
type editorJSON struct {
ID apijson.Field
InstallationInstructions apijson.Field
Name apijson.Field
URLTemplate apijson.Field
Alias apijson.Field
IconURL apijson.Field
ShortDescription apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Editor) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r editorJSON) RawJSON() string {
return r.raw
}
type EditorGetResponse struct {
// editor contains the editor
Editor Editor `json:"editor,required"`
JSON editorGetResponseJSON `json:"-"`
}
// editorGetResponseJSON contains the JSON metadata for the struct
// [EditorGetResponse]
type editorGetResponseJSON struct {
Editor apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EditorGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r editorGetResponseJSON) RawJSON() string {
return r.raw
}
type EditorResolveURLResponse struct {
// url is the resolved editor URL
URL string `json:"url,required"`
JSON editorResolveURLResponseJSON `json:"-"`
}
// editorResolveURLResponseJSON contains the JSON metadata for the struct
// [EditorResolveURLResponse]
type editorResolveURLResponseJSON struct {
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EditorResolveURLResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r editorResolveURLResponseJSON) RawJSON() string {
return r.raw
}
type EditorGetParams struct {
// id is the ID of the editor to get
ID param.Field[string] `json:"id,required"`
}
func (r EditorGetParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type EditorListParams struct {
Token param.Field[string] `query:"token"`
PageSize param.Field[int64] `query:"pageSize"`
// pagination contains the pagination options for listing environments
Pagination param.Field[EditorListParamsPagination] `json:"pagination"`
}
func (r EditorListParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// URLQuery serializes [EditorListParams]'s query parameters as `url.Values`.
func (r EditorListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// pagination contains the pagination options for listing environments
type EditorListParamsPagination struct {
// Token for the next set of results that was returned as next_token of a
// PaginationResponse
Token param.Field[string] `json:"token"`
// Page size is the maximum number of results to retrieve per page. Defaults to 25.
// Maximum 100.
PageSize param.Field[int64] `json:"pageSize"`
}
func (r EditorListParamsPagination) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type EditorResolveURLParams struct {
// editorId is the ID of the editor to resolve the URL for
EditorID param.Field[string] `json:"editorId,required" format:"uuid"`
// environmentId is the ID of the environment to resolve the URL for
EnvironmentID param.Field[string] `json:"environmentId,required" format:"uuid"`
// organizationId is the ID of the organization to resolve the URL for
OrganizationID param.Field[string] `json:"organizationId,required" format:"uuid"`
}
func (r EditorResolveURLParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}