1 package managementgroups
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
19
20 type HierarchySettingsClient struct {
21 BaseClient
22 }
23
24
25 func NewHierarchySettingsClient() HierarchySettingsClient {
26 return NewHierarchySettingsClientWithBaseURI(DefaultBaseURI)
27 }
28
29
30
31
32 func NewHierarchySettingsClientWithBaseURI(baseURI string) HierarchySettingsClient {
33 return HierarchySettingsClient{NewWithBaseURI(baseURI)}
34 }
35
36
37
38
39
40 func (client HierarchySettingsClient) CreateOrUpdate(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (result HierarchySettings, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.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 req, err := client.CreateOrUpdatePreparer(ctx, groupID, createTenantSettingsRequest)
52 if err != nil {
53 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", nil, "Failure preparing request")
54 return
55 }
56
57 resp, err := client.CreateOrUpdateSender(req)
58 if err != nil {
59 result.Response = autorest.Response{Response: resp}
60 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", resp, "Failure sending request")
61 return
62 }
63
64 result, err = client.CreateOrUpdateResponder(resp)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", resp, "Failure responding to request")
67 return
68 }
69
70 return
71 }
72
73
74 func (client HierarchySettingsClient) CreateOrUpdatePreparer(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (*http.Request, error) {
75 pathParameters := map[string]interface{}{
76 "groupId": autorest.Encode("path", groupID),
77 }
78
79 const APIVersion = "2020-02-01"
80 queryParameters := map[string]interface{}{
81 "api-version": APIVersion,
82 }
83
84 preparer := autorest.CreatePreparer(
85 autorest.AsContentType("application/json; charset=utf-8"),
86 autorest.AsPut(),
87 autorest.WithBaseURL(client.BaseURI),
88 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters),
89 autorest.WithJSON(createTenantSettingsRequest),
90 autorest.WithQueryParameters(queryParameters))
91 return preparer.Prepare((&http.Request{}).WithContext(ctx))
92 }
93
94
95
96 func (client HierarchySettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
97 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
98 }
99
100
101
102 func (client HierarchySettingsClient) CreateOrUpdateResponder(resp *http.Response) (result HierarchySettings, err error) {
103 err = autorest.Respond(
104 resp,
105 azure.WithErrorUnlessStatusCode(http.StatusOK),
106 autorest.ByUnmarshallingJSON(&result),
107 autorest.ByClosing())
108 result.Response = autorest.Response{Response: resp}
109 return
110 }
111
112
113
114
115 func (client HierarchySettingsClient) Delete(ctx context.Context, groupID string) (result autorest.Response, err error) {
116 if tracing.IsEnabled() {
117 ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Delete")
118 defer func() {
119 sc := -1
120 if result.Response != nil {
121 sc = result.Response.StatusCode
122 }
123 tracing.EndSpan(ctx, sc, err)
124 }()
125 }
126 req, err := client.DeletePreparer(ctx, groupID)
127 if err != nil {
128 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", nil, "Failure preparing request")
129 return
130 }
131
132 resp, err := client.DeleteSender(req)
133 if err != nil {
134 result.Response = resp
135 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", resp, "Failure sending request")
136 return
137 }
138
139 result, err = client.DeleteResponder(resp)
140 if err != nil {
141 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", resp, "Failure responding to request")
142 return
143 }
144
145 return
146 }
147
148
149 func (client HierarchySettingsClient) DeletePreparer(ctx context.Context, groupID string) (*http.Request, error) {
150 pathParameters := map[string]interface{}{
151 "groupId": autorest.Encode("path", groupID),
152 }
153
154 const APIVersion = "2020-02-01"
155 queryParameters := map[string]interface{}{
156 "api-version": APIVersion,
157 }
158
159 preparer := autorest.CreatePreparer(
160 autorest.AsDelete(),
161 autorest.WithBaseURL(client.BaseURI),
162 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters),
163 autorest.WithQueryParameters(queryParameters))
164 return preparer.Prepare((&http.Request{}).WithContext(ctx))
165 }
166
167
168
169 func (client HierarchySettingsClient) DeleteSender(req *http.Request) (*http.Response, error) {
170 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
171 }
172
173
174
175 func (client HierarchySettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
176 err = autorest.Respond(
177 resp,
178 azure.WithErrorUnlessStatusCode(http.StatusOK),
179 autorest.ByClosing())
180 result.Response = resp
181 return
182 }
183
184
185
186
187
188 func (client HierarchySettingsClient) Get(ctx context.Context, groupID string) (result HierarchySettings, err error) {
189 if tracing.IsEnabled() {
190 ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Get")
191 defer func() {
192 sc := -1
193 if result.Response.Response != nil {
194 sc = result.Response.Response.StatusCode
195 }
196 tracing.EndSpan(ctx, sc, err)
197 }()
198 }
199 req, err := client.GetPreparer(ctx, groupID)
200 if err != nil {
201 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", nil, "Failure preparing request")
202 return
203 }
204
205 resp, err := client.GetSender(req)
206 if err != nil {
207 result.Response = autorest.Response{Response: resp}
208 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", resp, "Failure sending request")
209 return
210 }
211
212 result, err = client.GetResponder(resp)
213 if err != nil {
214 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", resp, "Failure responding to request")
215 return
216 }
217
218 return
219 }
220
221
222 func (client HierarchySettingsClient) GetPreparer(ctx context.Context, groupID string) (*http.Request, error) {
223 pathParameters := map[string]interface{}{
224 "groupId": autorest.Encode("path", groupID),
225 }
226
227 const APIVersion = "2020-02-01"
228 queryParameters := map[string]interface{}{
229 "api-version": APIVersion,
230 }
231
232 preparer := autorest.CreatePreparer(
233 autorest.AsGet(),
234 autorest.WithBaseURL(client.BaseURI),
235 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters),
236 autorest.WithQueryParameters(queryParameters))
237 return preparer.Prepare((&http.Request{}).WithContext(ctx))
238 }
239
240
241
242 func (client HierarchySettingsClient) GetSender(req *http.Request) (*http.Response, error) {
243 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
244 }
245
246
247
248 func (client HierarchySettingsClient) GetResponder(resp *http.Response) (result HierarchySettings, err error) {
249 err = autorest.Respond(
250 resp,
251 azure.WithErrorUnlessStatusCode(http.StatusOK),
252 autorest.ByUnmarshallingJSON(&result),
253 autorest.ByClosing())
254 result.Response = autorest.Response{Response: resp}
255 return
256 }
257
258
259
260
261
262 func (client HierarchySettingsClient) List(ctx context.Context, groupID string) (result HierarchySettingsList, err error) {
263 if tracing.IsEnabled() {
264 ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.List")
265 defer func() {
266 sc := -1
267 if result.Response.Response != nil {
268 sc = result.Response.Response.StatusCode
269 }
270 tracing.EndSpan(ctx, sc, err)
271 }()
272 }
273 req, err := client.ListPreparer(ctx, groupID)
274 if err != nil {
275 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", nil, "Failure preparing request")
276 return
277 }
278
279 resp, err := client.ListSender(req)
280 if err != nil {
281 result.Response = autorest.Response{Response: resp}
282 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", resp, "Failure sending request")
283 return
284 }
285
286 result, err = client.ListResponder(resp)
287 if err != nil {
288 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", resp, "Failure responding to request")
289 return
290 }
291
292 return
293 }
294
295
296 func (client HierarchySettingsClient) ListPreparer(ctx context.Context, groupID string) (*http.Request, error) {
297 pathParameters := map[string]interface{}{
298 "groupId": autorest.Encode("path", groupID),
299 }
300
301 const APIVersion = "2020-02-01"
302 queryParameters := map[string]interface{}{
303 "api-version": APIVersion,
304 }
305
306 preparer := autorest.CreatePreparer(
307 autorest.AsGet(),
308 autorest.WithBaseURL(client.BaseURI),
309 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings", pathParameters),
310 autorest.WithQueryParameters(queryParameters))
311 return preparer.Prepare((&http.Request{}).WithContext(ctx))
312 }
313
314
315
316 func (client HierarchySettingsClient) ListSender(req *http.Request) (*http.Response, error) {
317 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
318 }
319
320
321
322 func (client HierarchySettingsClient) ListResponder(resp *http.Response) (result HierarchySettingsList, err error) {
323 err = autorest.Respond(
324 resp,
325 azure.WithErrorUnlessStatusCode(http.StatusOK),
326 autorest.ByUnmarshallingJSON(&result),
327 autorest.ByClosing())
328 result.Response = autorest.Response{Response: resp}
329 return
330 }
331
332
333
334
335
336 func (client HierarchySettingsClient) Update(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (result HierarchySettings, err error) {
337 if tracing.IsEnabled() {
338 ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Update")
339 defer func() {
340 sc := -1
341 if result.Response.Response != nil {
342 sc = result.Response.Response.StatusCode
343 }
344 tracing.EndSpan(ctx, sc, err)
345 }()
346 }
347 req, err := client.UpdatePreparer(ctx, groupID, createTenantSettingsRequest)
348 if err != nil {
349 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", nil, "Failure preparing request")
350 return
351 }
352
353 resp, err := client.UpdateSender(req)
354 if err != nil {
355 result.Response = autorest.Response{Response: resp}
356 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", resp, "Failure sending request")
357 return
358 }
359
360 result, err = client.UpdateResponder(resp)
361 if err != nil {
362 err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", resp, "Failure responding to request")
363 return
364 }
365
366 return
367 }
368
369
370 func (client HierarchySettingsClient) UpdatePreparer(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (*http.Request, error) {
371 pathParameters := map[string]interface{}{
372 "groupId": autorest.Encode("path", groupID),
373 }
374
375 const APIVersion = "2020-02-01"
376 queryParameters := map[string]interface{}{
377 "api-version": APIVersion,
378 }
379
380 preparer := autorest.CreatePreparer(
381 autorest.AsContentType("application/json; charset=utf-8"),
382 autorest.AsPatch(),
383 autorest.WithBaseURL(client.BaseURI),
384 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters),
385 autorest.WithJSON(createTenantSettingsRequest),
386 autorest.WithQueryParameters(queryParameters))
387 return preparer.Prepare((&http.Request{}).WithContext(ctx))
388 }
389
390
391
392 func (client HierarchySettingsClient) UpdateSender(req *http.Request) (*http.Response, error) {
393 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
394 }
395
396
397
398 func (client HierarchySettingsClient) UpdateResponder(resp *http.Response) (result HierarchySettings, err error) {
399 err = autorest.Respond(
400 resp,
401 azure.WithErrorUnlessStatusCode(http.StatusOK),
402 autorest.ByUnmarshallingJSON(&result),
403 autorest.ByClosing())
404 result.Response = autorest.Response{Response: resp}
405 return
406 }
407
View as plain text