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