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/tracing"
14 "net/http"
15 )
16
17
18 type ArtifactsClient struct {
19 BaseClient
20 }
21
22
23 func NewArtifactsClient(subscriptionID string) ArtifactsClient {
24 return NewArtifactsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewArtifactsClientWithBaseURI(baseURI string, subscriptionID string) ArtifactsClient {
30 return ArtifactsClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36
37
38
39
40
41 func (client ArtifactsClient) GenerateArmTemplate(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (result ArmTemplateInfo, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactsClient.GenerateArmTemplate")
44 defer func() {
45 sc := -1
46 if result.Response.Response != nil {
47 sc = result.Response.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 req, err := client.GenerateArmTemplatePreparer(ctx, resourceGroupName, labName, artifactSourceName, name, generateArmTemplateRequest)
53 if err != nil {
54 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "GenerateArmTemplate", nil, "Failure preparing request")
55 return
56 }
57
58 resp, err := client.GenerateArmTemplateSender(req)
59 if err != nil {
60 result.Response = autorest.Response{Response: resp}
61 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "GenerateArmTemplate", resp, "Failure sending request")
62 return
63 }
64
65 result, err = client.GenerateArmTemplateResponder(resp)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "GenerateArmTemplate", resp, "Failure responding to request")
68 return
69 }
70
71 return
72 }
73
74
75 func (client ArtifactsClient) GenerateArmTemplatePreparer(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (*http.Request, error) {
76 pathParameters := map[string]interface{}{
77 "artifactSourceName": autorest.Encode("path", artifactSourceName),
78 "labName": autorest.Encode("path", labName),
79 "name": autorest.Encode("path", name),
80 "resourceGroupName": autorest.Encode("path", resourceGroupName),
81 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
82 }
83
84 const APIVersion = "2016-05-15"
85 queryParameters := map[string]interface{}{
86 "api-version": APIVersion,
87 }
88
89 preparer := autorest.CreatePreparer(
90 autorest.AsContentType("application/json; charset=utf-8"),
91 autorest.AsPost(),
92 autorest.WithBaseURL(client.BaseURI),
93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}/generateArmTemplate", pathParameters),
94 autorest.WithJSON(generateArmTemplateRequest),
95 autorest.WithQueryParameters(queryParameters))
96 return preparer.Prepare((&http.Request{}).WithContext(ctx))
97 }
98
99
100
101 func (client ArtifactsClient) GenerateArmTemplateSender(req *http.Request) (*http.Response, error) {
102 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
103 }
104
105
106
107 func (client ArtifactsClient) GenerateArmTemplateResponder(resp *http.Response) (result ArmTemplateInfo, err error) {
108 err = autorest.Respond(
109 resp,
110 azure.WithErrorUnlessStatusCode(http.StatusOK),
111 autorest.ByUnmarshallingJSON(&result),
112 autorest.ByClosing())
113 result.Response = autorest.Response{Response: resp}
114 return
115 }
116
117
118
119
120
121
122
123
124 func (client ArtifactsClient) Get(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (result Artifact, err error) {
125 if tracing.IsEnabled() {
126 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactsClient.Get")
127 defer func() {
128 sc := -1
129 if result.Response.Response != nil {
130 sc = result.Response.Response.StatusCode
131 }
132 tracing.EndSpan(ctx, sc, err)
133 }()
134 }
135 req, err := client.GetPreparer(ctx, resourceGroupName, labName, artifactSourceName, name, expand)
136 if err != nil {
137 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "Get", nil, "Failure preparing request")
138 return
139 }
140
141 resp, err := client.GetSender(req)
142 if err != nil {
143 result.Response = autorest.Response{Response: resp}
144 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "Get", resp, "Failure sending request")
145 return
146 }
147
148 result, err = client.GetResponder(resp)
149 if err != nil {
150 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "Get", resp, "Failure responding to request")
151 return
152 }
153
154 return
155 }
156
157
158 func (client ArtifactsClient) GetPreparer(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (*http.Request, error) {
159 pathParameters := map[string]interface{}{
160 "artifactSourceName": autorest.Encode("path", artifactSourceName),
161 "labName": autorest.Encode("path", labName),
162 "name": autorest.Encode("path", name),
163 "resourceGroupName": autorest.Encode("path", resourceGroupName),
164 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
165 }
166
167 const APIVersion = "2016-05-15"
168 queryParameters := map[string]interface{}{
169 "api-version": APIVersion,
170 }
171 if len(expand) > 0 {
172 queryParameters["$expand"] = autorest.Encode("query", expand)
173 }
174
175 preparer := autorest.CreatePreparer(
176 autorest.AsGet(),
177 autorest.WithBaseURL(client.BaseURI),
178 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}", pathParameters),
179 autorest.WithQueryParameters(queryParameters))
180 return preparer.Prepare((&http.Request{}).WithContext(ctx))
181 }
182
183
184
185 func (client ArtifactsClient) GetSender(req *http.Request) (*http.Response, error) {
186 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
187 }
188
189
190
191 func (client ArtifactsClient) GetResponder(resp *http.Response) (result Artifact, err error) {
192 err = autorest.Respond(
193 resp,
194 azure.WithErrorUnlessStatusCode(http.StatusOK),
195 autorest.ByUnmarshallingJSON(&result),
196 autorest.ByClosing())
197 result.Response = autorest.Response{Response: resp}
198 return
199 }
200
201
202
203
204
205
206
207
208
209
210 func (client ArtifactsClient) List(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationArtifactPage, err error) {
211 if tracing.IsEnabled() {
212 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactsClient.List")
213 defer func() {
214 sc := -1
215 if result.rwca.Response.Response != nil {
216 sc = result.rwca.Response.Response.StatusCode
217 }
218 tracing.EndSpan(ctx, sc, err)
219 }()
220 }
221 result.fn = client.listNextResults
222 req, err := client.ListPreparer(ctx, resourceGroupName, labName, artifactSourceName, expand, filter, top, orderby)
223 if err != nil {
224 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "List", nil, "Failure preparing request")
225 return
226 }
227
228 resp, err := client.ListSender(req)
229 if err != nil {
230 result.rwca.Response = autorest.Response{Response: resp}
231 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "List", resp, "Failure sending request")
232 return
233 }
234
235 result.rwca, err = client.ListResponder(resp)
236 if err != nil {
237 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "List", resp, "Failure responding to request")
238 return
239 }
240 if result.rwca.hasNextLink() && result.rwca.IsEmpty() {
241 err = result.NextWithContext(ctx)
242 return
243 }
244
245 return
246 }
247
248
249 func (client ArtifactsClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
250 pathParameters := map[string]interface{}{
251 "artifactSourceName": autorest.Encode("path", artifactSourceName),
252 "labName": autorest.Encode("path", labName),
253 "resourceGroupName": autorest.Encode("path", resourceGroupName),
254 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
255 }
256
257 const APIVersion = "2016-05-15"
258 queryParameters := map[string]interface{}{
259 "api-version": APIVersion,
260 }
261 if len(expand) > 0 {
262 queryParameters["$expand"] = autorest.Encode("query", expand)
263 }
264 if len(filter) > 0 {
265 queryParameters["$filter"] = autorest.Encode("query", filter)
266 }
267 if top != nil {
268 queryParameters["$top"] = autorest.Encode("query", *top)
269 }
270 if len(orderby) > 0 {
271 queryParameters["$orderby"] = autorest.Encode("query", orderby)
272 }
273
274 preparer := autorest.CreatePreparer(
275 autorest.AsGet(),
276 autorest.WithBaseURL(client.BaseURI),
277 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts", pathParameters),
278 autorest.WithQueryParameters(queryParameters))
279 return preparer.Prepare((&http.Request{}).WithContext(ctx))
280 }
281
282
283
284 func (client ArtifactsClient) ListSender(req *http.Request) (*http.Response, error) {
285 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
286 }
287
288
289
290 func (client ArtifactsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArtifact, err error) {
291 err = autorest.Respond(
292 resp,
293 azure.WithErrorUnlessStatusCode(http.StatusOK),
294 autorest.ByUnmarshallingJSON(&result),
295 autorest.ByClosing())
296 result.Response = autorest.Response{Response: resp}
297 return
298 }
299
300
301 func (client ArtifactsClient) listNextResults(ctx context.Context, lastResults ResponseWithContinuationArtifact) (result ResponseWithContinuationArtifact, err error) {
302 req, err := lastResults.responseWithContinuationArtifactPreparer(ctx)
303 if err != nil {
304 return result, autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "listNextResults", nil, "Failure preparing next results request")
305 }
306 if req == nil {
307 return
308 }
309 resp, err := client.ListSender(req)
310 if err != nil {
311 result.Response = autorest.Response{Response: resp}
312 return result, autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "listNextResults", resp, "Failure sending next results request")
313 }
314 result, err = client.ListResponder(resp)
315 if err != nil {
316 err = autorest.NewErrorWithError(err, "dtl.ArtifactsClient", "listNextResults", resp, "Failure responding to next results request")
317 }
318 return
319 }
320
321
322 func (client ArtifactsClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationArtifactIterator, err error) {
323 if tracing.IsEnabled() {
324 ctx = tracing.StartSpan(ctx, fqdn+"/ArtifactsClient.List")
325 defer func() {
326 sc := -1
327 if result.Response().Response.Response != nil {
328 sc = result.page.Response().Response.Response.StatusCode
329 }
330 tracing.EndSpan(ctx, sc, err)
331 }()
332 }
333 result.page, err = client.List(ctx, resourceGroupName, labName, artifactSourceName, expand, filter, top, orderby)
334 return
335 }
336
View as plain text