...
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/tracing"
14 "net/http"
15 )
16
17
18 type VMInsightsClient struct {
19 BaseClient
20 }
21
22
23 func NewVMInsightsClient(subscriptionID string) VMInsightsClient {
24 return NewVMInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewVMInsightsClientWithBaseURI(baseURI string, subscriptionID string) VMInsightsClient {
30 return VMInsightsClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36
37 func (client VMInsightsClient) GetOnboardingStatus(ctx context.Context, resourceURI string) (result VMInsightsOnboardingStatus, err error) {
38 if tracing.IsEnabled() {
39 ctx = tracing.StartSpan(ctx, fqdn+"/VMInsightsClient.GetOnboardingStatus")
40 defer func() {
41 sc := -1
42 if result.Response.Response != nil {
43 sc = result.Response.Response.StatusCode
44 }
45 tracing.EndSpan(ctx, sc, err)
46 }()
47 }
48 req, err := client.GetOnboardingStatusPreparer(ctx, resourceURI)
49 if err != nil {
50 err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", nil, "Failure preparing request")
51 return
52 }
53
54 resp, err := client.GetOnboardingStatusSender(req)
55 if err != nil {
56 result.Response = autorest.Response{Response: resp}
57 err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure sending request")
58 return
59 }
60
61 result, err = client.GetOnboardingStatusResponder(resp)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure responding to request")
64 return
65 }
66
67 return
68 }
69
70
71 func (client VMInsightsClient) GetOnboardingStatusPreparer(ctx context.Context, resourceURI string) (*http.Request, error) {
72 pathParameters := map[string]interface{}{
73 "resourceUri": resourceURI,
74 }
75
76 const APIVersion = "2018-11-27-preview"
77 queryParameters := map[string]interface{}{
78 "api-version": APIVersion,
79 }
80
81 preparer := autorest.CreatePreparer(
82 autorest.AsGet(),
83 autorest.WithBaseURL(client.BaseURI),
84 autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default", pathParameters),
85 autorest.WithQueryParameters(queryParameters))
86 return preparer.Prepare((&http.Request{}).WithContext(ctx))
87 }
88
89
90
91 func (client VMInsightsClient) GetOnboardingStatusSender(req *http.Request) (*http.Response, error) {
92 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
93 }
94
95
96
97 func (client VMInsightsClient) GetOnboardingStatusResponder(resp *http.Response) (result VMInsightsOnboardingStatus, err error) {
98 err = autorest.Respond(
99 resp,
100 azure.WithErrorUnlessStatusCode(http.StatusOK),
101 autorest.ByUnmarshallingJSON(&result),
102 autorest.ByClosing())
103 result.Response = autorest.Response{Response: resp}
104 return
105 }
106
View as plain text