1 package network
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 ApplicationGatewayPrivateLinkResourcesClient struct {
19 BaseClient
20 }
21
22
23
24 func NewApplicationGatewayPrivateLinkResourcesClient(subscriptionID string) ApplicationGatewayPrivateLinkResourcesClient {
25 return NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGatewayPrivateLinkResourcesClient {
32 return ApplicationGatewayPrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39 func (client ApplicationGatewayPrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateLinkResourceListResultPage, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateLinkResourcesClient.List")
42 defer func() {
43 sc := -1
44 if result.agplrlr.Response.Response != nil {
45 sc = result.agplrlr.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 result.fn = client.listNextResults
51 req, err := client.ListPreparer(ctx, resourceGroupName, applicationGatewayName)
52 if err != nil {
53 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", nil, "Failure preparing request")
54 return
55 }
56
57 resp, err := client.ListSender(req)
58 if err != nil {
59 result.agplrlr.Response = autorest.Response{Response: resp}
60 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", resp, "Failure sending request")
61 return
62 }
63
64 result.agplrlr, err = client.ListResponder(resp)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", resp, "Failure responding to request")
67 return
68 }
69 if result.agplrlr.hasNextLink() && result.agplrlr.IsEmpty() {
70 err = result.NextWithContext(ctx)
71 return
72 }
73
74 return
75 }
76
77
78 func (client ApplicationGatewayPrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) {
79 pathParameters := map[string]interface{}{
80 "applicationGatewayName": autorest.Encode("path", applicationGatewayName),
81 "resourceGroupName": autorest.Encode("path", resourceGroupName),
82 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
83 }
84
85 const APIVersion = "2022-05-01"
86 queryParameters := map[string]interface{}{
87 "api-version": APIVersion,
88 }
89
90 preparer := autorest.CreatePreparer(
91 autorest.AsGet(),
92 autorest.WithBaseURL(client.BaseURI),
93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateLinkResources", pathParameters),
94 autorest.WithQueryParameters(queryParameters))
95 return preparer.Prepare((&http.Request{}).WithContext(ctx))
96 }
97
98
99
100 func (client ApplicationGatewayPrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) {
101 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
102 }
103
104
105
106 func (client ApplicationGatewayPrivateLinkResourcesClient) ListResponder(resp *http.Response) (result ApplicationGatewayPrivateLinkResourceListResult, err error) {
107 err = autorest.Respond(
108 resp,
109 azure.WithErrorUnlessStatusCode(http.StatusOK),
110 autorest.ByUnmarshallingJSON(&result),
111 autorest.ByClosing())
112 result.Response = autorest.Response{Response: resp}
113 return
114 }
115
116
117 func (client ApplicationGatewayPrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayPrivateLinkResourceListResult) (result ApplicationGatewayPrivateLinkResourceListResult, err error) {
118 req, err := lastResults.applicationGatewayPrivateLinkResourceListResultPreparer(ctx)
119 if err != nil {
120 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request")
121 }
122 if req == nil {
123 return
124 }
125 resp, err := client.ListSender(req)
126 if err != nil {
127 result.Response = autorest.Response{Response: resp}
128 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request")
129 }
130 result, err = client.ListResponder(resp)
131 if err != nil {
132 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request")
133 }
134 return
135 }
136
137
138 func (client ApplicationGatewayPrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateLinkResourceListResultIterator, err error) {
139 if tracing.IsEnabled() {
140 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateLinkResourcesClient.List")
141 defer func() {
142 sc := -1
143 if result.Response().Response.Response != nil {
144 sc = result.page.Response().Response.Response.StatusCode
145 }
146 tracing.EndSpan(ctx, sc, err)
147 }()
148 }
149 result.page, err = client.List(ctx, resourceGroupName, applicationGatewayName)
150 return
151 }
152
View as plain text