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 ServiceAssociationLinksClient struct {
19 BaseClient
20 }
21
22
23 func NewServiceAssociationLinksClient(subscriptionID string) ServiceAssociationLinksClient {
24 return NewServiceAssociationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29
30 func NewServiceAssociationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServiceAssociationLinksClient {
31 return ServiceAssociationLinksClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client ServiceAssociationLinksClient) List(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (result ServiceAssociationLinksListResult, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceAssociationLinksClient.List")
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 req, err := client.ListPreparer(ctx, resourceGroupName, virtualNetworkName, subnetName)
51 if err != nil {
52 err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", nil, "Failure preparing request")
53 return
54 }
55
56 resp, err := client.ListSender(req)
57 if err != nil {
58 result.Response = autorest.Response{Response: resp}
59 err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", resp, "Failure sending request")
60 return
61 }
62
63 result, err = client.ListResponder(resp)
64 if err != nil {
65 err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", resp, "Failure responding to request")
66 return
67 }
68
69 return
70 }
71
72
73 func (client ServiceAssociationLinksClient) ListPreparer(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (*http.Request, error) {
74 pathParameters := map[string]interface{}{
75 "resourceGroupName": autorest.Encode("path", resourceGroupName),
76 "subnetName": autorest.Encode("path", subnetName),
77 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
78 "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
79 }
80
81 const APIVersion = "2021-08-01"
82 queryParameters := map[string]interface{}{
83 "api-version": APIVersion,
84 }
85
86 preparer := autorest.CreatePreparer(
87 autorest.AsGet(),
88 autorest.WithBaseURL(client.BaseURI),
89 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/ServiceAssociationLinks", pathParameters),
90 autorest.WithQueryParameters(queryParameters))
91 return preparer.Prepare((&http.Request{}).WithContext(ctx))
92 }
93
94
95
96 func (client ServiceAssociationLinksClient) ListSender(req *http.Request) (*http.Response, error) {
97 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
98 }
99
100
101
102 func (client ServiceAssociationLinksClient) ListResponder(resp *http.Response) (result ServiceAssociationLinksListResult, err error) {
103 err = autorest.Respond(
104 resp,
105 azure.WithErrorUnlessStatusCode(http.StatusOK),
106 autorest.ByUnmarshallingJSON(&result),
107 autorest.ByClosing())
108 result.Response = autorest.Response{Response: resp}
109 return
110 }
111
View as plain text