1 package insights
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 AnalyticsItemsClient struct {
20 BaseClient
21 }
22
23
24 func NewAnalyticsItemsClient(subscriptionID string) AnalyticsItemsClient {
25 return NewAnalyticsItemsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewAnalyticsItemsClientWithBaseURI(baseURI string, subscriptionID string) AnalyticsItemsClient {
31 return AnalyticsItemsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41
42 func (client AnalyticsItemsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result autorest.Response, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Delete")
45 defer func() {
46 sc := -1
47 if result.Response != nil {
48 sc = result.Response.StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: client.SubscriptionID,
55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
56 {TargetValue: resourceGroupName,
57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
59 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
60 return result, validation.NewError("insights.AnalyticsItemsClient", "Delete", err.Error())
61 }
62
63 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name)
64 if err != nil {
65 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", nil, "Failure preparing request")
66 return
67 }
68
69 resp, err := client.DeleteSender(req)
70 if err != nil {
71 result.Response = resp
72 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure sending request")
73 return
74 }
75
76 result, err = client.DeleteResponder(resp)
77 if err != nil {
78 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure responding to request")
79 return
80 }
81
82 return
83 }
84
85
86 func (client AnalyticsItemsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) {
87 pathParameters := map[string]interface{}{
88 "resourceGroupName": autorest.Encode("path", resourceGroupName),
89 "resourceName": autorest.Encode("path", resourceName),
90 "scopePath": autorest.Encode("path", scopePath),
91 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
92 }
93
94 const APIVersion = "2015-05-01"
95 queryParameters := map[string]interface{}{
96 "api-version": APIVersion,
97 }
98 if len(ID) > 0 {
99 queryParameters["id"] = autorest.Encode("query", ID)
100 }
101 if len(name) > 0 {
102 queryParameters["name"] = autorest.Encode("query", name)
103 }
104
105 preparer := autorest.CreatePreparer(
106 autorest.AsDelete(),
107 autorest.WithBaseURL(client.BaseURI),
108 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
109 autorest.WithQueryParameters(queryParameters))
110 return preparer.Prepare((&http.Request{}).WithContext(ctx))
111 }
112
113
114
115 func (client AnalyticsItemsClient) DeleteSender(req *http.Request) (*http.Response, error) {
116 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
117 }
118
119
120
121 func (client AnalyticsItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
122 err = autorest.Respond(
123 resp,
124 azure.WithErrorUnlessStatusCode(http.StatusOK),
125 autorest.ByClosing())
126 result.Response = resp
127 return
128 }
129
130
131
132
133
134
135
136
137
138 func (client AnalyticsItemsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result ApplicationInsightsComponentAnalyticsItem, err error) {
139 if tracing.IsEnabled() {
140 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Get")
141 defer func() {
142 sc := -1
143 if result.Response.Response != nil {
144 sc = result.Response.Response.StatusCode
145 }
146 tracing.EndSpan(ctx, sc, err)
147 }()
148 }
149 if err := validation.Validate([]validation.Validation{
150 {TargetValue: client.SubscriptionID,
151 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
152 {TargetValue: resourceGroupName,
153 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
154 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
155 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
156 return result, validation.NewError("insights.AnalyticsItemsClient", "Get", err.Error())
157 }
158
159 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name)
160 if err != nil {
161 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", nil, "Failure preparing request")
162 return
163 }
164
165 resp, err := client.GetSender(req)
166 if err != nil {
167 result.Response = autorest.Response{Response: resp}
168 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure sending request")
169 return
170 }
171
172 result, err = client.GetResponder(resp)
173 if err != nil {
174 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure responding to request")
175 return
176 }
177
178 return
179 }
180
181
182 func (client AnalyticsItemsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) {
183 pathParameters := map[string]interface{}{
184 "resourceGroupName": autorest.Encode("path", resourceGroupName),
185 "resourceName": autorest.Encode("path", resourceName),
186 "scopePath": autorest.Encode("path", scopePath),
187 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
188 }
189
190 const APIVersion = "2015-05-01"
191 queryParameters := map[string]interface{}{
192 "api-version": APIVersion,
193 }
194 if len(ID) > 0 {
195 queryParameters["id"] = autorest.Encode("query", ID)
196 }
197 if len(name) > 0 {
198 queryParameters["name"] = autorest.Encode("query", name)
199 }
200
201 preparer := autorest.CreatePreparer(
202 autorest.AsGet(),
203 autorest.WithBaseURL(client.BaseURI),
204 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
205 autorest.WithQueryParameters(queryParameters))
206 return preparer.Prepare((&http.Request{}).WithContext(ctx))
207 }
208
209
210
211 func (client AnalyticsItemsClient) GetSender(req *http.Request) (*http.Response, error) {
212 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
213 }
214
215
216
217 func (client AnalyticsItemsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) {
218 err = autorest.Respond(
219 resp,
220 azure.WithErrorUnlessStatusCode(http.StatusOK),
221 autorest.ByUnmarshallingJSON(&result),
222 autorest.ByClosing())
223 result.Response = autorest.Response{Response: resp}
224 return
225 }
226
227
228
229
230
231
232
233
234
235
236
237
238 func (client AnalyticsItemsClient) List(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (result ListApplicationInsightsComponentAnalyticsItem, err error) {
239 if tracing.IsEnabled() {
240 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.List")
241 defer func() {
242 sc := -1
243 if result.Response.Response != nil {
244 sc = result.Response.Response.StatusCode
245 }
246 tracing.EndSpan(ctx, sc, err)
247 }()
248 }
249 if err := validation.Validate([]validation.Validation{
250 {TargetValue: client.SubscriptionID,
251 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
252 {TargetValue: resourceGroupName,
253 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
254 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
255 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
256 return result, validation.NewError("insights.AnalyticsItemsClient", "List", err.Error())
257 }
258
259 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, scopePath, scope, typeParameter, includeContent)
260 if err != nil {
261 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", nil, "Failure preparing request")
262 return
263 }
264
265 resp, err := client.ListSender(req)
266 if err != nil {
267 result.Response = autorest.Response{Response: resp}
268 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure sending request")
269 return
270 }
271
272 result, err = client.ListResponder(resp)
273 if err != nil {
274 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure responding to request")
275 return
276 }
277
278 return
279 }
280
281
282 func (client AnalyticsItemsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (*http.Request, error) {
283 pathParameters := map[string]interface{}{
284 "resourceGroupName": autorest.Encode("path", resourceGroupName),
285 "resourceName": autorest.Encode("path", resourceName),
286 "scopePath": autorest.Encode("path", scopePath),
287 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
288 }
289
290 const APIVersion = "2015-05-01"
291 queryParameters := map[string]interface{}{
292 "api-version": APIVersion,
293 }
294 if len(string(scope)) > 0 {
295 queryParameters["scope"] = autorest.Encode("query", scope)
296 } else {
297 queryParameters["scope"] = autorest.Encode("query", "shared")
298 }
299 if len(string(typeParameter)) > 0 {
300 queryParameters["type"] = autorest.Encode("query", typeParameter)
301 } else {
302 queryParameters["type"] = autorest.Encode("query", "none")
303 }
304 if includeContent != nil {
305 queryParameters["includeContent"] = autorest.Encode("query", *includeContent)
306 }
307
308 preparer := autorest.CreatePreparer(
309 autorest.AsGet(),
310 autorest.WithBaseURL(client.BaseURI),
311 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}", pathParameters),
312 autorest.WithQueryParameters(queryParameters))
313 return preparer.Prepare((&http.Request{}).WithContext(ctx))
314 }
315
316
317
318 func (client AnalyticsItemsClient) ListSender(req *http.Request) (*http.Response, error) {
319 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
320 }
321
322
323
324 func (client AnalyticsItemsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentAnalyticsItem, err error) {
325 err = autorest.Respond(
326 resp,
327 azure.WithErrorUnlessStatusCode(http.StatusOK),
328 autorest.ByUnmarshallingJSON(&result.Value),
329 autorest.ByClosing())
330 result.Response = autorest.Response{Response: resp}
331 return
332 }
333
334
335
336
337
338
339
340
341
342
343
344 func (client AnalyticsItemsClient) Put(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (result ApplicationInsightsComponentAnalyticsItem, err error) {
345 if tracing.IsEnabled() {
346 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Put")
347 defer func() {
348 sc := -1
349 if result.Response.Response != nil {
350 sc = result.Response.Response.StatusCode
351 }
352 tracing.EndSpan(ctx, sc, err)
353 }()
354 }
355 if err := validation.Validate([]validation.Validation{
356 {TargetValue: client.SubscriptionID,
357 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
358 {TargetValue: resourceGroupName,
359 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
360 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
361 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
362 return result, validation.NewError("insights.AnalyticsItemsClient", "Put", err.Error())
363 }
364
365 req, err := client.PutPreparer(ctx, resourceGroupName, resourceName, scopePath, itemProperties, overrideItem)
366 if err != nil {
367 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", nil, "Failure preparing request")
368 return
369 }
370
371 resp, err := client.PutSender(req)
372 if err != nil {
373 result.Response = autorest.Response{Response: resp}
374 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure sending request")
375 return
376 }
377
378 result, err = client.PutResponder(resp)
379 if err != nil {
380 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure responding to request")
381 return
382 }
383
384 return
385 }
386
387
388 func (client AnalyticsItemsClient) PutPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (*http.Request, error) {
389 pathParameters := map[string]interface{}{
390 "resourceGroupName": autorest.Encode("path", resourceGroupName),
391 "resourceName": autorest.Encode("path", resourceName),
392 "scopePath": autorest.Encode("path", scopePath),
393 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
394 }
395
396 const APIVersion = "2015-05-01"
397 queryParameters := map[string]interface{}{
398 "api-version": APIVersion,
399 }
400 if overrideItem != nil {
401 queryParameters["overrideItem"] = autorest.Encode("query", *overrideItem)
402 }
403
404 itemProperties.Version = nil
405 itemProperties.TimeCreated = nil
406 itemProperties.TimeModified = nil
407 preparer := autorest.CreatePreparer(
408 autorest.AsContentType("application/json; charset=utf-8"),
409 autorest.AsPut(),
410 autorest.WithBaseURL(client.BaseURI),
411 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
412 autorest.WithJSON(itemProperties),
413 autorest.WithQueryParameters(queryParameters))
414 return preparer.Prepare((&http.Request{}).WithContext(ctx))
415 }
416
417
418
419 func (client AnalyticsItemsClient) PutSender(req *http.Request) (*http.Response, error) {
420 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
421 }
422
423
424
425 func (client AnalyticsItemsClient) PutResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) {
426 err = autorest.Respond(
427 resp,
428 azure.WithErrorUnlessStatusCode(http.StatusOK),
429 autorest.ByUnmarshallingJSON(&result),
430 autorest.ByClosing())
431 result.Response = autorest.Response{Response: resp}
432 return
433 }
434
View as plain text