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 ComponentAvailableFeaturesClient struct {
20 BaseClient
21 }
22
23
24 func NewComponentAvailableFeaturesClient(subscriptionID string) ComponentAvailableFeaturesClient {
25 return NewComponentAvailableFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewComponentAvailableFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentAvailableFeaturesClient {
32 return ComponentAvailableFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39 func (client ComponentAvailableFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentAvailableFeatures, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentAvailableFeaturesClient.Get")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 if err := validation.Validate([]validation.Validation{
51 {TargetValue: resourceGroupName,
52 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
54 {TargetValue: client.SubscriptionID,
55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
56 return result, validation.NewError("insights.ComponentAvailableFeaturesClient", "Get", err.Error())
57 }
58
59 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
60 if err != nil {
61 err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", nil, "Failure preparing request")
62 return
63 }
64
65 resp, err := client.GetSender(req)
66 if err != nil {
67 result.Response = autorest.Response{Response: resp}
68 err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", resp, "Failure sending request")
69 return
70 }
71
72 result, err = client.GetResponder(resp)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", resp, "Failure responding to request")
75 return
76 }
77
78 return
79 }
80
81
82 func (client ComponentAvailableFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
83 pathParameters := map[string]interface{}{
84 "resourceGroupName": autorest.Encode("path", resourceGroupName),
85 "resourceName": autorest.Encode("path", resourceName),
86 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
87 }
88
89 const APIVersion = "2015-05-01"
90 queryParameters := map[string]interface{}{
91 "api-version": APIVersion,
92 }
93
94 preparer := autorest.CreatePreparer(
95 autorest.AsGet(),
96 autorest.WithBaseURL(client.BaseURI),
97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures", pathParameters),
98 autorest.WithQueryParameters(queryParameters))
99 return preparer.Prepare((&http.Request{}).WithContext(ctx))
100 }
101
102
103
104 func (client ComponentAvailableFeaturesClient) GetSender(req *http.Request) (*http.Response, error) {
105 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
106 }
107
108
109
110 func (client ComponentAvailableFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAvailableFeatures, err error) {
111 err = autorest.Respond(
112 resp,
113 azure.WithErrorUnlessStatusCode(http.StatusOK),
114 autorest.ByUnmarshallingJSON(&result),
115 autorest.ByClosing())
116 result.Response = autorest.Response{Response: resp}
117 return
118 }
119
View as plain text