-
Notifications
You must be signed in to change notification settings - Fork 0
/
pydio8_store_v2.go
292 lines (236 loc) · 6.64 KB
/
pydio8_store_v2.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
package pydio8
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/pydio/pydio-sdk-go/client"
"github.com/pydio/pydio-sdk-go/client/provisioning"
"github.com/pydio/pydio-sdk-go/models"
)
type Client struct {
cli *client.PydioAPIV2
}
// User Client Rewrite
func (a *Client) GetPeople(params *GetPeopleParams) (*GetPeopleOK, error) {
// // TODO: Validate the params before sending
// if params == nil {
// params = NewGetPeopleParams()
// }
result, err := a.cli.Transport.Submit(&runtime.ClientOperation{
ID: "getPeople",
Method: "GET",
PathPattern: "/admin/people/{path}",
ProducesMediaTypes: []string{"application/json", "application/xml"},
ConsumesMediaTypes: []string{""},
Schemes: []string{"http"},
Params: params,
Reader: &GetPeopleReader{formats: strfmt.Default},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*GetPeopleOK), nil
}
/*GetPeopleParams contains all the parameters to send to the API endpoint
for the get people operation typically these are written to a http.Request
*/
type GetPeopleParams struct {
/*Format
Format produced in output (defaults to xml)
*/
Format *string
/*List
list children of the current resource
*/
List *bool
/*Path
User or group identifier, including full group path (optional)
*/
Path string
Page int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WriteToRequest writes these params to a swagger request
func (o *GetPeopleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Format != nil {
// query param format
var qrFormat string
if o.Format != nil {
qrFormat = *o.Format
}
qFormat := qrFormat
if qFormat != "" {
if err := r.SetQueryParam("format", qFormat); err != nil {
return err
}
}
}
if o.List != nil {
// query param list
var qrList bool
if o.List != nil {
qrList = *o.List
}
qList := swag.FormatBool(qrList)
if qList != "" {
if err := r.SetQueryParam("list", qList); err != nil {
return err
}
}
}
if o.Page > 0 {
qPage := swag.FormatInt64(o.Page)
if qPage != "" {
if err := r.SetQueryParam("page", qPage); err != nil {
return err
}
}
}
// path param path
if err := r.SetPathParam("path", o.Path); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ROLE client rewrite
func (a *Client) GetRoles(params *provisioning.GetRolesParams) (*GetRolesOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = provisioning.NewGetRolesParams()
}
result, err := a.cli.Transport.Submit(&runtime.ClientOperation{
ID: "getRoles",
Method: "GET",
PathPattern: "/admin/roles",
ProducesMediaTypes: []string{"application/json", "application/xml"},
ConsumesMediaTypes: []string{""},
Schemes: []string{"http"},
Params: params,
Reader: &GetRolesReader{formats: strfmt.Default},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*GetRolesOK), nil
}
// GetRolesReader is a Reader for the GetRoles structure.
type GetPeopleReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetPeopleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetPeopleOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewGetRolesOK creates a GetRolesOK with default headers values
func NewGetPeopleOK() *GetPeopleOK {
return &GetPeopleOK{}
}
/*GetRolesOK handles this case with default header values.
A list of roles represented as standard nodes
*/
type GetPeopleOK struct {
Payload *models.NodeList
}
func (o *GetPeopleOK) Error() string {
return fmt.Sprintf("[GET /admin/people][%d] getPeopleOk %+v", 200, o.Payload)
}
// readResponse may parse response formated as NodeList OR NodeListData
func (o *GetPeopleOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.NodeList)
var body map[string]interface{}
if err := consumer.Consume(response.Body(), &body); err != nil && err != io.EOF {
return err
}
if val, ok := body["children"]; ok {
o.Payload.Data = new(models.NodeListData)
test, _ := json.Marshal(val)
if string(test) == "[]" {
o.Payload.Data.Children = make(map[string]models.Node)
} else {
js, _ := json.Marshal(body)
if err := json.Unmarshal(js, &o.Payload.Data); err != nil {
return err
}
}
} else {
js, e := json.Marshal(body)
if e != nil {
return e
}
var p models.NodeList
if err := json.Unmarshal(js, &p); err != nil {
return err
}
o.Payload = &p
}
return nil
}
// GetRolesReader is a Reader for the GetRoles structure.
type GetRolesReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetRolesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetRolesOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewGetRolesOK creates a GetRolesOK with default headers values
func NewGetRolesOK() *GetRolesOK {
return &GetRolesOK{}
}
/*GetRolesOK handles this case with default header values.
A list of roles represented as standard nodes
*/
type GetRolesOK struct {
Payload *models.NodeList
}
func (o *GetRolesOK) Error() string {
return fmt.Sprintf("[GET /admin/roles][%d] getRolesOK %+v", 200, o.Payload)
}
func (o *GetRolesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.NodeList)
data := new(models.NodeListData)
// response payload
if err := consumer.Consume(response.Body(), &data); err != nil && err != io.EOF {
return err
}
o.Payload.Data = data
return nil
}