1 package dtl
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type ArtifactSourcesClient struct {
20 BaseClient
21 }
22
23
24 func NewArtifactSourcesClient(subscriptionID string) ArtifactSourcesClient {
25 return NewArtifactSourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewArtifactSourcesClientWithBaseURI(baseURI string, subscriptionID string) ArtifactSourcesClient {
31 return ArtifactSourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40 func (client ArtifactSourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (result ArtifactSource, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.Response.Response != nil {
46 sc = result.Response.Response.StatusCode
47 }
48 tracing.EndSpan(ctx, sc, err)
49 }()
50 }
51 if err := validation.Validate([]validation.Validation{
52 {TargetValue: artifactSource,
53 Constraints: []validation.Constraint{{Target: "artifactSource.ArtifactSourceProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
54 return result, validation.NewError("dtl.ArtifactSourcesClient", "CreateOrUpdate", err.Error())
55 }
56
57 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, labName, name, artifactSource)
58 if err != nil {
59 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "CreateOrUpdate", nil, "Failure preparing request")
60 return
61 }
62
63 resp, err := client.CreateOrUpdateSender(req)
64 if err != nil {
65 result.Response = autorest.Response{Response: resp}
66 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "CreateOrUpdate", resp, "Failure sending request")
67 return
68 }
69
70 result, err = client.CreateOrUpdateResponder(resp)
71 if err != nil {
72 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "CreateOrUpdate", resp, "Failure responding to request")
73 return
74 }
75
76 return
77 }
78
79
80 func (client ArtifactSourcesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (*http.Request, error) {
81 pathParameters := map[string]interface{}{
82 "labName": autorest.Encode("path", labName),
83 "name": autorest.Encode("path", name),
84 "resourceGroupName": autorest.Encode("path", resourceGroupName),
85 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
86 }
87
88 const APIVersion = "2018-09-15"
89 queryParameters := map[string]interface{}{
90 "api-version": APIVersion,
91 }
92
93 preparer := autorest.CreatePreparer(
94 autorest.AsContentType("application/json; charset=utf-8"),
95 autorest.AsPut(),
96 autorest.WithBaseURL(client.BaseURI),
97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}", pathParameters),
98 autorest.WithJSON(artifactSource),
99 autorest.WithQueryParameters(queryParameters))
100 return preparer.Prepare((&http.Request{}).WithContext(ctx))
101 }
102
103
104
105 func (client ArtifactSourcesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
106 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
107 }
108
109
110
111 func (client ArtifactSourcesClient) CreateOrUpdateResponder(resp *http.Response) (result ArtifactSource, err error) {
112 err = autorest.Respond(
113 resp,
114 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
115 autorest.ByUnmarshallingJSON(&result),
116 autorest.ByClosing())
117 result.Response = autorest.Response{Response: resp}
118 return
119 }
120
121
122
123
124
125
126 func (client ArtifactSourcesClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string) (result autorest.Response, err error) {
127 if tracing.IsEnabled() {
128 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.Delete")
129 defer func() {
130 sc := -1
131 if result.Response != nil {
132 sc = result.Response.StatusCode
133 }
134 tracing.EndSpan(ctx, sc, err)
135 }()
136 }
137 req, err := client.DeletePreparer(ctx, resourceGroupName, labName, name)
138 if err != nil {
139 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Delete", nil, "Failure preparing request")
140 return
141 }
142
143 resp, err := client.DeleteSender(req)
144 if err != nil {
145 result.Response = resp
146 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Delete", resp, "Failure sending request")
147 return
148 }
149
150 result, err = client.DeleteResponder(resp)
151 if err != nil {
152 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Delete", resp, "Failure responding to request")
153 return
154 }
155
156 return
157 }
158
159
160 func (client ArtifactSourcesClient) DeletePreparer(ctx context.Context, resourceGroupName string, labName string, name string) (*http.Request, error) {
161 pathParameters := map[string]interface{}{
162 "labName": autorest.Encode("path", labName),
163 "name": autorest.Encode("path", name),
164 "resourceGroupName": autorest.Encode("path", resourceGroupName),
165 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
166 }
167
168 const APIVersion = "2018-09-15"
169 queryParameters := map[string]interface{}{
170 "api-version": APIVersion,
171 }
172
173 preparer := autorest.CreatePreparer(
174 autorest.AsDelete(),
175 autorest.WithBaseURL(client.BaseURI),
176 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}", pathParameters),
177 autorest.WithQueryParameters(queryParameters))
178 return preparer.Prepare((&http.Request{}).WithContext(ctx))
179 }
180
181
182
183 func (client ArtifactSourcesClient) DeleteSender(req *http.Request) (*http.Response, error) {
184 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
185 }
186
187
188
189 func (client ArtifactSourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
190 err = autorest.Respond(
191 resp,
192 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
193 autorest.ByClosing())
194 result.Response = resp
195 return
196 }
197
198
199
200
201
202
203
204 func (client ArtifactSourcesClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, expand string) (result ArtifactSource, err error) {
205 if tracing.IsEnabled() {
206 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.Get")
207 defer func() {
208 sc := -1
209 if result.Response.Response != nil {
210 sc = result.Response.Response.StatusCode
211 }
212 tracing.EndSpan(ctx, sc, err)
213 }()
214 }
215 req, err := client.GetPreparer(ctx, resourceGroupName, labName, name, expand)
216 if err != nil {
217 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Get", nil, "Failure preparing request")
218 return
219 }
220
221 resp, err := client.GetSender(req)
222 if err != nil {
223 result.Response = autorest.Response{Response: resp}
224 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Get", resp, "Failure sending request")
225 return
226 }
227
228 result, err = client.GetResponder(resp)
229 if err != nil {
230 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Get", resp, "Failure responding to request")
231 return
232 }
233
234 return
235 }
236
237
238 func (client ArtifactSourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, labName string, name string, expand string) (*http.Request, error) {
239 pathParameters := map[string]interface{}{
240 "labName": autorest.Encode("path", labName),
241 "name": autorest.Encode("path", name),
242 "resourceGroupName": autorest.Encode("path", resourceGroupName),
243 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
244 }
245
246 const APIVersion = "2018-09-15"
247 queryParameters := map[string]interface{}{
248 "api-version": APIVersion,
249 }
250 if len(expand) > 0 {
251 queryParameters["$expand"] = autorest.Encode("query", expand)
252 }
253
254 preparer := autorest.CreatePreparer(
255 autorest.AsGet(),
256 autorest.WithBaseURL(client.BaseURI),
257 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}", pathParameters),
258 autorest.WithQueryParameters(queryParameters))
259 return preparer.Prepare((&http.Request{}).WithContext(ctx))
260 }
261
262
263
264 func (client ArtifactSourcesClient) GetSender(req *http.Request) (*http.Response, error) {
265 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
266 }
267
268
269
270 func (client ArtifactSourcesClient) GetResponder(resp *http.Response) (result ArtifactSource, err error) {
271 err = autorest.Respond(
272 resp,
273 azure.WithErrorUnlessStatusCode(http.StatusOK),
274 autorest.ByUnmarshallingJSON(&result),
275 autorest.ByClosing())
276 result.Response = autorest.Response{Response: resp}
277 return
278 }
279
280
281
282
283
284
285
286
287
288 func (client ArtifactSourcesClient) List(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ArtifactSourceListPage, err error) {
289 if tracing.IsEnabled() {
290 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.List")
291 defer func() {
292 sc := -1
293 if result.asl.Response.Response != nil {
294 sc = result.asl.Response.Response.StatusCode
295 }
296 tracing.EndSpan(ctx, sc, err)
297 }()
298 }
299 result.fn = client.listNextResults
300 req, err := client.ListPreparer(ctx, resourceGroupName, labName, expand, filter, top, orderby)
301 if err != nil {
302 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "List", nil, "Failure preparing request")
303 return
304 }
305
306 resp, err := client.ListSender(req)
307 if err != nil {
308 result.asl.Response = autorest.Response{Response: resp}
309 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "List", resp, "Failure sending request")
310 return
311 }
312
313 result.asl, err = client.ListResponder(resp)
314 if err != nil {
315 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "List", resp, "Failure responding to request")
316 return
317 }
318 if result.asl.hasNextLink() && result.asl.IsEmpty() {
319 err = result.NextWithContext(ctx)
320 return
321 }
322
323 return
324 }
325
326
327 func (client ArtifactSourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
328 pathParameters := map[string]interface{}{
329 "labName": autorest.Encode("path", labName),
330 "resourceGroupName": autorest.Encode("path", resourceGroupName),
331 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
332 }
333
334 const APIVersion = "2018-09-15"
335 queryParameters := map[string]interface{}{
336 "api-version": APIVersion,
337 }
338 if len(expand) > 0 {
339 queryParameters["$expand"] = autorest.Encode("query", expand)
340 }
341 if len(filter) > 0 {
342 queryParameters["$filter"] = autorest.Encode("query", filter)
343 }
344 if top != nil {
345 queryParameters["$top"] = autorest.Encode("query", *top)
346 }
347 if len(orderby) > 0 {
348 queryParameters["$orderby"] = autorest.Encode("query", orderby)
349 }
350
351 preparer := autorest.CreatePreparer(
352 autorest.AsGet(),
353 autorest.WithBaseURL(client.BaseURI),
354 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources", pathParameters),
355 autorest.WithQueryParameters(queryParameters))
356 return preparer.Prepare((&http.Request{}).WithContext(ctx))
357 }
358
359
360
361 func (client ArtifactSourcesClient) ListSender(req *http.Request) (*http.Response, error) {
362 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
363 }
364
365
366
367 func (client ArtifactSourcesClient) ListResponder(resp *http.Response) (result ArtifactSourceList, err error) {
368 err = autorest.Respond(
369 resp,
370 azure.WithErrorUnlessStatusCode(http.StatusOK),
371 autorest.ByUnmarshallingJSON(&result),
372 autorest.ByClosing())
373 result.Response = autorest.Response{Response: resp}
374 return
375 }
376
377
378 func (client ArtifactSourcesClient) listNextResults(ctx context.Context, lastResults ArtifactSourceList) (result ArtifactSourceList, err error) {
379 req, err := lastResults.artifactSourceListPreparer(ctx)
380 if err != nil {
381 return result, autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "listNextResults", nil, "Failure preparing next results request")
382 }
383 if req == nil {
384 return
385 }
386 resp, err := client.ListSender(req)
387 if err != nil {
388 result.Response = autorest.Response{Response: resp}
389 return result, autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "listNextResults", resp, "Failure sending next results request")
390 }
391 result, err = client.ListResponder(resp)
392 if err != nil {
393 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "listNextResults", resp, "Failure responding to next results request")
394 }
395 return
396 }
397
398
399 func (client ArtifactSourcesClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ArtifactSourceListIterator, err error) {
400 if tracing.IsEnabled() {
401 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.List")
402 defer func() {
403 sc := -1
404 if result.Response().Response.Response != nil {
405 sc = result.page.Response().Response.Response.StatusCode
406 }
407 tracing.EndSpan(ctx, sc, err)
408 }()
409 }
410 result.page, err = client.List(ctx, resourceGroupName, labName, expand, filter, top, orderby)
411 return
412 }
413
414
415
416
417
418
419
420 func (client ArtifactSourcesClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSourceFragment) (result ArtifactSource, err error) {
421 if tracing.IsEnabled() {
422 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactSourcesClient.Update")
423 defer func() {
424 sc := -1
425 if result.Response.Response != nil {
426 sc = result.Response.Response.StatusCode
427 }
428 tracing.EndSpan(ctx, sc, err)
429 }()
430 }
431 req, err := client.UpdatePreparer(ctx, resourceGroupName, labName, name, artifactSource)
432 if err != nil {
433 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Update", nil, "Failure preparing request")
434 return
435 }
436
437 resp, err := client.UpdateSender(req)
438 if err != nil {
439 result.Response = autorest.Response{Response: resp}
440 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Update", resp, "Failure sending request")
441 return
442 }
443
444 result, err = client.UpdateResponder(resp)
445 if err != nil {
446 err = autorest.NewErrorWithError(err, "dtl.ArtifactSourcesClient", "Update", resp, "Failure responding to request")
447 return
448 }
449
450 return
451 }
452
453
454 func (client ArtifactSourcesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, labName string, name string, artifactSource ArtifactSourceFragment) (*http.Request, error) {
455 pathParameters := map[string]interface{}{
456 "labName": autorest.Encode("path", labName),
457 "name": autorest.Encode("path", name),
458 "resourceGroupName": autorest.Encode("path", resourceGroupName),
459 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
460 }
461
462 const APIVersion = "2018-09-15"
463 queryParameters := map[string]interface{}{
464 "api-version": APIVersion,
465 }
466
467 preparer := autorest.CreatePreparer(
468 autorest.AsContentType("application/json; charset=utf-8"),
469 autorest.AsPatch(),
470 autorest.WithBaseURL(client.BaseURI),
471 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}", pathParameters),
472 autorest.WithJSON(artifactSource),
473 autorest.WithQueryParameters(queryParameters))
474 return preparer.Prepare((&http.Request{}).WithContext(ctx))
475 }
476
477
478
479 func (client ArtifactSourcesClient) UpdateSender(req *http.Request) (*http.Response, error) {
480 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
481 }
482
483
484
485 func (client ArtifactSourcesClient) UpdateResponder(resp *http.Response) (result ArtifactSource, err error) {
486 err = autorest.Respond(
487 resp,
488 azure.WithErrorUnlessStatusCode(http.StatusOK),
489 autorest.ByUnmarshallingJSON(&result),
490 autorest.ByClosing())
491 result.Response = autorest.Response{Response: resp}
492 return
493 }
494
View as plain text