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